Skip to content
Snippets Groups Projects
Unverified Commit 51d9be95 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Simplify person view functions.

parent cb7c9730
No related branches found
No related tags found
No related merge requests found
......@@ -11,8 +11,10 @@ urlpatterns = [
path('accounts/', include('django.contrib.auth.urls')),
path('persons', views.persons, name='persons'),
path('person', views.person, name='person'),
path('person/<int:id_>', views.person, name='person_by_id'),
path('person_card/<int:id_>', views.person_card, name='person_card_by_id'),
path('person/<int:id_>', views.person,
{'template': 'full'}, name='person_by_id'),
path('person/<int:id_>/card', views.person,
{'template': 'card'}, name='person_by_id_card'),
path('', views.index, name='index'),
]
......
......@@ -29,26 +29,7 @@ def persons(request):
@login_required
def person_card(request, id_):
context = {}
# Raise Http404 if now id is given
if id is None:
raise Http404
# Get person and check access
try:
person = Person.objects.get(pk=id_)
except Person.DoesNotExist as e:
# Turn not-found object into a 404 error
raise Http404 from e
context['person'] = person
return render(request, 'core/person_card.html', context)
def person(request, id_):
def person(request, id_, template):
context = {}
# Get person and check access
......@@ -60,4 +41,4 @@ def person(request, id_):
context['person'] = person
return render(request, 'core/person.html', context)
return render(request, 'core/person_%s.html' % template, context)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment