From 81973ba49677efb9b0584d138318b890d20a510a Mon Sep 17 00:00:00 2001 From: j Date: Sat, 9 Dec 2017 13:51:56 +0100 Subject: [PATCH] redirects, optional content --- camp/urls.py | 6 +++++- content/templates/detail.html | 4 ++++ content/views.py | 5 ++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/camp/urls.py b/camp/urls.py index c2805c4..c8030ae 100644 --- a/camp/urls.py +++ b/camp/urls.py @@ -14,8 +14,11 @@ Including another URLconf 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) """ from django.conf.urls import url -from content import views from django.contrib import admin +from django.views.generic import RedirectView + +from content import views + urlpatterns = [ url(r'^admin/', admin.site.urls), @@ -24,6 +27,7 @@ urlpatterns = [ url(r'^.*index.php$', views.redirect_index, name='redirect_index'), url(r'^.*event.php$', views.redirect_event, name='redirect_event'), url(r'^.*(/images/.*)$', views.redirect_images, name='redirect_images'), + url(r'directions.html', RedirectView.as_view(url='/directions/')), url(r'^projects/', views.projects, name='projects'), url(r'^events/', views.events, name='events'), diff --git a/content/templates/detail.html b/content/templates/detail.html index ec3141b..4e52db4 100644 --- a/content/templates/detail.html +++ b/content/templates/detail.html @@ -7,7 +7,9 @@ {% endif %} +{% if content.image_url %} +{% endif %}

{{ content.title }}

@@ -33,6 +35,7 @@
{% endif %} +{% if content.parent or content.children.exists %}
In This Event:
+{% endif %} {% if content.resources.exists %} {% if content.links.exists %} diff --git a/content/views.py b/content/views.py index dfaa3c9..7587ba6 100644 --- a/content/views.py +++ b/content/views.py @@ -15,7 +15,10 @@ def index(request): return render(request, 'index.html', context) def content(request, shortname): - content = get_object_or_404(Content, shortname=shortname, published=True) + if request.user.is_staff: + content = get_object_or_404(Content, shortname=shortname) + else: + content = get_object_or_404(Content, shortname=shortname, published=True) return render(request, 'detail.html', {'content': content}) def projects(request):