From eb46fce0741088a341c0417f51a2849c3b8c92f8 Mon Sep 17 00:00:00 2001 From: sophia-massie <96220951+sophia-massie@users.noreply.github.com> Date: Fri, 20 Sep 2024 11:14:44 -0500 Subject: [PATCH] hotfix/address-null-in-filters (#315) * hotfix/address-null-in-admin-filters and View Submissions for users table * - Fixes bug to show None in dropdown menu when selected * - Removes required threshold from other exception query --- .../templates/list_admin_exception.html | 2 +- apcd_cms/src/apps/admin_exception/views.py | 24 +++++++++---------- .../templates/list_admin_extension.html | 4 ++-- apcd_cms/src/apps/admin_extension/views.py | 18 +++++++------- .../templates/list_registrations.html | 2 +- apcd_cms/src/apps/admin_regis_table/views.py | 10 ++++---- .../templates/list_admin_submissions.html | 4 ++-- apcd_cms/src/apps/admin_submissions/views.py | 19 ++++++++++----- .../templates/list_submissions.html | 4 ++-- apcd_cms/src/apps/submissions/views.py | 10 ++++---- apcd_cms/src/apps/utils/apcd_database.py | 3 +-- .../apps/view_users/templates/view_users.html | 5 ++-- apcd_cms/src/apps/view_users/views.py | 9 ++++--- .../apcd_cms/static/apcd_cms/css/table.css | 1 - 14 files changed, 59 insertions(+), 56 deletions(-) diff --git a/apcd_cms/src/apps/admin_exception/templates/list_admin_exception.html b/apcd_cms/src/apps/admin_exception/templates/list_admin_exception.html index a14fd097..f6c9dfa7 100644 --- a/apcd_cms/src/apps/admin_exception/templates/list_admin_exception.html +++ b/apcd_cms/src/apps/admin_exception/templates/list_admin_exception.html @@ -26,7 +26,7 @@

View Exception Requests

{% endfor %} - {% if selected_status or selected_org %} + {% if selected_status != 'All' or selected_org != 'All' %} {% endif %} diff --git a/apcd_cms/src/apps/admin_exception/views.py b/apcd_cms/src/apps/admin_exception/views.py index fa14f5e3..c4d5b1ac 100644 --- a/apcd_cms/src/apps/admin_exception/views.py +++ b/apcd_cms/src/apps/admin_exception/views.py @@ -69,7 +69,7 @@ def _set_exceptions(exception): 'requestor_name': exception[2], 'request_type': title_case(exception[3]) if exception[3] else None, # to make sure if val doesn't exist, utils don't break page 'explanation_justification': exception[4], - 'outcome': title_case(exception[5]) if exception[3] else None, + 'outcome': title_case(exception[5]) if exception[5] else None, 'created_at': exception[6], 'updated_at': exception[7], 'submitter_code': exception[8], @@ -83,7 +83,7 @@ def _set_exceptions(exception): 'requested_expiration_date': exception[16], 'approved_threshold': exception[17], 'approved_expiration_date': exception[18], - 'status': title_case(exception[19])if exception[3] else None, + 'status': title_case(exception[19])if exception[19] else 'None', 'notes': exception[20], 'entity_name': exception[21], 'data_file_name': exception[22] @@ -110,31 +110,29 @@ def getDate(row): # to be able to access any exception in a template using exceptions var in the future context['exceptions'].append(_set_exceptions(exception)) entity_name = title_case(exception[21]) - status = title_case(exception[19]) + status = title_case(exception[19]) if exception[19] else 'None' outcome = title_case(exception[5]) 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 is not None, x != 'All', x if x is not None else '')) + context['org_options'] = sorted(context['org_options'],key=lambda x: (x != 'All', x is None, 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 is not None, x != 'All', x if x is not None else '')) + context['status_options'].append(status) + context['status_options'] = sorted(context['status_options'], key=lambda x: (x != 'All', x is None, 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 != 'All', x if x is not None else '')) + context['outcome_options'] = sorted(context['outcome_options'], key=lambda x: (x != 'All', x is None, x if x is not None else '')) - context['selected_status'] = None - if status_filter is not None and status_filter != 'All': + context['selected_status'] = 'All' + if status_filter and status_filter != 'All': context['selected_status'] = status_filter queryStr += f'&status={status_filter}' exception_table_entries = table_filter(status_filter, exception_table_entries, 'status') - context['selected_org'] = None - if org_filter is not None and org_filter != 'All': + context['selected_org'] = 'All' + if org_filter and org_filter != 'All': context['selected_org'] = org_filter queryStr += f'&org={org_filter}' exception_table_entries = table_filter(org_filter.replace("(", "").replace(")",""), exception_table_entries, 'entity_name') diff --git a/apcd_cms/src/apps/admin_extension/templates/list_admin_extension.html b/apcd_cms/src/apps/admin_extension/templates/list_admin_extension.html index c7d3a134..6a663eaf 100644 --- a/apcd_cms/src/apps/admin_extension/templates/list_admin_extension.html +++ b/apcd_cms/src/apps/admin_extension/templates/list_admin_extension.html @@ -26,7 +26,7 @@

View Extension Requests

{% endfor %} - {% if selected_status or selected_org %} + {% if selected_status != 'All' or selected_org != 'All' %} {% endif %} @@ -121,4 +121,4 @@

View Extension Requests

actionsDropdown.selectedIndex = 0; /* resets dropdown to display 'Select Action' again */ } -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/apcd_cms/src/apps/admin_extension/views.py b/apcd_cms/src/apps/admin_extension/views.py index 83344653..77aad967 100644 --- a/apcd_cms/src/apps/admin_extension/views.py +++ b/apcd_cms/src/apps/admin_extension/views.py @@ -67,14 +67,14 @@ def _set_extensions(extension): # to separate small carrier into two words 'extension_type': title_case(extension[5].replace('_', ' ')) if extension[5] else None, 'applicable_data_period': _get_applicable_data_period(extension[6]), - 'status': title_case(extension[7]), - 'outcome': title_case(extension[8]), + 'status': title_case(extension[7]) if extension[7] else 'None', + 'outcome': title_case(extension[8]) if extension[8] else None, 'created_at': extension[9], 'updated_at': extension[10], 'submitter_code': extension[11], 'payor_code': extension[12], 'user_id': extension[13], - 'requestor_name': title_case(extension[14]), + 'requestor_name': title_case(extension[14]) if extension[14] else None, 'requestor_email': extension[15], 'explanation_justification': extension[16], 'notes': extension[17], @@ -104,31 +104,31 @@ def getDate(row): # to be able to access any extension in a template context['extensions'].append(_set_extensions(extension)) entity_name = title_case(extension[18]) - status = title_case(extension[7]) + status = title_case(extension[7]) if extension[7] else 'None' 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 is not None, x != 'All', x if x is not None else '')) + context['org_options'] = sorted(context['org_options'], key=lambda x: (x != 'All', x is None, 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 is not None, x != 'All', x if x is not None else '')) + context['status_options'] = sorted(context['status_options'], key=lambda x: (x != 'All', x is None, 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 != 'All', x if x is not None else '')) + context['outcome_options'] = sorted(context['outcome_options'], key=lambda x: (x != 'All', x is None, x if x is not None else '')) queryStr = '' status_filter = self.request.GET.get('status') org_filter = self.request.GET.get('org') - context['selected_status'] = None + context['selected_status'] = 'All' if status_filter is not None and status_filter != 'All': context['selected_status'] = status_filter queryStr += f'&status={status_filter}' extension_table_entries = table_filter(status_filter, extension_table_entries, 'status') - context['selected_org'] = None + context['selected_org'] = 'All' if org_filter is not None and org_filter != 'All': context['selected_org'] = org_filter queryStr += f'&org={org_filter}' diff --git a/apcd_cms/src/apps/admin_regis_table/templates/list_registrations.html b/apcd_cms/src/apps/admin_regis_table/templates/list_registrations.html index 25f112fc..7eb08dca 100644 --- a/apcd_cms/src/apps/admin_regis_table/templates/list_registrations.html +++ b/apcd_cms/src/apps/admin_regis_table/templates/list_registrations.html @@ -28,7 +28,7 @@

