HyphaApp / hypha

Submission management software for open calls
https://www.hypha.app
BSD 3-Clause "New" or "Revised" License
67 stars 39 forks source link

Results page is broken when all submissions lack "Requested amount" field #3902

Closed bachlava closed 3 months ago

bachlava commented 3 months ago

Describe the bug

Related to #3785, when all existing submissions do not have a requested amount, Results page breaks with following error:

Traceback (most recent call last):
  File "C:\grants-management-app\venv\Lib\site-packages\django\core\handlers\exception.py", line 55, in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "C:\grants-management-app\venv\Lib\site-packages\django\core\handlers\base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\grants-management-app\venv\Lib\site-packages\django\views\generic\base.py", line 104, in view
    return self.dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\grants-management-app\venv\Lib\site-packages\django\utils\decorators.py", line 46, in _wrapper
    return bound_method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\grants-management-app\venv\Lib\site-packages\django\utils\decorators.py", line 134, in _wrapper_view
    response = view_func(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\grants-management-app\venv\Lib\site-packages\django\utils\decorators.py", line 46, in _wrapper
    return bound_method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\grants-management-app\venv\Lib\site-packages\django\contrib\auth\decorators.py", line 23, in _wrapper_view
    return view_func(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\grants-management-app\venv\Lib\site-packages\django\contrib\auth\decorators.py", line 23, in _wrapper_view
    return view_func(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\grants-management-app\venv\Lib\site-packages\django\views\generic\base.py", line 143, in dispatch
    return handler(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\grants-management-app\venv\Lib\site-packages\django_filters\views.py", line 85, in get
    context = self.get_context_data(

  File "C:\grants-management-app\hypha\apply\funds\views.py", line 1732, in get_context_data
    average_value = intcomma(round(submission_values.get("value__avg")))
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Exception Type: TypeError at /apply/submissions/result/
Exception Value: type NoneType doesn't define __round__ method

To Reproduce

  1. Make an application form without the "Requested amount" form field
  2. Submit one (or more) applications using this application form 2.1 If any, remove all other submissions with requested amount field
  3. Go to Results page
  4. See error

Expected behavior

See the Results page.

Priority

Affected roles

Desktop (please complete the following information):

frjo commented 3 months ago

Thanks for the report, will get this fixed.