Skip to content

Commit

Permalink
Election stats download explicitly checks whether election has been p…
Browse files Browse the repository at this point in the history
…rocessed instead of throwing error.
  • Loading branch information
helgihg committed Sep 27, 2018
1 parent 88db24b commit 9d48fa3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions election/dataviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,13 @@ def election_showclosed(request):


def election_stats_download(request, polity_id=None, election_id=None, filename=None):
election = get_object_or_404(Election, id=election_id, polity_id=polity_id)

if not election.stats_publish_files:
raise Http404
election = get_object_or_404(
Election,
id=election_id,
polity_id=polity_id,
is_processed=True,
stats_publish_files=True
)

filetype = filename.split('.')[-1].lower()
assert(filetype in ('json', 'xlsx', 'ods', 'html'))
Expand Down

0 comments on commit 9d48fa3

Please sign in to comment.