Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Commit

Permalink
Fix filters when using alltimes option (#54)
Browse files Browse the repository at this point in the history
* Fix filters when using alltimes option
  • Loading branch information
rubenvanerk authored Jun 20, 2020
1 parent 65e2d47 commit 1c3ab4d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ <h1 class="ui header">Changelog</h1>
</div>

<p>Note: Changes from before May 7th 2020 are not recorded on this page</p>
<div id="2020.06.20" class="ui horizontal version divider">2020.06.20</div>
<h3 class="ui header">Fixed</h3>
<ul>
<li>
Fix filters when using option to show all times
</li>
</ul>
<div id="2020.06.17" class="ui horizontal version divider">2020.06.17</div>
<h3 class="ui header">Changed</h3>
<ul>
Expand Down
12 changes: 12 additions & 0 deletions rankings/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,18 @@ def get_context_data(self, **kwargs):
order_by=F('time').asc()
),
)
if 'date_range_start' in result_filter:
results = results.filter(competition__date__gte=result_filter['date_range_start'])
if 'date_range_end' in result_filter:
results = results.filter(competition__date__lte=result_filter['date_range_end'])
if 'nationality' in result_filter and type(result_filter['nationality']) is Nationality:
results = results.filter(
athlete__nationalities__in=result_filter['nationality'].get_all_children(include_self=True))
if 'yob_start' in result_filter and result_filter['yob_start'] > 0:
results = results.filter(athlete__year_of_birth__gte=result_filter['yob_start'])

if 'yob_end' in result_filter and result_filter['yob_end'] > 0:
results = results.filter(athlete__year_of_birth__lte=result_filter['yob_end'])
results = results.select_related('athlete', 'competition')
results = results.prefetch_related('athlete__nationalities')
else:
Expand Down

0 comments on commit 1c3ab4d

Please sign in to comment.