Merge sponsors.py into supporters app, frontpage.py into views.py
Just a small structural change so that the related functionality is grouped together.
This commit is contained in:
parent
44c0a9db32
commit
2ff551147c
11 changed files with 71 additions and 73 deletions
2
TODO.md
2
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 `<detail>` elements for supporter page hidden sections, rather than
|
||||
complex jQuery
|
||||
* remove jQuery
|
||||
|
|
|
@ -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)
|
|
@ -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)
|
|
@ -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')),
|
||||
]
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 %}
|
||||
<div class="supporter-type-selector">
|
||||
<strong>Become a Sustainer Now:</strong>
|
||||
|
@ -29,12 +29,12 @@
|
|||
| <a id="renewalSelector" href="#renewal">Annual Renew</a>
|
||||
</div>
|
||||
|
||||
{% 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 %}
|
||||
|
||||
<a name="renew" class="hidden"></a>
|
||||
{% 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 %}
|
||||
|
||||
<span id="form-correction-needed" class="form-error">Please ensure all form data above is correct.</span>
|
|
@ -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/'
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue