Move the content templates/files into conservancy/content
These were previously intermingled with the static content in `conservancy/static`.
Before Width: | Height: | Size: 177 KiB After Width: | Height: | Size: 177 KiB |
Before Width: | Height: | Size: 145 KiB After Width: | Height: | Size: 145 KiB |
Before Width: | Height: | Size: 171 KiB After Width: | Height: | Size: 171 KiB |
Before Width: | Height: | Size: 146 KiB After Width: | Height: | Size: 146 KiB |
Before Width: | Height: | Size: 152 KiB After Width: | Height: | Size: 152 KiB |
|
@ -99,7 +99,6 @@ TEMPLATES = [
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
'DIRS': [
|
'DIRS': [
|
||||||
BASE_DIR / 'templates',
|
BASE_DIR / 'templates',
|
||||||
BASE_DIR / 'static',
|
|
||||||
],
|
],
|
||||||
'APP_DIRS': True,
|
'APP_DIRS': True,
|
||||||
'OPTIONS': {
|
'OPTIONS': {
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
from django.urls import path, re_path
|
from django.urls import path
|
||||||
from django.views.generic import TemplateView
|
from django.views.generic import TemplateView
|
||||||
|
|
||||||
from . import views as supp_views
|
from . import views as supp_views
|
||||||
from .. import views as static_views
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', supp_views.index),
|
path('', supp_views.index),
|
||||||
path('banner/', TemplateView.as_view(template_name='supporter/banners.html')),
|
path('banner/', TemplateView.as_view(template_name='supporter/banners.html')),
|
||||||
path('banners/', TemplateView.as_view(template_name='supporter/banners.html')),
|
path('banners/', TemplateView.as_view(template_name='supporter/banners.html')),
|
||||||
re_path(r'', static_views.index),
|
|
||||||
]
|
]
|
||||||
|
|
|
@ -52,8 +52,9 @@ urlpatterns = [
|
||||||
re_path(r'^GiveUpGitHub/', static_views.index),
|
re_path(r'^GiveUpGitHub/', static_views.index),
|
||||||
re_path(r'^learn/', static_views.index),
|
re_path(r'^learn/', static_views.index),
|
||||||
re_path(r'^npoacct/', static_views.index, {'fundraiser_sought': 'npoacct'}),
|
re_path(r'^npoacct/', static_views.index, {'fundraiser_sought': 'npoacct'}),
|
||||||
re_path(r'^overview/', static_views.index),
|
re_path(r'^overview/', static_views.index), # Unused?
|
||||||
re_path(r'^press/', static_views.index),
|
re_path(r'^press/', static_views.index),
|
||||||
re_path(r'^privacy-policy/', static_views.index),
|
re_path(r'^privacy-policy/', static_views.index),
|
||||||
re_path(r'^projects/', static_views.index),
|
re_path(r'^projects/', static_views.index),
|
||||||
|
re_path(r'^sustainer/', static_views.index),
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import mimetypes
|
import mimetypes
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.http import FileResponse, Http404, HttpResponseRedirect
|
from django.http import FileResponse, Http404, HttpResponse, HttpResponseRedirect
|
||||||
from django.template.response import TemplateResponse
|
from django.template import RequestContext, Template
|
||||||
|
|
||||||
from .local_context_processors import fundgoal_lookup
|
from .local_context_processors import fundgoal_lookup
|
||||||
|
|
||||||
|
@ -27,8 +27,7 @@ def index(request, *args, **kwargs):
|
||||||
infrastructure. If it finds a file but it's not a template, it will serve
|
infrastructure. If it finds a file but it's not a template, it will serve
|
||||||
the file as-is.
|
the file as-is.
|
||||||
"""
|
"""
|
||||||
# The name "static" has no connection to Django staticfiles.
|
base_path = settings.BASE_DIR / 'content'
|
||||||
base_path = settings.BASE_DIR / 'static'
|
|
||||||
path = request.path.lstrip('/')
|
path = request.path.lstrip('/')
|
||||||
if path.endswith('/'):
|
if path.endswith('/'):
|
||||||
path += 'index.html'
|
path += 'index.html'
|
||||||
|
@ -43,11 +42,13 @@ def index(request, *args, **kwargs):
|
||||||
if not is_template:
|
if not is_template:
|
||||||
return FileResponse(open(full_path, 'rb'))
|
return FileResponse(open(full_path, 'rb'))
|
||||||
else:
|
else:
|
||||||
context = kwargs.copy()
|
|
||||||
try:
|
try:
|
||||||
context['fundgoal'] = fundgoal_lookup(kwargs['fundraiser_sought'])
|
kwargs['fundgoal'] = fundgoal_lookup(kwargs['fundraiser_sought'])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
# Maybe this should open() the template file directly so that these
|
# These template are intentionally not in the template loader path, so
|
||||||
# don't have to be included in the global template TEMPLATES.DIRS?
|
# we open them directly, rather than using the template loader.
|
||||||
return TemplateResponse(request, path, context)
|
with open(full_path) as t:
|
||||||
|
template = Template(t.read())
|
||||||
|
context = RequestContext(request, kwargs)
|
||||||
|
return HttpResponse(template.render(context))
|
||||||
|
|