From f6895e7d2518e40d34b379b50b4b7490626332c4 Mon Sep 17 00:00:00 2001 From: Evert Date: Fri, 10 Nov 2017 17:21:21 +0200 Subject: [PATCH] Show - Added Submissions Page --- LandingPage/static/css/style.css | 83 ++++++++++++++++++++++++-------- Show/templates/episode.html | 32 ++++++++++++ Show/templates/show.html | 9 ++-- Show/urls.py | 3 +- Show/views.py | 28 ++++++++++- 5 files changed, 129 insertions(+), 26 deletions(-) create mode 100644 Show/templates/episode.html diff --git a/LandingPage/static/css/style.css b/LandingPage/static/css/style.css index 1adfa30..307e516 100644 --- a/LandingPage/static/css/style.css +++ b/LandingPage/static/css/style.css @@ -4,6 +4,15 @@ body { margin: 0; padding: 0; } +.button, input[type="submit"], button { + display: inline-block; + padding: 5px 10px; + background-color: #fdfdfd; + border: 1px solid #ddd; + border-radius: 5px; + text-decoration: none; + color: #000; +} .unibar { padding: 20px; border-bottom: 1px solid #ddd; @@ -96,35 +105,71 @@ section.show-details { font-size: 200%; } .show-details .details .description { - display: inline-grid; width: 80%; } -.show-details .details .data { - display: inline-grid; - text-align: right; -} -.show-details .stats .param { - color: #a2a2a2; -} -section.seasons { - min-height: 100vh; - padding: 25px; +section.seasons, section.submissions { + min-height: 100vh; + padding: 25px; } .season-name { - padding: 6px; - font-size: 180%; - background-color: #e8e8e8; + padding: 6px; + font-size: 180%; + background-color: #e8e8e8; } a.episode { - padding: 10px; - display: block; - color: #000; - text-decoration: none; - background-color: #f7f7f7; + padding: 10px; + display: block; + color: #000; + text-decoration: none; + background-color: #f7f7f7; } a.episode:nth-child(even) { background-color: #fbfbfb; } +a.episode .submission_cnt { + float: right; + color: #949494; +} +.submission-list .submission { + background-color: #f9f9f9; +} +.submission-list .submission:nth-child(even) { + background-color: #ececec; +} +.submission { + padding: 10px; +} +.submission a { + font-size: 180%; + text-decoration: none; + color: #191919; + font-style: italic; +} +.vote-btns { + float: right; +} +.vote-positive, .vote-negative { + padding: 10px; + display: inline-block; + min-width: 20px; + text-align: center; + border-radius: 5px; + font-weight: bold; +} +.vote-positive { + background-color: #a4ffa7; + color: #008005; +} +.vote-negative { + background-color: #ffa6a6; + color: #ab0000; +} +.submission.buried .vote-btns{ + opacity: 0.5; +} +.submission.buried a { + color: #d2d2d2; +} @media all and (max-width: 800px) { .logo { font-size: 5vw !important; diff --git a/Show/templates/episode.html b/Show/templates/episode.html new file mode 100644 index 0000000..e3b5d60 --- /dev/null +++ b/Show/templates/episode.html @@ -0,0 +1,32 @@ +{% extends "base.html" %} +{% block content %} +
+ + +
+
+ << Show Index +

Watch {{episode.name}} From

+
+ {% for sbm in submissions %} +
+  {{sbm.url}} +
+
 {{sbm.positives}}
+
 {{sbm.negatives}}
+
+
+ {% endfor %} +
+
+{% endblock %} diff --git a/Show/templates/show.html b/Show/templates/show.html index 64548da..8edd791 100644 --- a/Show/templates/show.html +++ b/Show/templates/show.html @@ -24,14 +24,15 @@
+

Watch Now

{% for season in seasons %}
{% if season.name %}{{season.number}} - {{season.name}}{% else %}Season {{season.number}}{%endif%}
- {% for episode in episodes %} - {% if episode.season == season %} - {{episode.episode}} - {{episode.name}} - {% endif %} + {% for episode in season.episodes.all %} + {{episode.episode}} - {{episode.name}} + {{episode.submissions.all|length}} Available Links + {% endfor %}
diff --git a/Show/urls.py b/Show/urls.py index aa3a679..504224c 100644 --- a/Show/urls.py +++ b/Show/urls.py @@ -19,5 +19,6 @@ from django.conf.urls import url, include from . import views urlpatterns = [ - url(r'^', views.Index.as_view()) + url(r'^$', views.IndexView.as_view()), + url(r'^episode/(?P\d{1,4})/(?P\d{1,4})/?$', views.EpisodeView.as_view()) ] diff --git a/Show/views.py b/Show/views.py index 0f208f5..ad83970 100644 --- a/Show/views.py +++ b/Show/views.py @@ -9,15 +9,39 @@ from django.http import HttpResponseRedirect from LandingPage.models import Show from LandingPage.models import Season from LandingPage.models import Episode +from LandingPage.models import Submission # Create your views here. -class Index (TemplateView): +class IndexView(TemplateView): template_name = "show.html" def get_context_data(self, abbreviation, **kwargs): ctx = super().get_context_data() ctx['show'] = Show.objects.filter(abbr=abbreviation).first() ctx['seasons'] = Season.objects.filter(show=ctx['show']) - ctx['episodes'] = Episode.objects.filter(show=ctx['show']) + ctx['episodes'] = Episode.objects.filter(show=ctx['show']).count() + return ctx + +class EpisodeView(TemplateView): + template_name = "episode.html" + + def get_context_data(self, abbreviation, season, episode, **kwargs): + ctx = super().get_context_data() + ctx['show'] = Show.objects.filter(abbr=abbreviation).first() + ctx['episode'] = Episode.objects.filter(show=ctx['show'],episode=episode).first() + + if not ctx['episode']: + return ctx + + # If you're smarter than me, maybe you can compress the next 8 lines into fewer ones by some django magic I'm not aware of + submissions = ctx['episode'].submissions.all() + + for sbm in submissions: + sbm.positives = sbm.votes.filter(positive=True).count() + sbm.negatives = sbm.votes.count() - sbm.positives + + # sorts by "score", TODO: less bullshit + ctx['submissions'] = reversed(sorted(submissions, key=lambda x: x.positives - x.negatives)) + return ctx