Skip to content

Commit

Permalink
Hotfix: null handling in the status filter options for all admin tabl…
Browse files Browse the repository at this point in the history
…es (#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
  • Loading branch information
sophia-massie authored Sep 19, 2024
1 parent 280d8ab commit 02d179e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
6 changes: 3 additions & 3 deletions apcd_cms/src/apps/admin_exception/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down
8 changes: 4 additions & 4 deletions apcd_cms/src/apps/admin_extension/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -145,4 +145,4 @@ def _get_applicable_data_period(value):
try:
return datetime.strptime(str(value), '%Y%m').strftime('%b. %Y')
except:
return None
return None
Original file line number Diff line number Diff line change
Expand Up @@ -478,4 +478,4 @@ <h4>Acknowledgment of Terms</h4>
</small>
</div>
</div>
{% endblock %}
{% endblock %}
5 changes: 3 additions & 2 deletions apcd_cms/src/apps/utils/apcd_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)]),
Expand Down

0 comments on commit 02d179e

Please sign in to comment.