From 02d179e411d46712663b037aa358c8885ba965fb Mon Sep 17 00:00:00 2001 From: sophia-massie <96220951+sophia-massie@users.noreply.github.com> Date: Thu, 19 Sep 2024 12:34:44 -0500 Subject: [PATCH] Hotfix: null handling in the status filter options for all admin tables (#309) * - Adds readonly required threshold field to exception threshold form - Adds required threshold form field to write to the exception database table - Updates docker-compose to docker compose in Makefile for local development * - Adds none checks for filter options --- apcd_cms/src/apps/admin_exception/views.py | 6 +++--- apcd_cms/src/apps/admin_extension/views.py | 8 ++++---- .../exception_threshold_form.html | 2 +- apcd_cms/src/apps/utils/apcd_database.py | 5 +++-- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/apcd_cms/src/apps/admin_exception/views.py b/apcd_cms/src/apps/admin_exception/views.py index 34fbfdef..fa14f5e3 100644 --- a/apcd_cms/src/apps/admin_exception/views.py +++ b/apcd_cms/src/apps/admin_exception/views.py @@ -115,17 +115,17 @@ def getDate(row): if entity_name not in context['org_options']: context['org_options'].append(entity_name) # to make sure All is first in the dropdown filter options after sorting alphabetically - context['org_options'] = sorted(context['org_options'], key=lambda x: (x != 'All', x)) + context['org_options'] = sorted(context['org_options'],key=lambda x: (x is not None, x != 'All', x if x is not None else '')) # Remove empty strings context['org_options'] = [option for option in context['org_options'] if option != ''] if status not in context['status_options']: if status != None: context['status_options'].append(status) # to make sure All is first in the dropdown filter options after sorting alphabetically - context['status_options'] = sorted(context['status_options'], key=lambda x: (x != 'All', x)) + context['status_options'] = sorted(context['status_options'], key=lambda x: (x is not None, x != 'All', x if x is not None else '')) if outcome not in context['outcome_options']: context['outcome_options'].append(outcome) - context['outcome_options'] = sorted(context['outcome_options'], key=lambda x: (x is not None, x)) + context['outcome_options'] = sorted(context['outcome_options'],key=lambda x: (x is not None, x != 'All', x if x is not None else '')) context['selected_status'] = None if status_filter is not None and status_filter != 'All': diff --git a/apcd_cms/src/apps/admin_extension/views.py b/apcd_cms/src/apps/admin_extension/views.py index 0c5774e0..83344653 100644 --- a/apcd_cms/src/apps/admin_extension/views.py +++ b/apcd_cms/src/apps/admin_extension/views.py @@ -108,15 +108,15 @@ def getDate(row): outcome = title_case(extension[8]) if entity_name not in context['org_options']: context['org_options'].append(entity_name) - context['org_options'] = sorted(context['org_options'], key=lambda x: (x != 'All', x)) + context['org_options'] = sorted(context['org_options'], key=lambda x: (x is not None, x != 'All', x if x is not None else '')) # Remove empty strings context['org_options'] = [option for option in context['org_options'] if option != ''] if status not in context['status_options']: context['status_options'].append(status) - context['status_options'] = sorted(context['status_options'], key=lambda x: (x != 'All', x)) + context['status_options'] = sorted(context['status_options'], key=lambda x: (x is not None, x != 'All', x if x is not None else '')) if outcome not in context['outcome_options']: context['outcome_options'].append(outcome) - context['outcome_options'] = sorted(context['outcome_options'], key=lambda x: (x is not None, x)) + context['outcome_options'] = sorted(context['outcome_options'],key=lambda x: (x is not None, x != 'All', x if x is not None else '')) queryStr = '' status_filter = self.request.GET.get('status') @@ -145,4 +145,4 @@ def _get_applicable_data_period(value): try: return datetime.strptime(str(value), '%Y%m').strftime('%b. %Y') except: - return None \ No newline at end of file + return None diff --git a/apcd_cms/src/apps/exception/templates/exception_submission_form/exception_threshold_form.html b/apcd_cms/src/apps/exception/templates/exception_submission_form/exception_threshold_form.html index 0cd4cdda..d26c7193 100644 --- a/apcd_cms/src/apps/exception/templates/exception_submission_form/exception_threshold_form.html +++ b/apcd_cms/src/apps/exception/templates/exception_submission_form/exception_threshold_form.html @@ -478,4 +478,4 @@

Acknowledgment of Terms

-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/apcd_cms/src/apps/utils/apcd_database.py b/apcd_cms/src/apps/utils/apcd_database.py index bc34b6f6..15b0e4db 100644 --- a/apcd_cms/src/apps/utils/apcd_database.py +++ b/apcd_cms/src/apps/utils/apcd_database.py @@ -778,8 +778,9 @@ def create_threshold_exception(form, iteration, sub_data): field_number, requested_threshold, explanation_justification, - status - ) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s) + status, + required_threshold + ) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s) """ values = ( _clean_value(form['business-name_{}'.format(iteration)]),