Makes admin urls work with Django 1.3 and adds a hint if no index page is defined

EmailTemplateFixes
Denis Krienbühl 2011-12-14 14:14:09 +01:00
parent db8113014c
commit f946ca1a3b
2 changed files with 23 additions and 15 deletions

View File

@ -1,15 +1,21 @@
# Create your views here. # Create your views here.
from django.shortcuts import render_to_response, get_object_or_404 from django.shortcuts import render_to_response
from django import settings
from django.template import RequestContext from django.template import RequestContext
from django import http from django import http
from django.utils import translation from django.utils import translation
from models import Page from models import Page
def page(request, page): def page(request, page):
p = get_object_or_404(Page, slug=page) try:
if not p.public: p = Page.objects.get(slug=page, public=True)
raise Http404 except Page.DoesNotExist:
return render_to_response("page.html", { "request" : request, "page":p, }, context_instance = RequestContext(request) ) raise http.Http404('%s page requested but not found' % page)
return render_to_response("page.html",
{ "request" : request, "page" : p, },
context_instance = RequestContext(request)
)
def langpage(request, lang, page): def langpage(request, lang, page):
translation.activate_language(lang) translation.activate_language(lang)

View File

@ -1,19 +1,21 @@
from django.conf.urls.defaults import *
from django.contrib import admin
from django.conf import settings from django.conf import settings
from django.conf.urls.defaults import patterns, include, url
from django.contrib import admin
admin.autodiscover() admin.autodiscover()
urlpatterns = patterns('', urlpatterns = patterns('',
(r'q/', include('questionnaire.urls')), url(r'q/', include('questionnaire.urls')),
(r'^take/(?P<questionnaire_id>[0-9]+)/$', 'questionnaire.views.generate_run'), url(r'^take/(?P<questionnaire_id>[0-9]+)/$', 'questionnaire.views.generate_run'),
(r'^$', 'page.views.page', {'page' : 'index'}), url(r'^$', 'page.views.page', {'page' : 'index'}),
(r'^(?P<page>.*)\.html$', 'page.views.page'), url(r'^(?P<page>.*)\.html$', 'page.views.page'),
(r'^(?P<lang>..)/(?P<page>.*)\.html$', 'page.views.langpage'), url(r'^(?P<lang>..)/(?P<page>.*)\.html$', 'page.views.langpage'),
(r'^setlang/$', 'questionnaire.views.set_language'), url(r'^setlang/$', 'questionnaire.views.set_language'),
(r'^media/(.*)', 'django.views.static.serve', url(r'^media/(.*)', 'django.views.static.serve',
{ 'document_root' : settings.MEDIA_ROOT }), { 'document_root' : settings.MEDIA_ROOT }),
(r'^admin/(.*)', admin.site.root), url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
url(r'^admin/', include(admin.site.urls)),
) )