List Registrations

{% endfor %} - {% if selected_status or selected_org %} + {% if selected_status != 'All' or selected_org != 'All' %} {% endif %} diff --git a/apcd_cms/src/apps/admin_regis_table/views.py b/apcd_cms/src/apps/admin_regis_table/views.py index cfc5eaa4..5f90323d 100644 --- a/apcd_cms/src/apps/admin_regis_table/views.py +++ b/apcd_cms/src/apps/admin_regis_table/views.py @@ -73,6 +73,7 @@ def get_context_data(self, registrations_content, registrations_entities, regist context['header'] = ['Business Name', 'Year', 'Type', 'Location', 'Registration Status', 'Actions'] context['status_options'] = ['All', 'Received', 'Processing', 'Complete', 'Withdrawn'] + context['status_options'] = sorted(context['status_options'], key=lambda x: (x != 'All', x is None, x if x is not None else '')) context['org_options'] = ['All'] try: @@ -94,19 +95,20 @@ def getDate(row): org_name = registration[5] if org_name not in context['org_options']: context['org_options'].append(org_name) + context['org_options'] = sorted(context['org_options'],key=lambda x: (x != 'All', x is None, x if x is not None else '')) queryStr = '' status_filter = self.request.GET.get('status') org_filter = self.request.GET.get('org') - context['selected_status'] = None - if status_filter is not None and status_filter != 'All': + context['selected_status'] = 'All' + if status_filter and status_filter != 'All': context['selected_status'] = status_filter queryStr += f'&status={status_filter}' registration_table_entries = table_filter(status_filter, registration_table_entries, 'reg_status') - context['selected_org'] = None - if org_filter is not None and org_filter != 'All': + context['selected_org'] = 'All' + if org_filter and org_filter != 'All': context['selected_org'] = org_filter queryStr += f'&org={org_filter}' registration_table_entries = table_filter(org_filter.replace("(", "").replace(")",""), registration_table_entries, 'biz_name') diff --git a/apcd_cms/src/apps/admin_submissions/templates/list_admin_submissions.html b/apcd_cms/src/apps/admin_submissions/templates/list_admin_submissions.html index 8ca1ae0e..ccd1eb6c 100644 --- a/apcd_cms/src/apps/admin_submissions/templates/list_admin_submissions.html +++ b/apcd_cms/src/apps/admin_submissions/templates/list_admin_submissions.html @@ -21,7 +21,7 @@

View Submissions

Filter by Status: @@ -32,7 +32,7 @@

View Submissions

{% endfor %} - {% if selected_status or selected_sort %} + {% if selected_status != 'All' or selected_sort != None %} {% endif %}
diff --git a/apcd_cms/src/apps/admin_submissions/views.py b/apcd_cms/src/apps/admin_submissions/views.py index 7f5f2af9..abf61087 100644 --- a/apcd_cms/src/apps/admin_submissions/views.py +++ b/apcd_cms/src/apps/admin_submissions/views.py @@ -24,6 +24,14 @@ def get_context_data(self, *args, **kwargs): submission_content = get_all_submissions_and_logs() + context['status_options'] = ['All'] + for i in submission_content: + status = title_case(i['status']) if i['status'] else 'None' + 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 is None, x if x is not None else '')) + + queryStr = '' dateSort = self.request.GET.get('sort') status_filter = self.request.GET.get('status') @@ -42,7 +50,7 @@ def getDate(row): except: page_num = 1 - context['selected_status'] = None + context['selected_status'] = 'All' if status_filter is not None and status_filter != 'All': context['selected_status'] = status_filter queryStr += f'&status={status_filter}' @@ -54,18 +62,17 @@ def getDate(row): # modifies the object fields for display, only modifies a subset of entries that will be displayed # on the current page using offset and limit for s in submission_content[offset:offset + limit]: - s['status'] = title_case(s['status']) - s['entity_name'] = title_case(s['entity_name']) - s['outcome'] = title_case(s['outcome']) + s['status'] = title_case(s['status']) if s['status'] else None + s['entity_name'] = title_case(s['entity_name']) if s['entity_name'] else None + s['outcome'] = title_case(s['outcome']) if s['outcome'] else None s['received_timestamp'] = parser.parse(s['received_timestamp']) if s['received_timestamp'] else None s['updated_at'] = parser.parse(s['updated_at']) if s['updated_at'] else None s['view_modal_content'] = [{ **t, - 'outcome': title_case(t['outcome']) + 'outcome': title_case(t['outcome']) if t['outcome'] else None } for t in (s['view_modal_content'] or [])] context['header'] = ['Received', 'Entity Organization', 'File Name', ' ', 'Outcome', 'Status', 'Last Updated', 'Actions'] - context['filter_options'] = ['All', 'In Process', 'Complete'] context['sort_options'] = {'newDate': 'Newest Received', 'oldDate': 'Oldest Received'} context['query_str'] = queryStr diff --git a/apcd_cms/src/apps/submissions/templates/list_submissions.html b/apcd_cms/src/apps/submissions/templates/list_submissions.html index 09a9dcf8..25106db0 100644 --- a/apcd_cms/src/apps/submissions/templates/list_submissions.html +++ b/apcd_cms/src/apps/submissions/templates/list_submissions.html @@ -20,7 +20,7 @@

