From 28bdf742fec9e09348c2c99f76d07dc26cfe77bd Mon Sep 17 00:00:00 2001 From: David Morris Date: Sun, 28 Jul 2024 17:59:50 +0100 Subject: [PATCH] fixing soldier display --- cmp/urls.py | 11 ++++------- cmp/views.py | 9 ++++++++- templates/cmp/soldier.html | 5 ++--- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/cmp/urls.py b/cmp/urls.py index a22257d..7a74514 100644 --- a/cmp/urls.py +++ b/cmp/urls.py @@ -9,10 +9,8 @@ urlpatterns = [ - #path('soldier//', soldier_detail, name='soldier_detail'), - path('soldier//', views.soldier, name='soldier'), - path("", views.index, name="index"), + path('soldier//', views.soldier, name='soldier'), path("sentry-debug/", views.trigger_error ), @@ -68,15 +66,14 @@ # Soldiers - path('soldiers/', views.soldiers, name='soldiers'), + path('soldiers/', views.soldiers, name='soldiersrn'), # Soldier management - path("mgmt/soldiers", views.edit_soldiers, name="soldiers"), - path("mgmt/soldiers//", views.detail_soldiers, name="soldiers"), + path("mgmt/soldiers", views.edit_soldiers, name="soldiersa"), + path("mgmt/soldiers//", views.detail_soldiers, name="soldiersb"), path("mgmt/soldiers/edit/", views.edit_soldiers, name="edit-soldiers"), path('mgmt/soldiers/search/', views.search_soldiers, name='search-soldiers'), - #path("soldier-search/", views.soldier_search, name="soldier-search" ), #path("soldier-search/" , views.soldier_search , name="soldier-search" ), diff --git a/cmp/views.py b/cmp/views.py index 96867e3..bee74c0 100644 --- a/cmp/views.py +++ b/cmp/views.py @@ -364,6 +364,7 @@ def soldier_detail(request, soldier_id): soldier = get_object_or_404(Soldier, id=soldier_id) return render(request, 'cmp/soldier.html', {'soldier': soldier}) + def edit_soldiers(request, soldier_id): soldier = get_object_or_404(Soldier, id=soldier_id) death, created = SoldierDeath.objects.get_or_create(soldier=soldier) @@ -565,13 +566,19 @@ def soldier(request, soldier_id): m_html = m._repr_html_() cemetery_map = m_html - context = { "soldier": soldier, "cemetery_map": cemetery_map } + context = { "soldier": soldier, + "soldierdecorations": soldierdecorations, + "soldierdeath": soldierdeath, + "cemetery_map": cemetery_map + } return render(request, "cmp/soldier.html", context) def index(request): if request.method == 'POST': surname = request.POST.get('name', '') soldiers = Soldier.objects.filter(surname__icontains=surname).order_by('surname') + + # Pagination paginator = Paginator(soldiers, 10) # Show 10 soldiers per page diff --git a/templates/cmp/soldier.html b/templates/cmp/soldier.html index c7ccc0b..367a57a 100644 --- a/templates/cmp/soldier.html +++ b/templates/cmp/soldier.html @@ -9,8 +9,7 @@

Corps of Military Police

-

Soldier Record

- +

Soldier Record

@@ -37,7 +36,7 @@

Soldier Record

{% endif %} - {% if soldier.soldierdeath.exists %} + {% if soldier.soldierdeath %}

Casualty Record:

Date of Death:{{ soldier.soldierdeath.date }}
Company:{{ soldier.soldierdeath.company }}