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',
|
||||
'DIRS': [
|
||||
BASE_DIR / 'templates',
|
||||
BASE_DIR / 'static',
|
||||
],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
from django.urls import path, re_path
|
||||
from django.urls import path
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
from . import views as supp_views
|
||||
from .. import views as static_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')),
|
||||
re_path(r'', static_views.index),
|
||||
]
|
||||
|
|
|
@ -52,8 +52,9 @@ urlpatterns = [
|
|||
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),
|
||||
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),
|
||||
]
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import mimetypes
|
||||
|
||||
from django.conf import settings
|
||||
from django.http import FileResponse, Http404, HttpResponseRedirect
|
||||
from django.template.response import TemplateResponse
|
||||
from django.http import FileResponse, Http404, HttpResponse, HttpResponseRedirect
|
||||
from django.template import RequestContext, Template
|
||||
|
||||
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
|
||||
the file as-is.
|
||||
"""
|
||||
# The name "static" has no connection to Django staticfiles.
|
||||
base_path = settings.BASE_DIR / 'static'
|
||||
base_path = settings.BASE_DIR / 'content'
|
||||
path = request.path.lstrip('/')
|
||||
if path.endswith('/'):
|
||||
path += 'index.html'
|
||||
|
@ -43,11 +42,13 @@ def index(request, *args, **kwargs):
|
|||
if not is_template:
|
||||
return FileResponse(open(full_path, 'rb'))
|
||||
else:
|
||||
context = kwargs.copy()
|
||||
try:
|
||||
context['fundgoal'] = fundgoal_lookup(kwargs['fundraiser_sought'])
|
||||
kwargs['fundgoal'] = fundgoal_lookup(kwargs['fundraiser_sought'])
|
||||
except KeyError:
|
||||
pass
|
||||
# Maybe this should open() the template file directly so that these
|
||||
# don't have to be included in the global template TEMPLATES.DIRS?
|
||||
return TemplateResponse(request, path, context)
|
||||
# These template are intentionally not in the template loader path, so
|
||||
# we open them directly, rather than using the template loader.
|
||||
with open(full_path) as t:
|
||||
template = Template(t.read())
|
||||
context = RequestContext(request, kwargs)
|
||||
return HttpResponse(template.render(context))
|
||||
|
|