diff --git a/apcd-cms/src/apps/exception/views.py b/apcd-cms/src/apps/exception/views.py
index dbedf683..60dfd810 100644
--- a/apcd-cms/src/apps/exception/views.py
+++ b/apcd-cms/src/apps/exception/views.py
@@ -35,7 +35,7 @@ def get_context_data(self, *args, **kwargs):
user = self.request.user.username
- submitters = apcd_database.get_submitter_for_extend_or_except(user)
+ submitters = apcd_database.get_submitter_info(user)
file_type = self.request.GET.get('file_type')
@@ -127,7 +127,7 @@ def get_context_data(self, *args, **kwargs):
user = self.request.user.username
- submitters = apcd_database.get_submitter_for_extend_or_except(user)
+ submitters = apcd_database.get_submitter_info(user)
self.request.session['submitters'] = submitters
diff --git a/apcd-cms/src/apps/extension/views.py b/apcd-cms/src/apps/extension/views.py
index 3bfbb4af..bfea1cf3 100644
--- a/apcd-cms/src/apps/extension/views.py
+++ b/apcd-cms/src/apps/extension/views.py
@@ -21,7 +21,7 @@ def get_context_data(self, *args, **kwargs):
user = self.request.user.username
- submitters = apcd_database.get_submitter_for_extend_or_except(user)
+ submitters = apcd_database.get_submitter_info(user)
self.request.session['submitters'] = submitters
diff --git a/apcd-cms/src/apps/registrations/urls.py b/apcd-cms/src/apps/registrations/urls.py
index aaa90d23..88b64747 100644
--- a/apcd-cms/src/apps/registrations/urls.py
+++ b/apcd-cms/src/apps/registrations/urls.py
@@ -3,5 +3,5 @@
app_name = 'register'
urlpatterns = [
- path('request-to-submit/', SubmissionFormView.as_view(), name='index')
+ path('request-to-submit/', SubmissionFormView.as_view(), name='register_table')
]
diff --git a/apcd-cms/src/apps/submitter_renewals_listing/__init__.py b/apcd-cms/src/apps/submitter_renewals_listing/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/apcd-cms/src/apps/submitter_renewals_listing/apps.py b/apcd-cms/src/apps/submitter_renewals_listing/apps.py
new file mode 100644
index 00000000..78aafdff
--- /dev/null
+++ b/apcd-cms/src/apps/submitter_renewals_listing/apps.py
@@ -0,0 +1,5 @@
+from django.apps import AppConfig
+
+
+class SubmitterRenewalsListingConfig(AppConfig):
+ name = 'submitter_renewals_listing'
diff --git a/apcd-cms/src/apps/submitter_renewals_listing/static/submitter_renewals_listing/css/table.css b/apcd-cms/src/apps/submitter_renewals_listing/static/submitter_renewals_listing/css/table.css
new file mode 100644
index 00000000..4d479533
--- /dev/null
+++ b/apcd-cms/src/apps/submitter_renewals_listing/static/submitter_renewals_listing/css/table.css
@@ -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"; }
+}
diff --git a/apcd-cms/src/apps/submitter_renewals_listing/templates/list_submitter_registrations.html b/apcd-cms/src/apps/submitter_renewals_listing/templates/list_submitter_registrations.html
new file mode 100644
index 00000000..7ac98c05
--- /dev/null
+++ b/apcd-cms/src/apps/submitter_renewals_listing/templates/list_submitter_registrations.html
@@ -0,0 +1,127 @@
+{% extends "standard.html" %}
+{% load static %}
+
+{% block content %}
+
+
+
+
+
+
+ {% include "nav_cms_breadcrumbs.html" %}
+
+
Registration Information
+
+
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.
+
+
+
+ Filter by Status:
+
+ {% for option in status_options %}
+ {{ option }}
+ {% endfor %}
+
+ Filter by Organization:
+
+ {% for option in org_options %}
+ {{ option }}
+ {% endfor %}
+
+ {% if selected_status or selected_org %}
+ Clear Options
+ {% endif %}
+
+
+
+
+
+ {% for k in header %}
+ {{k}}
+ {% endfor %}
+
+
+
+ {% for r in page %}
+
+ {{r.biz_name}}
+ {{r.year}}
+ {{r.type}}
+ {{r.location}}
+ {{r.reg_status}}
+
+ {% include "view_registration_modal.html" %}
+
+ Actions
+ View Record
+ Renew Registration
+
+
+
+ {% endfor %}
+
+
+ {% include 'paginator.html' %}
+
+
+
+{% endblock %}
diff --git a/apcd-cms/src/apps/submitter_renewals_listing/templates/submitter_listing_error.html b/apcd-cms/src/apps/submitter_renewals_listing/templates/submitter_listing_error.html
new file mode 100644
index 00000000..503e7b92
--- /dev/null
+++ b/apcd-cms/src/apps/submitter_renewals_listing/templates/submitter_listing_error.html
@@ -0,0 +1,14 @@
+{% extends "standard.html" %}
+{% block content %}
+
+ {% include "nav_cms_breadcrumbs.html" %}
+
+
View Registations
+
+
+ An error occurred loading your registrations. For help, submit a ticket .
+
+
Back to Home
+
+
+{% endblock %}
diff --git a/apcd-cms/src/apps/submitter_renewals_listing/urls.py b/apcd-cms/src/apps/submitter_renewals_listing/urls.py
new file mode 100644
index 00000000..bd43d3c5
--- /dev/null
+++ b/apcd-cms/src/apps/submitter_renewals_listing/urls.py
@@ -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)/', SubmittersTable.as_view(), name='submitter_regis_table'),
+ path(r'list-registration-requests/?org=(?P)/', SubmittersTable.as_view(), name='submitter_regis_table'),
+ path(r'list-registration-requests/?status=(?P)&org=(?P)/', SubmittersTable.as_view(), name='submitter_regis_table')
+]
diff --git a/apcd-cms/src/apps/submitter_renewals_listing/views.py b/apcd-cms/src/apps/submitter_renewals_listing/views.py
new file mode 100644
index 00000000..921c8a52
--- /dev/null
+++ b/apcd-cms/src/apps/submitter_renewals_listing/views.py
@@ -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)
diff --git a/apcd-cms/src/apps/utils/apcd_database.py b/apcd-cms/src/apps/utils/apcd_database.py
index 668b8854..cd17ff7e 100644
--- a/apcd-cms/src/apps/utils/apcd_database.py
+++ b/apcd-cms/src/apps/utils/apcd_database.py
@@ -127,7 +127,7 @@ def get_user_role(user):
conn.close()
-def get_registrations(reg_id=None):
+def get_registrations(reg_id=None, submitter_code=None):
cur = None
conn = None
try:
@@ -139,7 +139,7 @@ def get_registrations(reg_id=None):
port=APCD_DB['port'],
sslmode='require'
)
- query = f"""SELECT
+ query = f"""SELECT DISTINCT
registrations.registration_id,
registrations.posted_date,
registrations.applicable_period_start,
@@ -151,8 +151,11 @@ def get_registrations(reg_id=None):
registrations.mail_address,
registrations.city,
registrations.state,
- registrations.zip
- FROM registrations {f"WHERE registration_id = {str(reg_id)}" if reg_id is not None else ''}"""
+ registrations.zip,
+ registrations.registration_year
+ FROM registrations
+ {f"WHERE registration_id = {str(reg_id)}" if reg_id is not None else ''}
+ {f"LEFT JOIN submitters on registrations.registration_id = submitters.registration_id WHERE submitter_code = '{str(submitter_code)}' ORDER BY registrations.registration_id" if submitter_code is not None else ''}"""
cur = conn.cursor()
cur.execute(query)
return cur.fetchall()
@@ -272,7 +275,7 @@ def update_registration(form, reg_id):
if conn is not None:
conn.close()
-def get_registration_entities(reg_id=None):
+def get_registration_entities(reg_id=None, submitter_code=None):
cur = None
conn = None
try:
@@ -302,7 +305,10 @@ def get_registration_entities(reg_id=None):
registration_entities.file_mc,
registration_entities.file_pc,
registration_entities.file_dc
- FROM registration_entities {f"WHERE registration_id = {str(reg_id)}" if reg_id is not None else ''}"""
+ FROM registration_entities
+ {f"WHERE registration_id = {str(reg_id)}" if reg_id is not None else ''}
+ {f"LEFT JOIN submitters on registration_entities.registration_id = submitters.registration_id WHERE submitter_code = '{str(submitter_code)}'" if submitter_code is not None else ''}"""
+
cur = conn.cursor()
cur.execute(query)
return cur.fetchall()
@@ -492,7 +498,7 @@ def delete_registration_entity(reg_id, ent_id):
conn.close()
-def get_registration_contacts(reg_id=None):
+def get_registration_contacts(reg_id=None, submitter_code=None):
cur = None
conn = None
try:
@@ -512,7 +518,9 @@ def get_registration_contacts(reg_id=None):
registration_contacts.contact_name,
registration_contacts.contact_phone,
registration_contacts.contact_email
- FROM registration_contacts {f"WHERE registration_id = {str(reg_id)}" if reg_id is not None else ''}"""
+ FROM registration_contacts
+ {f"WHERE registration_id = {str(reg_id)}" if reg_id is not None else ''}
+ {f"LEFT JOIN submitters on registration_contacts.registration_id = submitters.registration_id WHERE submitter_code = '{str(submitter_code)}'" if submitter_code is not None else ''}"""
cur = conn.cursor()
cur.execute(query)
return cur.fetchall()
@@ -1236,7 +1244,7 @@ def update_extension(form):
if cur is not None:
cur.close()
-def get_submitter_for_extend_or_except(user):
+def get_submitter_info(user):
cur = None
conn = None
try:
diff --git a/apcd-cms/src/apps/utils/apcd_groups.py b/apcd-cms/src/apps/utils/apcd_groups.py
index 866afb65..39305034 100644
--- a/apcd-cms/src/apps/utils/apcd_groups.py
+++ b/apcd-cms/src/apps/utils/apcd_groups.py
@@ -6,3 +6,6 @@ def has_apcd_group(user):
def is_apcd_admin(user):
return user.groups.filter(name='APCD_ADMIN').exists()
+
+def is_submitter_admin(user):
+ return user.groups.filter(name='SUBMITTER_ADMIN').exists()
\ No newline at end of file
diff --git a/apcd-cms/src/apps/utils/registrations_data_formatting.py b/apcd-cms/src/apps/utils/registrations_data_formatting.py
index 60050fbf..13c560c1 100644
--- a/apcd-cms/src/apps/utils/registrations_data_formatting.py
+++ b/apcd-cms/src/apps/utils/registrations_data_formatting.py
@@ -14,6 +14,7 @@ def _set_registration(reg, reg_ents, reg_conts):
),
'reg_status': reg[5].title(),
'reg_id': reg[0],
+ 'year': reg[12],
'view_modal_content': _set_modal_content(reg, reg_ents, reg_conts, org_types)
}
def _set_entities(reg_ent):
diff --git a/apcd-cms/src/taccsite_cms/custom_app_settings.py b/apcd-cms/src/taccsite_cms/custom_app_settings.py
index 14baebe8..9c35e8d9 100644
--- a/apcd-cms/src/taccsite_cms/custom_app_settings.py
+++ b/apcd-cms/src/taccsite_cms/custom_app_settings.py
@@ -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')
diff --git a/apcd-cms/src/taccsite_cms/urls_custom.py b/apcd-cms/src/taccsite_cms/urls_custom.py
index eea7e993..55cbe897 100644
--- a/apcd-cms/src/taccsite_cms/urls_custom.py
+++ b/apcd-cms/src/taccsite_cms/urls_custom.py
@@ -8,6 +8,7 @@
path('administration/', include('apps.admin_extension.urls', namespace='admin_extension')),
path('apcd-login/', include('apps.apcd_login.urls', namespace='apcd_login')),
path('register/', include('apps.registrations.urls', namespace='register')),
+ path('register/', include('apps.submitter_renewals_listing.urls', namespace='submitter_regis_table')),
path('submissions/', include('apps.extension.urls', namespace='extension')),
path('submissions/', include('apps.exception.urls', namespace='exception')),
path('submissions/', include('apps.submissions.urls', namespace='submissions'))