Skip to content

Commit 398d3e3

Browse files
task/WP-345: Entities changes UTH & task/WP-376: Add 'Year' column to 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]>
1 parent 6d7a712 commit 398d3e3

File tree

10 files changed

+257
-192
lines changed

10 files changed

+257
-192
lines changed

apcd-cms/src/apps/admin_regis_table/static/admin_regis_table/css/table.css

+5-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
/* To label the cells */
88
/* RFE: Add `data-label` to each cell so we can use `attr(data-label)` */
99
.registration-table td:nth-of-type(1):before { content: "Business Name"; }
10-
.registration-table td:nth-of-type(2):before { content: "Type"; }
11-
.registration-table td:nth-of-type(3):before { content: "Location"; }
12-
.registration-table td:nth-of-type(4):before { content: "Registration Status"; }
13-
.registration-table td:nth-of-type(5):before { content: "Actions"; }
10+
.registration-table td:nth-of-type(2):before { content: "Year"; }
11+
.registration-table td:nth-of-type(3):before { content: "Type"; }
12+
.registration-table td:nth-of-type(4):before { content: "Location"; }
13+
.registration-table td:nth-of-type(5):before { content: "Registration Status"; }
14+
.registration-table td:nth-of-type(6):before { content: "Actions"; }
1415
}

apcd-cms/src/apps/admin_regis_table/templates/list_registrations.html

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ <h1>List Registrations</h1>
4545
{% for r in page %}
4646
<tr>
4747
<td>{{r.biz_name}}</td>
48+
<td>{{r.year}}</td>
4849
<td>{{r.type}}</td>
4950
<td>{{r.location}}</td>
5051
<td>{{r.reg_status}}</td>

apcd-cms/src/apps/admin_regis_table/views.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def dispatch(self, request, *args, **kwargs):
8484
def get_context_data(self, registrations_content, registrations_entities, registrations_contacts, *args, **kwargs):
8585
context = super(RegistrationsTable, self).get_context_data(*args, **kwargs)
8686

87-
context['header'] = ['Business Name', 'Type', 'Location', 'Registration Status', 'Actions']
87+
context['header'] = ['Business Name', 'Year', 'Type', 'Location', 'Registration Status', 'Actions']
8888
context['status_options'] = ['All', 'Received', 'Processing', 'Complete']
8989
context['org_options'] = ['All']
9090

