Skip to content

Commit

Permalink
Task/wp 372 admin except extend entity name (#241)
Browse files Browse the repository at this point in the history
* task/wp-372-Admin-Except-Extend-Entity-Name

- Updated query for get_all_exceptions and get_all_extensions
- Updated view and template for extensions to pull entity name from
submitters table

* Left org name as the parameter for filter but
changed value to entity_name from submitters table

* Updated to entity organization so users will know
to use filter by organization

* Allow None to be an outcome listed in the
edit modals but only if it's a NoneType object and
not a string

---------

Co-authored-by: edmondsgarrett <[email protected]>
  • Loading branch information
sophia-massie and edmondsgarrett authored Nov 8, 2023
1 parent 2cc4018 commit 1bfb7a8
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
.modal-cell {
padding-left: 0px;
}
/* SEE: https://css-tricks.com/responsive-data-tables/ */
@media (max-width: 767px) {

/* To label the cells */
/* RFE: Add `data-label` to each cell so we can use `attr(data-label)` */
.exception-table td:nth-of-type(1):before { content: "Created"; }
.exception-table td:nth-of-type(2):before { content: "Organization"; }
.exception-table td:nth-of-type(2):before { content: "Entity Organization"; }
.exception-table td:nth-of-type(3):before { content: "Requestor Name"; }
.exception-table td:nth-of-type(4):before { content: "Exception Type"; }
.exception-table td:nth-of-type(5):before { content: "Outcome"; }
.exception-table td:nth-of-type(6):before { content: "Status"; }
.exception-table td:nth-of-type(7):before { content: "Actions"; }
.exception-table td:nth-of-type(7):before {content:"Actions";}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Edit Exception ID: {{r.exception_id}} for {{r.org_name}}</h4>
<h4 class="modal-title">Edit Exception ID {{r.exception_id}} for {{r.entity_name}}</h4>
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">&#xe912;</span>
</button>
Expand Down Expand Up @@ -94,8 +94,8 @@ <h4 class="modal-header">Current Exception Information</h4>
<dl class="c-data-list--is-vert c-data-list--is-wide">
<dt class="c-data-list__key">Created</dt>
<dd class="c-data-list__value">{{r.created_at}}</dd>
<dt class="c-data-list__key">Organization</dt>
<dd class="c-data-list__value">{{r.org_name}}</dd>
<dt class="c-data-list__key">Entity Organization</dt>
<dd class="c-data-list__value">{{r.entity_name}}</dd>
<dt class="c-data-list__key">Requestor</dt>
<dd class="c-data-list__value">{{r.requestor_name}}</dd>
<dt class="c-data-list__key">Requestor Email</dt>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ <h1>View Exception Requests</h1>
<tr>
<!-- So when page is shrunk, rows match with the former columns -->
<td class="created">{{r.created_at}}</td>
<td class="org_name">{{r.org_name}}</td>
<td class="entity_name">{{r.entity_name}}</td>
<td class="requestor_name">{{r.requestor_name}}</td>
<td class="exception_type">{{r.request_type}}</td>
<td class="outcome">{{r.outcome}}</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ <h4>Details</h4>
<dl class="c-data-list--is-vert c-data-list--is-wide">
<dt class="c-data-list__key">Created</dt>
<dd class="c-data-list__value">{{r.created_at}}</dd>
<dt class="c-data-list__key">Organization</dt>
<dd class="c-data-list__value">{{r.org_name}}</dd>
<dt class="c-data-list__key">Entity Organization</dt>
<dd class="c-data-list__value">{{r.entity_name}}</dd>
<dt class="c-data-list__key">Requestor</dt>
<dd class="c-data-list__value">{{r.requestor_name}}</dd>
<dt class="c-data-list__key">Requestor Email</dt>
Expand Down
17 changes: 8 additions & 9 deletions apcd-cms/src/apps/admin_exception/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ def _set_exceptions(exception):
'approved_expiration_date': exception[18],
'status': title_case(exception[19])if exception[3] else None,
'notes': exception[20],
'org_name': exception[21],
'entity_name': exception[21],
'data_file_name': exception[22]
}

context['header'] = ['Created', 'Organization', 'Requestor Name', 'Exception Type', 'Outcome', 'Status', 'Actions']
context['header'] = ['Created', 'Entity Organization', 'Requestor Name', 'Exception Type', 'Outcome', 'Status', 'Actions']
context['status_options'] = ['All']
context['org_options'] = ['All']
context['outcome_options'] = []
Expand All @@ -109,11 +109,11 @@ def getDate(row):
exception_table_entries.append(_set_exceptions(exception))
# to be able to access any exception in a template using exceptions var in the future
context['exceptions'].append(_set_exceptions(exception))
org_name = title_case(exception[21])
entity_name = title_case(exception[21])
status = title_case(exception[19])
outcome = title_case(exception[5])
if org_name not in context['org_options']:
context['org_options'].append(org_name)
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))
if status not in context['status_options']:
Expand All @@ -122,9 +122,8 @@ def getDate(row):
# 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))
if outcome not in context['outcome_options']:
if outcome != None:
context['outcome_options'].append(outcome)
context['outcome_options'] = sorted(context['outcome_options'])
context['outcome_options'].append(outcome)
context['outcome_options'] = sorted(context['outcome_options'], key=lambda x: (x is not None, x))

