Quellcode durchsuchen

Stub in sports urls

Colin Powell vor 2 Jahren
Ursprung
Commit
654a64e82d

+ 18 - 0
vrobbler/apps/sports/urls.py

@@ -0,0 +1,18 @@
+from django.urls import path
+from sports import views
+
+app_name = 'sports'
+
+
+urlpatterns = [
+    path(
+        'sport-events/',
+        views.SportEventListView.as_view(),
+        name='event_list',
+    ),
+    path(
+        'sport-events/<slug:slug>/',
+        views.SportEventDetailView.as_view(),
+        name='event_detail',
+    ),
+]

+ 12 - 0
vrobbler/apps/sports/views.py

@@ -0,0 +1,12 @@
+from django.views import generic
+from sports.models import SportEvent
+
+
+class SportEventListView(generic.ListView):
+    model = SportEvent
+    paginate_by = 50
+
+
+class SportEventDetailView(generic.DetailView):
+    model = SportEvent
+    slug_field = 'uuid'

+ 33 - 0
vrobbler/templates/sports/sportevent_detail.html

@@ -0,0 +1,33 @@
+{% extends "base_detail.html" %}
+
+{% block title %}{{object.title}} - {{object.round.season.league}}{% endblock %}
+
+{% block details %}
+
+<div class="row">
+    <h2>{{object.tv_series}}</h2>
+    <div class="col-md">
+        <h3>Last scrobbles</h3>
+        <div class="table-responsive">
+            <table class="table table-striped table-sm">
+                <thead>
+                    <tr>
+                        <th scope="col">Date</th>
+                        <th scope="col">Season</th>
+                        <th scope="col">League</th>
+                    </tr>
+                </thead>
+                <tbody>
+                    {% for scrobble in object.scrobble_set.all %}
+                    <tr>
+                        <td>{{scrobble.timestamp}}</td>
+                        <td>{{scrobble.media_obj.round.season.name}}</td>
+                        <td>{{scrobble.media_obj.round.season.league}}</td>
+                    </tr>
+                    {% endfor %}
+                </tbody>
+            </table>
+        </div>
+    </div>
+</div>
+{% endblock %}

+ 36 - 0
vrobbler/templates/sports/sportevent_list.html

@@ -0,0 +1,36 @@
+{% extends "base_list.html" %}
+
+{% block title %}Sport events{% endblock %}
+
+{% block lists %}
+<div class="row">
+    <div class="col-md">
+        <div class="table-responsive">
+            <table class="table table-striped table-sm">
+                <thead>
+                    <tr>
+                        <th scope="col">Title</th>
+                        <th scope="col">Date</th>
+                        <th scope="col">Round</th>
+                        <th scope="col">League</th>
+                        <th scope="col">Scrobbles</th>
+                        <th scope="col">All time</th>
+                    </tr>
+                </thead>
+                <tbody>
+                    {% for obj in object_list %}
+                    <tr>
+                        <td><a href="{{obj.get_absolute_url}}">{{obj.title}}</a></td>
+                        <td>{{obj.start}}</td>
+                        <td>{{obj.round.name}}</td>
+                        <td>{{obj.round.league}}</td>
+                        <td>{{obj.scrobble_set.count}}</td>
+                        <td></td>
+                    </tr>
+                    {% endfor %}
+                </tbody>
+            </table>
+        </div>
+    </div>
+</div>
+{% endblock %}

+ 2 - 0
vrobbler/urls.py

@@ -5,6 +5,7 @@ from rest_framework import routers
 import vrobbler.apps.scrobbles.views as scrobbles_views
 from vrobbler.apps.books.api.views import AuthorViewSet, BookViewSet
 from vrobbler.apps.music import urls as music_urls
+from vrobbler.apps.sports import urls as sports_urls
 from vrobbler.apps.music.api.views import (
     AlbumViewSet,
     ArtistViewSet,
@@ -57,6 +58,7 @@ urlpatterns = [
     path("accounts/", include("allauth.urls")),
     path("", include(music_urls, namespace="music")),
     path("", include(video_urls, namespace="videos")),
+    path("", include(sports_urls, namespace="sports")),
     path("", include(scrobble_urls, namespace="scrobbles")),
     path(
         "", scrobbles_views.RecentScrobbleList.as_view(), name="vrobbler-home"