diff --git a/TODO.md b/TODO.md index 9d8bff4f..5dbd27d9 100644 --- a/TODO.md +++ b/TODO.md @@ -6,11 +6,11 @@ * serve a 400 in Apache for a hostname we don't explicitly support * replace `internalNavigate` with inline flexbox layout * add tests for main pages returning 200 -* move `sponsors.py` and `sponsors.html` into `supporters` app # Done +* move `sponsors.py` and `sponsors.html` into `supporters` app * use `` elements for supporter page hidden sections, rather than complex jQuery * remove jQuery diff --git a/conservancy/frontpage.py b/conservancy/frontpage.py deleted file mode 100644 index 84858c1a..00000000 --- a/conservancy/frontpage.py +++ /dev/null @@ -1,21 +0,0 @@ -from datetime import datetime - -from django.shortcuts import render - -from .blog.models import Entry -from .news.models import PressRelease -from .supporters.models import Supporter - - -def view(request): - """Conservancy front page view - - Performs all object queries necessary to render the front page. - """ - now = datetime.now() - context = { - 'press_releases': PressRelease.objects.all().filter(pub_date__lte=now, sites=2)[:5], - 'supporters_count': Supporter.objects.all().filter(display_until_date__gte=now).count(), - 'blog': Entry.objects.all().filter(pub_date__lte=now)[:5], - } - return render(request, "frontpage.html", context) diff --git a/conservancy/sponsors.py b/conservancy/sponsors.py deleted file mode 100644 index 549b9c4b..00000000 --- a/conservancy/sponsors.py +++ /dev/null @@ -1,22 +0,0 @@ -from datetime import datetime - -from django.shortcuts import render - -from .supporters.models import Supporter - - -def view(request): - """Conservancy Sponsors Page view - - Performs object queries necessary to render the sponsors page. - """ - supporters = Supporter.objects.all().filter(display_until_date__gte=datetime.now()) - supporters_count = len(supporters) - anonymous_count = len(supporters.filter(display_name='Anonymous')) - supporters = supporters.exclude(display_name='Anonymous').order_by('ledger_entity_id') - c = { - 'supporters' : supporters, - 'supporters_count' : supporters_count, - 'anonymous_count' : anonymous_count - } - return render(request, "sponsors.html", c) diff --git a/conservancy/supporters/urls.py b/conservancy/supporters/urls.py index fdbae119..627fea06 100644 --- a/conservancy/supporters/urls.py +++ b/conservancy/supporters/urls.py @@ -1,10 +1,10 @@ from django.urls import path from django.views.generic import TemplateView -from . import views as supp_views +from . import views urlpatterns = [ - path('', supp_views.index), - path('banner/', TemplateView.as_view(template_name='supporter/banners.html')), - path('banners/', TemplateView.as_view(template_name='supporter/banners.html')), + path('', views.sustainers), + path('banner/', TemplateView.as_view(template_name='supporters/banners.html')), + path('banners/', TemplateView.as_view(template_name='supporters/banners.html')), ] diff --git a/conservancy/supporters/views.py b/conservancy/supporters/views.py index cd0f0666..28dad991 100644 --- a/conservancy/supporters/views.py +++ b/conservancy/supporters/views.py @@ -1,9 +1,12 @@ +from datetime import datetime + from django.shortcuts import render from .. import ParameterValidator +from .models import Supporter -def index(request): +def sustainers(request): with ParameterValidator(request.GET, 'upgrade_id') as validator: try: amount_param = float(request.GET['upgrade']) @@ -16,4 +19,21 @@ def index(request): 'partial_amount': partial_amount, 'minimum_amount': 120 - partial_amount, } - return render(request, "supporter/index.html", context) + return render(request, "supporters/sustainers.html", context) + + +def sponsors(request): + """Conservancy Sponsors Page view + + Performs object queries necessary to render the sponsors page. + """ + supporters = Supporter.objects.all().filter(display_until_date__gte=datetime.now()) + supporters_count = len(supporters) + anonymous_count = len(supporters.filter(display_name='Anonymous')) + supporters = supporters.exclude(display_name='Anonymous').order_by('ledger_entity_id') + c = { + 'supporters' : supporters, + 'supporters_count' : supporters_count, + 'anonymous_count' : anonymous_count + } + return render(request, "supporters/sponsors.html", c) diff --git a/conservancy/templates/supporter/banners.html b/conservancy/templates/supporters/banners.html similarity index 100% rename from conservancy/templates/supporter/banners.html rename to conservancy/templates/supporters/banners.html diff --git a/conservancy/templates/supporter/form_partial.html b/conservancy/templates/supporters/form_partial.html similarity index 100% rename from conservancy/templates/supporter/form_partial.html rename to conservancy/templates/supporters/form_partial.html diff --git a/conservancy/templates/sponsors.html b/conservancy/templates/supporters/sponsors.html similarity index 100% rename from conservancy/templates/sponsors.html rename to conservancy/templates/supporters/sponsors.html diff --git a/conservancy/templates/supporter/index.html b/conservancy/templates/supporters/sustainers.html similarity index 97% rename from conservancy/templates/supporter/index.html rename to conservancy/templates/supporters/sustainers.html index 8cf7514e..9e90a4ef 100644 --- a/conservancy/templates/supporter/index.html +++ b/conservancy/templates/supporters/sustainers.html @@ -20,7 +20,7 @@ {% if partial_amount > 0 %} - {% include "supporter/form_partial.html" with form_id="annual" min_amt=minimum_amount partial_amt=partial_amount article="an" only %} + {% include "supporters/form_partial.html" with form_id="annual" min_amt=minimum_amount partial_amt=partial_amount article="an" only %} {% else %}
Become a Sustainer Now: @@ -29,12 +29,12 @@ | Annual Renew
- {% include "supporter/form_partial.html" with form_id="annual" min_amt=120 default_amt=128 article="an" only %} + {% include "supporters/form_partial.html" with form_id="annual" min_amt=120 default_amt=128 article="an" only %} - {% include "supporter/form_partial.html" with form_id="monthly" min_amt=10 default_amt=12 only %} + {% include "supporters/form_partial.html" with form_id="monthly" min_amt=10 default_amt=12 only %} - {% include "supporter/form_partial.html" with form_id="renewal" min_amt=120 default_amt=128 verb="renew" article="an" supptype="annual" only %} + {% include "supporters/form_partial.html" with form_id="renewal" min_amt=120 default_amt=128 verb="renew" article="an" supptype="annual" only %} {% endif %} Please ensure all form data above is correct. diff --git a/conservancy/urls.py b/conservancy/urls.py index 97588605..e8450778 100644 --- a/conservancy/urls.py +++ b/conservancy/urls.py @@ -22,12 +22,13 @@ from django.conf.urls.static import static from django.contrib import admin from django.urls import include, path, re_path -from . import feeds, frontpage, sponsors +from . import feeds from .fundgoal import views as fundgoal_views -from . import views as static_views +from . import views +from conservancy.supporters import views as supporters_views urlpatterns = [ - path('', frontpage.view), + path('', views.frontpage), path('admin/', admin.site.urls), path('assignment/', include('conservancy.assignment.urls')), path('blog/', include('conservancy.blog.urls')), @@ -41,25 +42,25 @@ urlpatterns = [ path('fossy/', include('conservancy.fossy.urls')), path('fundraiser_data/', fundgoal_views.view), path('news/', include('conservancy.news.urls')), - path('sponsors/', sponsors.view), - path('sponsors/index.html', sponsors.view), + path('sponsors/', supporters_views.sponsors), + path('sponsors/index.html', supporters_views.sponsors), path('sustainer/', include('conservancy.supporters.urls')), path('usethesource/', include('conservancy.usethesource.urls')), # Directories of templates and files - re_path(r'^about/', static_views.index), - re_path(r'^activities/', static_views.index), - re_path(r'^copyleft-compliance/', static_views.index, {'fundraiser_sought': 'vmware-match-0'}), - re_path(r'^donate/', static_views.index), - path('fossy/', static_views.index), - re_path(r'^GiveUpGitHub/', static_views.index), - re_path(r'^learn/', static_views.index), - re_path(r'^npoacct/', static_views.index, {'fundraiser_sought': 'npoacct'}), - re_path(r'^overview/', static_views.index), # Unused? - re_path(r'^press/', static_views.index), - re_path(r'^privacy-policy/', static_views.index), - re_path(r'^projects/', static_views.index), - re_path(r'^sustainer/', static_views.index), + re_path(r'^about/', views.content), + re_path(r'^activities/', views.content), + re_path(r'^copyleft-compliance/', views.content, {'fundraiser_sought': 'vmware-match-0'}), + re_path(r'^donate/', views.content), + path('fossy/', views.content), + re_path(r'^GiveUpGitHub/', views.content), + re_path(r'^learn/', views.content), + re_path(r'^npoacct/', views.content, {'fundraiser_sought': 'npoacct'}), + re_path(r'^overview/', views.content), # Unused? + re_path(r'^press/', views.content), + re_path(r'^privacy-policy/', views.content), + re_path(r'^projects/', views.content), + re_path(r'^sustainer/', views.content), ] # Serve uploaded media. Works only when DEBUG == True. Using '/media/' diff --git a/conservancy/views.py b/conservancy/views.py index 21f5b175..5509b387 100644 --- a/conservancy/views.py +++ b/conservancy/views.py @@ -1,12 +1,32 @@ +from datetime import datetime import mimetypes from django.conf import settings from django.http import FileResponse, Http404, HttpResponse, HttpResponseRedirect +from django.shortcuts import render from django.template import RequestContext, Template +from .blog.models import Entry from .local_context_processors import fundgoal_lookup +from .news.models import PressRelease +from .supporters.models import Supporter -def index(request, *args, **kwargs): + +def frontpage(request): + """Conservancy front page view + + Performs all object queries necessary to render the front page. + """ + now = datetime.now() + context = { + 'press_releases': PressRelease.objects.all().filter(pub_date__lte=now, sites=2)[:5], + 'supporters_count': Supporter.objects.all().filter(display_until_date__gte=now).count(), + 'blog': Entry.objects.all().filter(pub_date__lte=now)[:5], + } + return render(request, "frontpage.html", context) + + +def content(request, *args, **kwargs): """Faux CMS: bulk website content stored in templates and document files. Rationale: Many websites have a CMS and store the majority of their website