Skip to content
Snippets Groups Projects
Commit b83a0501 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Added 404 to information cms system

parent d260a109
No related branches found
No related tags found
No related merge requests found
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
# #
from django.shortcuts import render from django.shortcuts import render
from django.core.exceptions import ObjectDoesNotExist
from django.http import Http404
from information.models import InformationLocale, Information from information.models import InformationLocale, Information
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
...@@ -32,22 +34,26 @@ def index(request): ...@@ -32,22 +34,26 @@ def index(request):
return render(request, 'information/index.html', context) return render(request, 'information/index.html', context)
def detail(request, information_id): def detail(request, information_id):
information_locale = InformationLocale.get_information_locale_with_fallback(information_id, request.LANGUAGE_CODE) try:
# Is there a parent? information_locale = InformationLocale.get_information_locale_with_fallback(information_id, request.LANGUAGE_CODE)
#parent_information = information_locale.information.parent_information # Is there a parent?
# We get all the children too #parent_information = information_locale.information.parent_information
#children_locales = [] # We get all the children too
#for child in information_locale.information.children.all(): #children_locales = []
# children_locales.append(InformationLocale.get_information_locale_with_fallback(child.pk)) #for child in information_locale.information.children.all():
# children_locales.append(InformationLocale.get_information_locale_with_fallback(child.pk))
context = {
'information_locale' : information_locale, context = {
#'parent_information' : parent_information, 'information_locale' : information_locale,
#'children_locales':children_locales, #'parent_information' : parent_information,
'breadcrumb': get_breadcrumb(information_locale.information, request.LANGUAGE_CODE), #'children_locales':children_locales,
'menu_html': get_menu_html(None, information_id, request.LANGUAGE_CODE) 'breadcrumb': get_breadcrumb(information_locale.information, request.LANGUAGE_CODE),
} 'menu_html': get_menu_html(None, information_id, request.LANGUAGE_CODE)
return render(request, 'information/detail.html', context) }
return render(request, 'information/detail.html', context)
except ObjectDoesNotExist:
raise Http404("No information page found with id=%s" % information_id)
def get_breadcrumb(information, language): def get_breadcrumb(information, language):
active_id= information.pk active_id= information.pk
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment