redirects, optional content

This commit is contained in:
j 2017-12-09 13:51:56 +01:00
parent 8f1c7435ec
commit 81973ba496
3 changed files with 13 additions and 2 deletions

View File

@ -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'),

View File

@ -7,7 +7,9 @@
</div>
{% endif %}
{% if content.image_url %}
<img src="{{ content.image_url }}" width="75%">
{% endif %}
<div class="content_detail">
<h1>{{ content.title }}</h1>
@ -33,6 +35,7 @@
</div>
{% endif %}
{% if content.parent or content.children.exists %}
<div class="context">
<b>In This Event</b>:
<ul>
@ -67,6 +70,7 @@
{% endif %}
</ul>
</div>
{% endif %}
{% if content.resources.exists %}
{% if content.links.exists %}

View File

@ -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):