Skip to content

Commit

Permalink
task/WP-345: Entities changes UTH & task/WP-376: Add 'Year' column to…
Browse files Browse the repository at this point in the history
… registration admin listing (#245)

* Made medical, pharmacy, and dental checkboxes required + modified files type help text to say that one of those three is required.

* Checkbox validation fxn is now generalized for any group of checkboxes; some code simplification as well, and parallel changes to entities add. blocks to changes on form body template

* Convert coverage estimate fields to text fields with regex pattern to only capture relevant numbers

* Increase state drop down box size by 0.5ch

* Add JS scripting to switch between state abbreviation and full state description depending on user interaction with state drop down

* Add data-display-value attribute to state list options

* Add 'Year' column to admin registrations listing page

* Make common styling source for registrations listing table now that both tables have same layout

* Add registration_year to create_registration util, and accommodate renewal in this

* Pass renewal parameter to create_registration util to check for renewal on form

* Ensure checkbox validation for file type selection works on edit & renew

* Ensure option must be selected from state drop down to submit form

* task/WP-345--entities-changes-uth---proposed-query-fix (#247)

* task/WP-345--entities-changes-uth---proposed-query-fix

* Pass confirmed reg_ids to get_entities and get_contacts on renewal listing

---------

Co-authored-by: Garrett Edmonds <[email protected]>

---------

Co-authored-by: sophia-massie <[email protected]>
  • Loading branch information
edmondsgarrett and sophia-massie authored Nov 9, 2023
1 parent 6d7a712 commit 398d3e3
Show file tree
Hide file tree
Showing 10 changed files with 257 additions and 192 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
/* To label the cells */
/* RFE: Add `data-label` to each cell so we can use `attr(data-label)` */
.registration-table td:nth-of-type(1):before { content: "Business Name"; }
.registration-table td:nth-of-type(2):before { content: "Type"; }
.registration-table td:nth-of-type(3):before { content: "Location"; }
.registration-table td:nth-of-type(4):before { content: "Registration Status"; }
.registration-table td:nth-of-type(5):before { content: "Actions"; }
.registration-table td:nth-of-type(2):before { content: "Year"; }
.registration-table td:nth-of-type(3):before { content: "Type"; }
.registration-table td:nth-of-type(4):before { content: "Location"; }
.registration-table td:nth-of-type(5):before { content: "Registration Status"; }
.registration-table td:nth-of-type(6):before { content: "Actions"; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ <h1>List Registrations</h1>
{% 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>
Expand Down
2 changes: 1 addition & 1 deletion apcd-cms/src/apps/admin_regis_table/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def dispatch(self, request, *args, **kwargs):
def get_context_data(self, registrations_content, registrations_entities, registrations_contacts, *args, **kwargs):
context = super(RegistrationsTable, self).get_context_data(*args, **kwargs)

context['header'] = ['Business Name', 'Type', 'Location', 'Registration Status', 'Actions']
context['header'] = ['Business Name', 'Year', 'Type', 'Location', 'Registration Status', 'Actions']
context['status_options'] = ['All', 'Received', 'Processing', 'Complete']
context['org_options'] = ['All']

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ input[name^="zip_code"] {
box-sizing: content-box;
}
select[name^="state"] {
--length: 2ch;
--length: 2.5ch;
--ui-buffer: 2.5ch; /* to make room for dropdown arrows */

width: calc( var(--length) + var(--ui-buffer) );
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion apcd-cms/src/apps/registrations/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ def get(self, request):
def post(self, request):
form = request.POST.copy()
old_reg_id = None
renewal = False
if 'reg_id' in form:
old_reg_id = form['reg_id']
renewal = True
errors = []

if (request.user.is_authenticated):
Expand All @@ -59,7 +61,7 @@ def post(self, request):
else:
return HttpResponseRedirect('/')

reg_resp = apcd_database.create_registration(form)
reg_resp = apcd_database.create_registration(form, renewal=renewal)
if not _err_msg(reg_resp) and type(reg_resp) == int:
for iteration in range(1,6):
contact_resp = apcd_database.create_registration_contact(form, reg_resp, iteration, old_reg_id=old_reg_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<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' %}">
<link rel="stylesheet" href="{% static 'admin_regis_table/css/table.css' %}">

<div class="container">
{% include "nav_cms_breadcrumbs.html" %}
Expand Down
6 changes: 6 additions & 0 deletions apcd-cms/src/apps/submitter_renewals_listing/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ def get(self, request, *args, **kwargs):
data = json.loads(submitter_code)
submitter_code = data['submitter_code']
registrations_content = get_registrations(submitter_code=submitter_code)
registrations_entities = []
registrations_contacts = []
for reg in registrations_content:
reg_id = int(reg[0])
registrations_entities.append(get_registration_entities(reg_id=reg_id)) # get entities and contacts for reg id's
registrations_contacts.append(get_registration_contacts(reg_id=reg_id)) # we have already verified are associated w/ given 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)
Expand Down
21 changes: 10 additions & 11 deletions apcd-cms/src/apps/utils/apcd_database.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.conf import settings
import psycopg2
from datetime import datetime
from datetime import datetime, date
import re
import logging

Expand Down Expand Up @@ -168,7 +168,7 @@ def get_registrations(reg_id=None, submitter_code=None):
registrations.state,
registrations.zip,
registrations.registration_year
FROM registrations
FROM registrations
{f"WHERE registration_id = {str(reg_id)}" if reg_id is not None else ''}
{f"LEFT JOIN registration_submitters on registrations.registration_id = registration_submitters.registration_id LEFT JOIN submitters ON registration_submitters.submitter_id = submitters.submitter_id WHERE submitter_code = '{str(submitter_code)}' ORDER BY registrations.registration_id" if submitter_code is not None else ''}"""
cur = conn.cursor()
Expand All @@ -185,7 +185,7 @@ def get_registrations(reg_id=None, submitter_code=None):
conn.close()


def create_registration(form):
def create_registration(form, renewal=False):
cur = None
conn = None
try:
Expand All @@ -209,8 +209,9 @@ def create_registration(form):
mail_address,
city,
state,
zip
) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)
zip,
registration_year
) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)
RETURNING registration_id"""
values = (
datetime.now(),
Expand All @@ -223,7 +224,8 @@ def create_registration(form):
_clean_value(form['mailing-address']),
_clean_value(form['city']),
form['state'][:2],
form['zip_code']
form['zip_code'],
"{}".format(datetime.now().year + (1 if renewal else 0))
)
cur.execute(operation, values)
conn.commit()
Expand Down Expand Up @@ -321,9 +323,7 @@ def get_registration_entities(reg_id=None, submitter_code=None):
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 ''}
{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 ''}"""

{f"WHERE registration_id = {str(reg_id)}" if reg_id is not None else ''}"""
cur = conn.cursor()
cur.execute(query)
return cur.fetchall()
Expand Down Expand Up @@ -534,8 +534,7 @@ def get_registration_contacts(reg_id=None, submitter_code=None):
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 ''}
{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 ''}"""
{f"WHERE registration_id = {str(reg_id)}" if reg_id is not None else ''}"""
cur = conn.cursor()
cur.execute(query)
return cur.fetchall()
Expand Down

0 comments on commit 398d3e3

Please sign in to comment.