Added 404 page error checking and gettext readiness
svn: r13644
This commit is contained in:
parent
5b9c97c53d
commit
8df4105d3d
@ -11,15 +11,17 @@ from django.db.models import Q
|
|||||||
import web
|
import web
|
||||||
from web.grampsdb.models import *
|
from web.grampsdb.models import *
|
||||||
|
|
||||||
|
_ = lambda text: text
|
||||||
|
|
||||||
# Views: [(Nice name plural, /name/handle, Model), ]
|
# Views: [(Nice name plural, /name/handle, Model), ]
|
||||||
VIEWS = [('People', 'person', Person),
|
VIEWS = [(_('People'), 'person', Person),
|
||||||
('Families', 'family', Family),
|
(_('Families'), 'family', Family),
|
||||||
('Events', 'event', Event),
|
(_('Events'), 'event', Event),
|
||||||
('Notes', 'note', Note),
|
(_('Notes'), 'note', Note),
|
||||||
('Media', 'media', Media),
|
(_('Media'), 'media', Media),
|
||||||
('Sources', 'source', Source),
|
(_('Sources'), 'source', Source),
|
||||||
('Places', 'place', Place),
|
(_('Places'), 'place', Place),
|
||||||
('Repositories', 'repository', Repository),
|
(_('Repositories'), 'repository', Repository),
|
||||||
]
|
]
|
||||||
|
|
||||||
def context_processor(request):
|
def context_processor(request):
|
||||||
@ -48,13 +50,13 @@ def context_processor(request):
|
|||||||
def main_page(request):
|
def main_page(request):
|
||||||
context = RequestContext(request)
|
context = RequestContext(request)
|
||||||
context["view"] = 'home'
|
context["view"] = 'home'
|
||||||
context["cview"] = 'Home'
|
context["cview"] = _('Home')
|
||||||
return render_to_response("main_page.html", context)
|
return render_to_response("main_page.html", context)
|
||||||
|
|
||||||
def logout_page(request):
|
def logout_page(request):
|
||||||
context = RequestContext(request)
|
context = RequestContext(request)
|
||||||
context["view"] = 'home'
|
context["view"] = 'home'
|
||||||
context["cview"] = 'Home'
|
context["cview"] = _('Home')
|
||||||
logout(request)
|
logout(request)
|
||||||
return HttpResponseRedirect('/')
|
return HttpResponseRedirect('/')
|
||||||
|
|
||||||
@ -62,38 +64,64 @@ def user_page(request, username):
|
|||||||
try:
|
try:
|
||||||
user = User.objects.get(username=username)
|
user = User.objects.get(username=username)
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
raise Http404('Requested user not found.')
|
raise Http404(_('Requested user not found.'))
|
||||||
context = RequestContext(request)
|
context = RequestContext(request)
|
||||||
context["username"] = username
|
context["username"] = username
|
||||||
context["view"] = 'user'
|
context["view"] = 'user'
|
||||||
context["cview"] = 'User'
|
context["cview"] = _('User')
|
||||||
return render_to_response('user_page.html', context)
|
return render_to_response('user_page.html', context)
|
||||||
|
|
||||||
def view_detail(request, view, handle):
|
def view_detail(request, view, handle):
|
||||||
if view == "event":
|
if view == "event":
|
||||||
|
try:
|
||||||
obj = Event.objects.get(handle=handle)
|
obj = Event.objects.get(handle=handle)
|
||||||
|
except:
|
||||||
|
raise Http404(_("Requested %s does not exist.") % view)
|
||||||
view_template = 'view_event_detail.html'
|
view_template = 'view_event_detail.html'
|
||||||
elif view == "family":
|
elif view == "family":
|
||||||
|
try:
|
||||||
obj = Family.objects.get(handle=handle)
|
obj = Family.objects.get(handle=handle)
|
||||||
|
except:
|
||||||
|
raise Http404(_("Requested %s does not exist.") % view)
|
||||||
view_template = 'view_family_detail.html'
|
view_template = 'view_family_detail.html'
|
||||||
elif view == "media":
|
elif view == "media":
|
||||||
|
try:
|
||||||
obj = Media.objects.get(handle=handle)
|
obj = Media.objects.get(handle=handle)
|
||||||
|
except:
|
||||||
|
raise Http404(_("Requested %s does not exist.") % view)
|
||||||
view_template = 'view_media_detail.html'
|
view_template = 'view_media_detail.html'
|
||||||
elif view == "note":
|
elif view == "note":
|
||||||
|
try:
|
||||||
obj = Note.objects.get(handle=handle)
|
obj = Note.objects.get(handle=handle)
|
||||||
|
except:
|
||||||
|
raise Http404(_("Requested %s does not exist.") % view)
|
||||||
view_template = 'view_note_detail.html'
|
view_template = 'view_note_detail.html'
|
||||||
elif view == "person":
|
elif view == "person":
|
||||||
|
try:
|
||||||
obj = Person.objects.get(handle=handle)
|
obj = Person.objects.get(handle=handle)
|
||||||
|
except:
|
||||||
|
raise Http404(_("Requested %s does not exist.") % view)
|
||||||
view_template = 'view_person_detail.html'
|
view_template = 'view_person_detail.html'
|
||||||
elif view == "place":
|
elif view == "place":
|
||||||
|
try:
|
||||||
obj = Place.objects.get(handle=handle)
|
obj = Place.objects.get(handle=handle)
|
||||||
|
except:
|
||||||
|
raise Http404(_("Requested %s does not exist.") % view)
|
||||||
view_template = 'view_place_detail.html'
|
view_template = 'view_place_detail.html'
|
||||||
elif view == "repository":
|
elif view == "repository":
|
||||||
|
try:
|
||||||
obj = Repository.objects.get(handle=handle)
|
obj = Repository.objects.get(handle=handle)
|
||||||
|
except:
|
||||||
|
raise Http404(_("Requested %s does not exist.") % view)
|
||||||
view_template = 'view_repository_detail.html'
|
view_template = 'view_repository_detail.html'
|
||||||
elif view == "source":
|
elif view == "source":
|
||||||
|
try:
|
||||||
obj = Source.objects.get(handle=handle)
|
obj = Source.objects.get(handle=handle)
|
||||||
|
except:
|
||||||
|
raise Http404(_("Requested %s does not exist.") % view)
|
||||||
view_template = 'view_source_detail.html'
|
view_template = 'view_source_detail.html'
|
||||||
|
else:
|
||||||
|
raise Http404(_("Requested page type not known"))
|
||||||
cview = view.title()
|
cview = view.title()
|
||||||
context = RequestContext(request)
|
context = RequestContext(request)
|
||||||
context["cview"] = cview
|
context["cview"] = cview
|
||||||
@ -158,6 +186,8 @@ def view(request, view):
|
|||||||
elif view == "source":
|
elif view == "source":
|
||||||
object_list = Source.objects.all().order_by("gramps_id")
|
object_list = Source.objects.all().order_by("gramps_id")
|
||||||
view_template = 'view_sources.html'
|
view_template = 'view_sources.html'
|
||||||
|
else:
|
||||||
|
raise Http404("Requested page type not known")
|
||||||
|
|
||||||
paginator = Paginator(object_list, 15)
|
paginator = Paginator(object_list, 15)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user