From a815e29f659d2b5acc1563476f2ccb3e8f295bbb Mon Sep 17 00:00:00 2001 From: Taizo 'Tsa6' Simpson Date: Sun, 24 Sep 2017 16:53:10 -0400 Subject: [PATCH] Added very basic framework for the landing page --- LandingPage/templates/landing_page.html | 11 +++++++++++ LandingPage/urls.py | 1 + LandingPage/views.py | 14 ++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 LandingPage/templates/landing_page.html diff --git a/LandingPage/templates/landing_page.html b/LandingPage/templates/landing_page.html new file mode 100644 index 0000000..3501747 --- /dev/null +++ b/LandingPage/templates/landing_page.html @@ -0,0 +1,11 @@ +{% for show in shows %} +
+

{{show.name}} [{{show.abbr}}]

+

{{show.description}}

+ +
+{% endfor %} diff --git a/LandingPage/urls.py b/LandingPage/urls.py index ae09a29..8c4c86d 100644 --- a/LandingPage/urls.py +++ b/LandingPage/urls.py @@ -5,5 +5,6 @@ from . import views urlpatterns = [ url(r'^login/redirect$', views.LoginRedirect.as_view()), url(r'^login$', views.Login.as_view()), + url(r'^$', views.LandingPage.as_view()), ] diff --git a/LandingPage/views.py b/LandingPage/views.py index dd4be9f..8fcd39a 100644 --- a/LandingPage/views.py +++ b/LandingPage/views.py @@ -1,12 +1,15 @@ from django.shortcuts import render from django.views import View +from django.views.generic.base import TemplateView from django.conf import settings from django.http import HttpResponse from django.http import HttpResponseRedirect +from django.db.models import Max import requests import hashlib import json from .models import User +from .models import Show # Create your views here. # Redirect url should point to this view @@ -77,3 +80,14 @@ def generateState(request): m.update(bytearray(request.session.session_key, 'utf-8')) m.update(bytearray(settings.SECRET_KEY, 'utf-8')) return m.hexdigest() + +class LandingPage(TemplateView): + + template_name = "landing_page.html" + + def get_context_data(self, **kwargs): + ctx = super().get_context_data() + ctx['shows'] = Show.objects.annotate(recency=Max('episodes__airdate')).order_by('-recency')[:8] + return ctx + +