Skip to content

Commit

Permalink
Merge pull request #204 from gm3dmo/fixsoldiertable
Browse files Browse the repository at this point in the history
Fixing the table display
  • Loading branch information
gm3dmo authored Jul 28, 2024
2 parents d32ebc5 + c5039fe commit ab328a9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
19 changes: 9 additions & 10 deletions cmp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,17 +568,16 @@ def soldier(request, soldier_id):
context = { "soldier": soldier, "cemetery_map": cemetery_map }
return render(request, "cmp/soldier.html", context)


def index(request):
post = request.POST
if post:
try:
search_term = str(post.get("name"))
except ValueError:
print("woo")

surname = request.POST.get('name')
if request.method == 'POST':
surname = request.POST.get('name', '')
soldiers = Soldier.objects.filter(surname__icontains=surname).order_by('surname')
return render(request, 'cmp/soldier-results.html', {'soldiers': soldiers})

# Pagination
paginator = Paginator(soldiers, 10) # Show 10 soldiers per page
page_number = request.GET.get('page')
page_obj = paginator.get_page(page_number)

return render(request, 'cmp/soldier-results.html', {'page_obj': page_obj})
else:
return render(request, 'cmp/index.html')
2 changes: 1 addition & 1 deletion templates/cmp/soldier-results.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<br>
{% block content %}

{% if soldiers %}
{% if page_obj %}
<br>
<table class="content-table">
<thead>
Expand Down
6 changes: 3 additions & 3 deletions templates/cmp/soldier.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
{% block title %}Soldier{% endblock %}
{% block content %}

<div style="padding-bottom: 12px;">
<div class="center-content" style="padding-bottom: 12px;">
<img src="{% static 'cmp/cmp-masthead.svg' %}" style="width:350px; height:auto;" alt="The badge of the Royal Military Police">
</div>

<center><h3>Corps of Military Police</h3></center>
<h3>Corps of Military Police</h3>
</div>

<h4>Soldier Record</h4>

Expand Down

0 comments on commit ab328a9

Please sign in to comment.