context['selected_status'] = None
if status_filter is not None and status_filter != 'All':
Expand All @@ -136,7 +135,7 @@ def getDate(row):
if org_filter is not None 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, 'org_name')
exception_table_entries = table_filter(org_filter.replace("(", "").replace(")",""), exception_table_entries, 'entity_name')

context['query_str'] = queryStr
context.update(paginator(self.request, exception_table_entries))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
.modal-cell {
padding-left: 0px;
}
/* SEE: https://css-tricks.com/responsive-data-tables/ */
@media (max-width: 767px) {
/* To label the cells */
/* RFE: Add `data-label` to each cell so we can use `attr(data-label)` */
.extension-table td:nth-of-type(1):before { content: "Created"; }
.extension-table td:nth-of-type(2):before { content: "Organization"; }
.extension-table td:nth-of-type(2):before { content: "Entity Organization"; }
.extension-table td:nth-of-type(3):before { content: "Requestor Name"; }
.extension-table td:nth-of-type(4):before { content: "Extension Type"; }
.extension-table td:nth-of-type(5):before { content: "Outcome"; }
.extension-table td:nth-of-type(6):before { content: "Status"; }
.extension-table td:nth-of-type(7):before { content: "Approved Expiration"; }
.extension-table td:nth-of-type(8):before { content: "Actions"; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Edit Extension ID: {{r.extension_id}} for {{r.org_name}}</h4>
<h4 class="modal-title">Edit Extension ID {{r.extension_id}} for {{r.entity_name}}</h4>
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">&#xe912;</span>
</button>
Expand Down Expand Up @@ -62,7 +62,9 @@ <h4 class="modal-header">Edit Selected Extension</h4>
</label>
<select name='outcome' class="choicefield" id='outcome'>
{% for option in outcome_options %}
{% if option != 'None'%}
<option class="dropdown-text" {% if option == r.outcome %}selected{% endif %}>{{ option }}</option>
{% endif %}
{% endfor %}
</select>
</div>
Expand Down Expand Up @@ -92,8 +94,8 @@ <h4 class="modal-header">Current Extension Information</h4>
<dl class="c-data-list--is-vert c-data-list--is-wide">
<dt class="c-data-list__key">Created</dt>
<dd class="c-data-list__value">{{r.created_at}}</dd>
<dt class="c-data-list__key">Organization</dt>
<dd class="c-data-list__value">{{r.org_name}}</dd>
<dt class="c-data-list__key">Entity Organization</dt>
<dd class="c-data-list__value">{{r.entity_name}}</dd>
<dt class="c-data-list__key">Requestor</dt>
<dd class="c-data-list__value">{{r.requestor_name}}</dd>
<dt class="c-data-list__key">Requestor Email</dt>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ <h1>View Extension Requests</h1>
{% for r in page %}
<tr>
<td class="created">{{r.created_at}}</td>
<td class="org_name">{{r.org_name}} - {{r.submitter_id}}</td>
<td class="entity_name">{{r.entity_name}}</td>
<td class="requestor_name">{{r.requestor_name}}</td>
<td class="extension_type">{{r.extension_type}}</td>
<td class="outcome">{{r.outcome}}</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Extension Details ID: {{r.extension_id}} for {{r.org_name}}</h4>
<h4 class="modal-title">Extension Details ID {{r.extension_id}} for {{r.entity_name}}</h4>
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">&#xe912;</span>
</button>
Expand All @@ -20,8 +20,8 @@ <h4>Details</h4>
<dl class="c-data-list--is-vert c-data-list--is-wide">
<dt class="c-data-list__key">Created</dt>
<dd class="c-data-list__value">{{r.created_at}}</dd>
<dt class="c-data-list__key">Organization</dt>
<dd class="c-data-list__value">{{r.org_name}}</dd>
<dt class="c-data-list__key">Entity Organization</dt>
<dd class="c-data-list__value">{{r.entity_name}}</dd>
<dt class="c-data-list__key">Requestor</dt>
<dd class="c-data-list__value">{{r.requestor_name}}</dd>
<dt class="c-data-list__key">Requestor Email</dt>
Expand Down
14 changes: 7 additions & 7 deletions apcd-cms/src/apps/admin_extension/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ def _set_extensions(extension):
'requestor_email': extension[15],
'explanation_justification': extension[16],
'notes': extension[17],
'org_name': extension[18]
'entity_name': extension[18]
}
context['header'] = ['Created', 'Organization', 'Requestor Name', 'Extension Type', 'Outcome', 'Status', 'Approved Expiration', 'Actions']
context['header'] = ['Created', 'Entity Organization', 'Requestor Name', 'Extension Type', 'Outcome', 'Status', 'Approved Expiration', 'Actions']
context['status_options'] = ['All']
context['org_options'] = ['All']
context['outcome_options'] = []
Expand All @@ -103,18 +103,18 @@ def getDate(row):
extension_table_entries.append(_set_extensions(extension))
# to be able to access any extension in a template
context['extensions'].append(_set_extensions(extension))
org_name = title_case(extension[18])
entity_name = title_case(extension[18])
status = title_case(extension[7])
outcome = title_case(extension[8])
if org_name not in context['org_options']:
context['org_options'].append(org_name)
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))
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))
if outcome not in context['outcome_options']:
context['outcome_options'].append(outcome)
context['outcome_options'] = context['outcome_options']
context['outcome_options'] = sorted(context['outcome_options'], key=lambda x: (x is not None, x))