View Submissions

Filter by Status: @@ -31,7 +31,7 @@

View Submissions

{% endfor %} - {% if selected_status or selected_sort %} + {% if selected_status != 'All' or selected_sort != None %} {% endif %}
diff --git a/apcd_cms/src/apps/submissions/views.py b/apcd_cms/src/apps/submissions/views.py index 92b2f0b5..e6101333 100644 --- a/apcd_cms/src/apps/submissions/views.py +++ b/apcd_cms/src/apps/submissions/views.py @@ -46,7 +46,7 @@ def getDate(row): except: page_num = 1 - context['selected_status'] = None + context['selected_status'] = 'All' if status_filter is not None and status_filter != 'All': context['selected_status'] = status_filter queryStr += f'&status={status_filter}' @@ -58,18 +58,18 @@ def getDate(row): # modifies the object fields for display, only modifies a subset of entries that will be displayed # on the current page using offset and limit for s in submission_content[offset:offset + limit]: - s['status'] = title_case(s['status']) - s['outcome'] = title_case(s['outcome']) + s['status'] = title_case(s['status']) if s['status'] else None + s['outcome'] = title_case(s['outcome']) if s['outcome'] else None s['received_timestamp'] = parser.parse(s['received_timestamp']) if s['received_timestamp'] else None s['updated_at'] = parser.parse(s['updated_at']) if s['updated_at'] else None s['view_modal_content'] = [{ **t, - 'outcome': title_case(t['outcome']) + 'outcome': title_case(t['outcome']) if t['outcome'] else None } for t in (s['view_modal_content'] or [])] context['header'] = ['Received', 'File Name', ' ', 'Outcome', 'Status', 'Last Updated', 'Actions'] - context['filter_options'] = ['All', 'In Process', 'Complete'] + context['status_options'] = ['All', 'Complete', 'In Process'] context['sort_options'] = {'newDate': 'Newest Received', 'oldDate': 'Oldest Received'} context['query_str'] = queryStr diff --git a/apcd_cms/src/apps/utils/apcd_database.py b/apcd_cms/src/apps/utils/apcd_database.py index 15b0e4db..d47d7c16 100644 --- a/apcd_cms/src/apps/utils/apcd_database.py +++ b/apcd_cms/src/apps/utils/apcd_database.py @@ -722,8 +722,7 @@ def create_other_exception(form, sub_data): requested_expiration_date, explanation_justification, status, - required_threshold - ) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s) + ) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s) """ values = ( form["business-name"], diff --git a/apcd_cms/src/apps/view_users/templates/view_users.html b/apcd_cms/src/apps/view_users/templates/view_users.html index d5d7633d..b94c1e73 100644 --- a/apcd_cms/src/apps/view_users/templates/view_users.html +++ b/apcd_cms/src/apps/view_users/templates/view_users.html @@ -28,8 +28,7 @@

