Skip to content

Commit

Permalink
Merge pull request #208 from gm3dmo/fixacksearch
Browse files Browse the repository at this point in the history
Fixing acknowledgment search
  • Loading branch information
gm3dmo authored Aug 20, 2024
2 parents 8e06ab0 + 420324c commit ba51d2e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 21 deletions.
4 changes: 2 additions & 2 deletions cmp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,12 +397,12 @@ def search_acknowledgements(request):
query = request.GET.get('q')
page_number = request.GET.get('page')
if query:
acknowledgements = Acknowledgement.objects.filter(name__icontains=query).order_by('surname')
acknowledgements = Acknowledgement.objects.filter(surname__icontains=query).order_by('surname')
else:
acknowledgements = Acknowledgement.objects.all().order_by('surname')
paginator = Paginator(acknowledgements, settings.PAGE_SIZE)
page_obj = paginator.get_page(page_number)
return render(request, 'cmp/search-acknowledgements.html', {'page_obj': page_obj})
return render(request, 'cmp/search-acknowledgements.html', {'page_obj': page_obj, 'query': query})


def search_ranks(request):
Expand Down
47 changes: 28 additions & 19 deletions templates/cmp/search-acknowledgements.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,42 @@
{% block content %}

<div class="center-content">
<h3>Search Acknowledgements</h3>
<h3>Search Acknowlegements</h3>

<div name="search-input" class="search-input">
<form method="get">
<input type="text" name="q" placeholder="Search acknowledgements to edit">
<input type="text" name="q" value="{{ request.GET.q }}" placeholder="Search Acknowledgements">
<input type="submit" value="Search">
</form>
</div>

<div>
<table class="content-table">
<thead class="">
<tr>
<th></th>
<th>Surname</th><th>Name</th><th>Notes</th>
</tr>
</thead>
{% for acknowledgement in page_obj%}
<tr>
<td><button class="glossy-button" onclick="location.href='{% url 'edit-acknowledgements' acknowledgement.id %}'" type="button">EDIT</button></td>
<td><span class="soldier-info">{{ acknowledgement.surname}}</span></td>
<td><span class="soldier-info">{{ acknowledgement.name}}</span></td>
<td><span class="soldier-info">{{ acknowledgement.notes}}</span></td>
<div>
<table class="content-table">
<thead class="">
<tr>
<th></th>
<th>Surname</th>
<th>Name</th>
<th>Notes</th>
</tr>
{% endfor %}
</table>
</div>
</thead>

{% for acknowledgement in page_obj %}
<tr>
{% if acknowledgement.id %}
<td><button class="glossy-button" onclick="location.href='{% url 'edit-acknowledgements' acknowledgement.id %}'" type="button">EDIT</button></td>
{% else %}
<td><button class="glossy-button" disabled>EDIT</button></td>
{% endif %}
<td><span class="soldier-info">{{ acknowledgement.surname }}</span></td>
<td><span class="soldier-info">{{ acknowledgement.name }}</span></td>
<td><span class="soldier-info">{{ acknowledgement.notes }}</span></td>
</tr>
{% endfor %}

</table>

</div>

{% include 'cmp/pagination-footer.html' %}

Expand Down

0 comments on commit ba51d2e

Please sign in to comment.