queryStr = ''
status_filter = self.request.GET.get('status')
Expand All @@ -130,7 +130,7 @@ def getDate(row):
if org_filter is not None and org_filter != 'All':
context['selected_org'] = org_filter
queryStr += f'&org={org_filter}'
extension_table_entries = table_filter(org_filter.replace("(", "").replace(")",""), extension_table_entries, 'org_name')
extension_table_entries = table_filter(org_filter.replace("(", "").replace(")",""), extension_table_entries, 'entity_name')

context['query_str'] = queryStr
context.update(paginator(self.request, extension_table_entries))
Expand Down
4 changes: 2 additions & 2 deletions apcd-cms/src/apps/utils/apcd_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,7 @@ def get_all_extensions():
extensions.requestor_email,
extensions.explanation_justification,
extensions.notes,
submitters.org_name
submitters.entity_name
FROM extensions
JOIN submitters
ON extensions.submitter_id = submitters.submitter_id
Expand Down Expand Up @@ -1423,7 +1423,7 @@ def get_all_exceptions():
exceptions.approved_expiration_date,
exceptions.status,
exceptions.notes,
submitters.org_name,
submitters.entity_name,
standard_codes.item_value
FROM exceptions
JOIN submitters
Expand Down

0 comments on commit 1bfb7a8

Please sign in to comment.