-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Task/wp 284 submitter listing table (#232)
* Created path and submitter listing app, view, urls * task/wp-284-submitter-listin-table * -Updated get registration query to only get distinct registration records from DB -Made SubmittersTable a subclass of RegistrationTable * Reused admin view modal and removed submitter view modal Adjusted sub class parameters Added drop down to link to form * Changed wording per Jodie at UTH * Link to admin style sheet rather than copying into a new one * Changed path to correct form page * Update apcd-cms/src/apps/submitter_renewals_listing/templates/list_submitter_registrations.html Adjust path so reg_id is a query parameter and not a reg parameter Co-authored-by: edmondsgarrett <[email protected]> * Add year to query, view, and table. Recreated submission table css since it has different columns than admin registration * Added back css since table has different columns than admin registrations * Remove coming soon from options * Add year to registration context * Broken link to static dir --------- Co-authored-by: edmondsgarrett <[email protected]>
- Loading branch information
1 parent
a0b9e40
commit dc31d93
Showing
15 changed files
with
247 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class SubmitterRenewalsListingConfig(AppConfig): | ||
name = 'submitter_renewals_listing' |
15 changes: 15 additions & 0 deletions
15
apcd-cms/src/apps/submitter_renewals_listing/static/submitter_renewals_listing/css/table.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.status-filter.org-filter { | ||
width: max-content; | ||
} | ||
|
||
/* 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)` */ | ||
.submitters-table td:nth-of-type(1):before { content: "Business Name"; } | ||
.submitters-table td:nth-of-type(2):before { content: "Year"; } | ||
.submitters-table td:nth-of-type(3):before { content: "Type"; } | ||
.submitters-table td:nth-of-type(4):before { content: "Location"; } | ||
.submitters-table td:nth-of-type(5):before { content: "Registration Status"; } | ||
.submitters-table td:nth-of-type(6):before { content: "Actions"; } | ||
} |
127 changes: 127 additions & 0 deletions
127
apcd-cms/src/apps/submitter_renewals_listing/templates/list_submitter_registrations.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
{% extends "standard.html" %} | ||
{% load static %} | ||
|
||
{% block content %} | ||
|
||
<link rel="stylesheet" href="{% static 'apcd-cms/css/table.css' %}"> | ||
<link rel="stylesheet" href="{% static 'apcd-cms/css/modal.css' %}"> | ||
<link rel="stylesheet" href="{% static 'submitter_renewals_listing/css/table.css' %}"> | ||
|
||
<div class="container"> | ||
{% include "nav_cms_breadcrumbs.html" %} | ||
|
||
<h1>Registration Information</h1> | ||
<hr /> | ||
<p style="margin-bottom: 30px">Current registration information on file for your organization is listed below. On the right of the screen, select the dropdown menu under “Actions” to view or renew your organization’s registration information.</p> | ||
<hr /> | ||
<div class="filter-container"> | ||
<div class="filter-content"> | ||
<span><b>Filter by Status: </b></span> | ||
<select id="statusFilter" class="status-filter" onchange="filterTableByStatus()"> | ||
{% for option in status_options %} | ||
<option class="dropdown-text" {% if option == selected_status %}selected{% endif %}>{{ option }}</option> | ||
{% endfor %} | ||
</select> | ||
<span><b>Filter by Organization: </b></span> | ||
<select id="organizationFilter" class="status-filter org-filter" onchange="filterTableByOrganization()"> | ||
{% for option in org_options %} | ||
<option class="dropdown-text" {% if option == selected_org %}selected{% endif %}>{{ option }}</option> | ||
{% endfor %} | ||
</select> | ||
{% if selected_status or selected_org %} | ||
<button onclick="clearSelections()">Clear Options</button> | ||
{% endif %} | ||
</div> | ||
</div> | ||
<table id="submittersTable" class="submitters-table"> | ||
<thead> | ||
<tr> | ||
{% for k in header %} | ||
<th>{{k}}</th> | ||
{% endfor %} | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for r in page %} | ||
<tr> | ||
<td>{{r.biz_name}}</td> | ||
<td>{{r.year}}</td> | ||
<td>{{r.type}}</td> | ||
<td>{{r.location}}</td> | ||
<td>{{r.reg_status}}</td> | ||
<td> | ||
{% include "view_registration_modal.html" %} | ||
<select id='actionsSubmitterDropdown_{{r.reg_id}}' class='status-filter' onchange="openAction('{{r.reg_id}}')"> | ||
<option value="">Actions</option> | ||
<option value="viewRegistration">View Record</option> | ||
<option value="renewRegistration">Renew Registration</option> | ||
</select> | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
{% include 'paginator.html' %} | ||
</div> | ||
<script> | ||
function filterTableByStatus() { | ||
var dropdown, statusFilter, xhr, url_params, url; | ||
dropdown = document.getElementById("statusFilter"); | ||
statusFilter = dropdown.value; | ||
url_params = `?status=${statusFilter}`; | ||
{% if selected_org %} | ||
url_params += `&org={{selected_org}}`; | ||
{% endif %} | ||
url = `/register/list-registration-requests/${url_params}`; | ||
xhr = new XMLHttpRequest(); | ||
xhr.open('GET', url); | ||
xhr.send(); | ||
window.location.href = url; | ||
window.location.load(); | ||
} | ||
function filterTableByOrganization() { | ||
var input, orgFilter, xhr, url_params, url; | ||
input = document.getElementById("organizationFilter"); | ||
orgFilter = input.value.replace("&", encodeURIComponent('&')); | ||
url_params = `?org=${orgFilter}`; | ||
{% if selected_status %} | ||
url_params = `?status={{selected_status}}&org=${orgFilter}`; | ||
{% endif %} | ||
url = `/register/list-registration-requests/${url_params}`; | ||
xhr = new XMLHttpRequest(); | ||
xhr.open('GET', url); | ||
xhr.send(); | ||
window.location.href = url; | ||
window.location.load(); | ||
} | ||
function clearSelections() { | ||
var xhr; | ||
xhr = new XMLHttpRequest(); | ||
xhr.open('GET', '/register/list-registration-requests/') | ||
xhr.send() | ||
window.location.href = '/register/list-registration-requests/'; | ||
window.location.load(); | ||
} | ||
|
||
function openAction(reg_id) { | ||
var actionsDropdown, selectedOption, modal_id; | ||
actionsDropdown = document.getElementById(`actionsSubmitterDropdown_${reg_id}`); | ||
/* grabs dropdown option number selected by user via selectedIndex, | ||
then grabs actual value associated with that option via | ||
options[index].value */ | ||
selectedOption = actionsDropdown.options[actionsDropdown.selectedIndex].value; | ||
modal_id = `${selectedOption}Modal_${reg_id}`; | ||
$(`#${modal_id}`).modal({backdrop: "static"}); /* modal appears manually */ | ||
actionsDropdown.selectedIndex = 0; /* resets dropdown to display 'Select Action' again */ | ||
if (selectedOption == "renewRegistration") { | ||
var xhr; | ||
xhr = new XMLHttpRequest(); | ||
xhr.open('GET', `/register/request-to-submit/?reg_id=${reg_id}`) | ||
xhr.send() | ||
window.location.href = `/register/request-to-submit/?reg_id=${reg_id}`; | ||
window.location.load(); | ||
} | ||
} | ||
</script> | ||
|
||
{% endblock %} |
14 changes: 14 additions & 0 deletions
14
apcd-cms/src/apps/submitter_renewals_listing/templates/submitter_listing_error.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{% extends "standard.html" %} | ||
{% block content %} | ||
<div class="container"> | ||
{% include "nav_cms_breadcrumbs.html" %} | ||
|
||
<h1>View Registations</h1> | ||
<hr /> | ||
<p class="c-message c-message--error"> | ||
An error occurred loading your registrations. For help, <a href="/workbench/dashboard">submit a ticket</a>. | ||
</p> | ||
<a class="c-button c-button--primary" href="/">Back to Home</a> | ||
</div> | ||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from django.urls import path | ||
from apps.submitter_renewals_listing.views import SubmittersTable | ||
|
||
app_name = 'register' | ||
urlpatterns = [ | ||
path('list-registration-requests/', SubmittersTable.as_view(), name='submitter_regis_table'), | ||
path(r'list-registration-requests/?status=(?P<status>)/', SubmittersTable.as_view(), name='submitter_regis_table'), | ||
path(r'list-registration-requests/?org=(?P<org>)/', SubmittersTable.as_view(), name='submitter_regis_table'), | ||
path(r'list-registration-requests/?status=(?P<status>)&org=(?P<org>)/', SubmittersTable.as_view(), name='submitter_regis_table') | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from django.http import HttpResponse, HttpResponseRedirect, JsonResponse | ||
from django.views.generic.base import TemplateView | ||
from django.template import loader | ||
from apps.utils.apcd_database import get_registrations, get_registration_contacts, get_submitter_info, get_registration_entities | ||
from apps.utils.apcd_groups import is_submitter_admin | ||
from apps.admin_regis_table.views import RegistrationsTable | ||
import logging | ||
import json | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class SubmittersTable(RegistrationsTable): | ||
template_name = 'list_submitter_registrations.html' | ||
|
||
def get(self, request, *args, **kwargs): | ||
try: | ||
response = get_submitter_code(request.user) | ||
submitter_code = response.content | ||
data = json.loads(submitter_code) | ||
submitter_code = data['submitter_code'] | ||
registrations_content = get_registrations(submitter_code=submitter_code) | ||
registrations_entities = get_registration_entities(submitter_code=submitter_code) | ||
registrations_contacts = get_registration_contacts(submitter_code=submitter_code) | ||
context = self.get_context_data(registrations_content, registrations_entities, registrations_contacts, *args,**kwargs) | ||
template = loader.get_template(self.template_name) | ||
return HttpResponse(template.render(context, request)) | ||
except: | ||
context = super(RegistrationsTable, self).get_context_data(*args, **kwargs) | ||
template = loader.get_template('submitter_listing_error.html') | ||
return HttpResponse(template.render(context, request)) | ||
|
||
def dispatch(self, request, *args, **kwargs): | ||
if not request.user.is_authenticated or not is_submitter_admin(request.user): | ||
return HttpResponseRedirect('/') | ||
return super(SubmittersTable, self).dispatch(request, *args, **kwargs) | ||
|
||
def get_context_data(self, registrations_content, registrations_entities, registrations_contacts, *args, **kwargs): | ||
context = super().get_context_data(registrations_content, registrations_entities, registrations_contacts, *args, **kwargs) | ||
context['header'] = ['Business Name', 'Year', 'Type', 'Location', 'Registration Status', 'Actions'] | ||
context['pagination_url_namespaces'] = 'register:submitter_regis_table' | ||
return context | ||
|
||
def get_submitter_code(request): | ||
submitter = get_submitter_info(str(request)) | ||
for i in submitter: | ||
submitter_code = i[1] | ||
return JsonResponse(({'submitter_code' : submitter_code } if submitter_code else ""), safe=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
CUSTOM_APPS = ['apps.admin_regis_table', 'apps.apcd_login', 'apps.registrations', 'apps.submissions', 'apps.exception', 'apps.admin_submissions', 'apps.admin_extension', 'apps.admin_exception', 'apps.extension', 'apps.view_users', 'apps.components.paginator', 'apps.utils'] | ||
CUSTOM_APPS = ['apps.admin_regis_table', 'apps.apcd_login', 'apps.registrations', 'apps.submissions', 'apps.exception', 'apps.admin_submissions', 'apps.admin_extension', 'apps.admin_exception', 'apps.extension', 'apps.submitter_renewals_listing', 'apps.view_users', 'apps.components.paginator', 'apps.utils'] | ||
CUSTOM_MIDDLEWARE = [] | ||
STATICFILES_DIRS = ('taccsite_custom/apcd-cms', 'apps/admin_regis_table', 'apps/submissions', 'apps/exception', 'apps/extension', 'apps/view_users', 'apps/components/paginator', 'apps/utils') | ||
STATICFILES_DIRS = ('taccsite_custom/apcd-cms', 'apps/admin_regis_table', 'apps/submissions', 'apps/exception', 'apps/extension', 'apps/submitter_renewals_listing', 'apps/view_users', 'apps/components/paginator', 'apps/utils') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters