Skip to content

Commit

Permalink
Avoid error when no submission values exist. (#3786)
Browse files Browse the repository at this point in the history
Fixes #3785

Add a check to see if there are any submission values.
  • Loading branch information
frjo authored Feb 29, 2024
1 parent b1d9261 commit f51c8ef
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions hypha/apply/funds/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1724,10 +1724,16 @@ def get_queryset(self):

def get_context_data(self, **kwargs):
search_term = self.request.GET.get("query")
submission_values = self.object_list.value()
count_values = submission_values.get("value__count")
total_value = intcomma(submission_values.get("value__sum"))
average_value = intcomma(round(submission_values.get("value__avg")))

if self.object_list:
submission_values = self.object_list.value()
count_values = submission_values.get("value__count")
total_value = intcomma(submission_values.get("value__sum"))
average_value = intcomma(round(submission_values.get("value__avg")))
else:
count_values = 0
total_value = 0
average_value = 0

return super().get_context_data(
search_term=search_term,
Expand Down

0 comments on commit f51c8ef

Please sign in to comment.