View Users

{% endfor %} - - {% if selected_status or selected_org %} + {% if selected_status != 'All' or selected_org != 'All' %} {% endif %} @@ -129,4 +128,4 @@

View Users

-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/apcd_cms/src/apps/view_users/views.py b/apcd_cms/src/apps/view_users/views.py index a2a43009..1a65dcec 100644 --- a/apcd_cms/src/apps/view_users/views.py +++ b/apcd_cms/src/apps/view_users/views.py @@ -64,7 +64,7 @@ def _set_user(usr): 'user_id': usr[1], 'user_email': usr[2], 'user_name': usr[3], - 'entity_name': usr[4] if usr[4] else "Not Applicable", + 'entity_name': usr[4] if usr[4] else 'None', 'created_at': usr[5], 'updated_at': usr[6], 'notes': usr[7], @@ -99,15 +99,14 @@ def _set_user(usr): org_name = user[4] if org_name not in context['filter_options']: # prevent duplicates context['filter_options'].append(user[4]) - if org_name is None and 'Not Applicable' not in context['filter_options']: - context['filter_options'].append('Not Applicable') + context['filter_options'] = sorted(context['filter_options'],key=lambda x: (x != 'All', x is None, x if x is not None else '')) queryStr = '' status_filter = self.request.GET.get('status') org_filter = self.request.GET.get('org') role_filter = self.request.GET.get('role_name') - context['selected_status'] = None + context['selected_status'] = 'All' if status_filter is not None and status_filter !='All': context['selected_status'] = status_filter queryStr += f'&status={status_filter}' @@ -117,7 +116,7 @@ def _set_user(usr): context['selected_role'] = role_filter table_entries = table_filter(role_filter, table_entries, 'role_name', False) - context['selected_org'] = None + context['selected_org'] = 'All' if org_filter is not None and org_filter != 'All': context['selected_org'] = org_filter queryStr += f'&org={org_filter}' diff --git a/apcd_cms/src/taccsite_custom/apcd_cms/static/apcd_cms/css/table.css b/apcd_cms/src/taccsite_custom/apcd_cms/static/apcd_cms/css/table.css index 81958bbb..47d34670 100644 --- a/apcd_cms/src/taccsite_custom/apcd_cms/static/apcd_cms/css/table.css +++ b/apcd_cms/src/taccsite_custom/apcd_cms/static/apcd_cms/css/table.css @@ -124,7 +124,6 @@ table { width: 150px; appearance: none; -webkit-appearance: none; - box-sizing: border-box; background-image: url("data:image/svg+xml,%3Csvg id='tacc-arrows' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 130.34 292.4'%3E%3Cdefs%3E%3Cstyle%3E.arrow%7Bfill:%23484848;%7D%3C/style%3E%3C/defs%3E%3Cg id='tacc-arrows——root'%3E%3Cpath id='Path_3088' data-name='Path 3088' class='arrow' d='M82.24,96.17,148.09,0l64.45,96.17Z' transform='translate(-82.2)'/%3E%3Cpath id='Path_3089' data-name='Path 3089' class='arrow' d='M212.5,196.23,146.65,292.4,82.2,196.23Z' transform='translate(-82.2)'/%3E%3C/g%3E%3C/svg%3E"); background-repeat: no-repeat;