apcd-cms/src/apps/registrations/static/registrations/css/submission_form.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ input[name^="zip_code"] {
1010
box-sizing: content-box;
1111
}
1212
select[name^="state"] {
13-
--length: 2ch;
13+
--length: 2.5ch;
1414
--ui-buffer: 2.5ch; /* to make room for dropdown arrows */
1515

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

apcd-cms/src/apps/registrations/templates/submission_form/registration_form_body.html

+79-79
Large diffs are not rendered by default.

apcd-cms/src/apps/registrations/templates/submission_form/registration_form_scripts.html

+150-94
Large diffs are not rendered by default.

apcd-cms/src/apps/registrations/views.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ def get(self, request):
4747
def post(self, request):
4848
form = request.POST.copy()
4949
old_reg_id = None
50+
renewal = False
5051
if 'reg_id' in form:
5152
old_reg_id = form['reg_id']
53+
renewal = True
5254
errors = []
5355

5456
if (request.user.is_authenticated):
@@ -59,7 +61,7 @@ def post(self, request):
5961
else:
6062
return HttpResponseRedirect('/')
6163

62-
reg_resp = apcd_database.create_registration(form)
64+
reg_resp = apcd_database.create_registration(form, renewal=renewal)
6365
if not _err_msg(reg_resp) and type(reg_resp) == int:
6466
for iteration in range(1,6):
6567
contact_resp = apcd_database.create_registration_contact(form, reg_resp, iteration, old_reg_id=old_reg_id)

apcd-cms/src/apps/submitter_renewals_listing/templates/list_submitter_registrations.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<link rel="stylesheet" href="{% static 'apcd-cms/css/table.css' %}">
77
<link rel="stylesheet" href="{% static 'apcd-cms/css/modal.css' %}">
8-
<link rel="stylesheet" href="{% static 'submitter_renewals_listing/css/table.css' %}">
8+
<link rel="stylesheet" href="{% static 'admin_regis_table/css/table.css' %}">
99

1010
<div class="container">
1111
{% include "nav_cms_breadcrumbs.html" %}

apcd-cms/src/apps/submitter_renewals_listing/views.py

+6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ def get(self, request, *args, **kwargs):
1818
data = json.loads(submitter_code)
1919
submitter_code = data['submitter_code']
2020
registrations_content = get_registrations(submitter_code=submitter_code)
21+
registrations_entities = []
22+
registrations_contacts = []
23+
for reg in registrations_content:
24+
reg_id = int(reg[0])
25+
registrations_entities.append(get_registration_entities(reg_id=reg_id)) # get entities and contacts for reg id's
26+
registrations_contacts.append(get_registration_contacts(reg_id=reg_id)) # we have already verified are associated w/ given submitter code
2127
registrations_entities = get_registration_entities(submitter_code=submitter_code)
2228
registrations_contacts = get_registration_contacts(submitter_code=submitter_code)
2329
context = self.get_context_data(registrations_content, registrations_entities, registrations_contacts, *args,**kwargs)

apcd-cms/src/apps/utils/apcd_database.py

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from django.conf import settings
22
import psycopg2
3-
from datetime import datetime
3+
from datetime import datetime, date
44
import re
55
import logging
66

@@ -168,7 +168,7 @@ def get_registrations(reg_id=None, submitter_code=None):
168168
registrations.state,
169169
registrations.zip,
170170
registrations.registration_year
171-
FROM registrations
171+
FROM registrations
172172
{f"WHERE registration_id = {str(reg_id)}" if reg_id is not None else ''}
173173
{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 ''}"""
174174
cur = conn.cursor()
@@ -185,7 +185,7 @@ def get_registrations(reg_id=None, submitter_code=None):
185185
conn.close()
186186

187187

188-
def create_registration(form):
188+
def create_registration(form, renewal=False):
189189
cur = None
190190
conn = None
191191
try:
@@ -209,8 +209,9 @@ def create_registration(form):
209209
mail_address,
210210
city,
211211
state,
212-
zip
213-
) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)
212+
zip,
213+
registration_year
214+
) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)
214215
RETURNING registration_id"""
215216
values = (
216217
datetime.now(),
@@ -223,7 +224,8 @@ def create_registration(form):
223224
_clean_value(form['mailing-address']),
224225
_clean_value(form['city']),
225226
form['state'][:2],
226-
form['zip_code']
227+
form['zip_code'],
228+
"{}".format(datetime.now().year + (1 if renewal else 0))
227229
)
228230
cur.execute(operation, values)
229231
conn.commit()
@@ -321,9 +323,7 @@ def get_registration_entities(reg_id=None, submitter_code=None):
321323
registration_entities.file_pc,
322324
registration_entities.file_dc
323325
FROM registration_entities
324-
{f"WHERE registration_id = {str(reg_id)}" if reg_id is not None else ''}
325-
{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 ''}"""
326-
326+
{f"WHERE registration_id = {str(reg_id)}" if reg_id is not None else ''}"""
327327
cur = conn.cursor()
328328
cur.execute(query)
329329
return cur.fetchall()
@@ -534,8 +534,7 @@ def get_registration_contacts(reg_id=None, submitter_code=None):
534534
registration_contacts.contact_phone,
535535
registration_contacts.contact_email
536536
FROM registration_contacts
537-
{f"WHERE registration_id = {str(reg_id)}" if reg_id is not None else ''}
538-
{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 ''}"""
537+
{f"WHERE registration_id = {str(reg_id)}" if reg_id is not None else ''}"""
539538
cur = conn.cursor()
540539
cur.execute(query)
541540
return cur.fetchall()

0 commit comments

Comments
 (0)