Skip to content
Snippets Groups Projects
Unverified Commit dec530e1 authored by Martin Gummi's avatar Martin Gummi :ok_hand:
Browse files

Add person card

parent 64f6b548
No related branches found
No related tags found
1 merge request!7Add person card
{% load bootstrap4 staticfiles i18n %}
<div class="card mb-3">
<div class="row no-gutters">
<div class="col-md-4">
{% if person.jpeg_photo_url %}
<img class="person-img" src="{{ person.jpeg_photo_url }}" alt="{{ person.first_name }} {{ person.last_name }}" />
{% else %}
<img class="person-img" src="{% static 'img/fallback.png' %}" alt="{{ person.first_name }} {{ person.last_name }}" />
{% endif %}
</div>
<div class="col-md-8">
<h3 class="card-header">{{ person.first_name }} {{ person.last_name }}</h3>
<div class="card-body">
<h5 class="card-text">!Group</h5>
<p class="card-text">{{ person.date_of_birth|date }}</p>
</div>
</div>
</div>
</div>
......@@ -10,6 +10,7 @@ urlpatterns = [
path('admin/', admin.site.urls),
path('accounts/', include('django.contrib.auth.urls')),
path('persons', views.persons, name='persons'),
path('person_card/<int:id>', views.person_card, name='person_card_by_id'),
path('', views.index, name='index'),
]
......
from django.contrib.auth.decorators import login_required
from django.shortcuts import render
from django_tables2 import RequestConfig
from django.http import Http404
from .models import Person
from .tables import PersonsTable
......@@ -21,3 +22,22 @@ def persons(request):
context['persons_table'] = persons_table
return render(request, 'core/persons.html', context)
@login_required
def person_card(request, id=None):
context = {}
# Raise Http404 if now id is given
if id is None:
raise Http404
# Get person and check access
try:
person = Person.objects.get(id=id)
except ObjectDoesNotExist 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)
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