From d7da1f223843a5092ae9a0ca7ae56a19e74f2495 Mon Sep 17 00:00:00 2001 From: edmondsgarrett <43251554+edmondsgarrett@users.noreply.github.com> Date: Fri, 10 Nov 2023 15:47:13 -0600 Subject: [PATCH] task/WP-383: Allow user input of registration year (#250) * Add registration year field to registration form * Write registration year from form into db on create/renew + edit * Add Registration Year to View Registration modal * Change reg_year input to text w/ int bounds from 2023 to 2100 --- .../templates/view_registration_modal.html | 2 ++ .../registration_form_body.html | 18 ++++++++++++++++++ apcd-cms/src/apps/utils/apcd_database.py | 6 ++++-- .../utils/registrations_data_formatting.py | 1 + 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/apcd-cms/src/apps/admin_regis_table/templates/view_registration_modal.html b/apcd-cms/src/apps/admin_regis_table/templates/view_registration_modal.html index 30ba464e..cfbbc04c 100644 --- a/apcd-cms/src/apps/admin_regis_table/templates/view_registration_modal.html +++ b/apcd-cms/src/apps/admin_regis_table/templates/view_registration_modal.html @@ -24,6 +24,8 @@

Organization

Other {% endif %} +
Registration Year
+
{{r.view_modal_content.year}}
Type
{{r.view_modal_content.type}}
Business Name
diff --git a/apcd-cms/src/apps/registrations/templates/submission_form/registration_form_body.html b/apcd-cms/src/apps/registrations/templates/submission_form/registration_form_body.html index 1d039cfe..b5f26e12 100644 --- a/apcd-cms/src/apps/registrations/templates/submission_form/registration_form_body.html +++ b/apcd-cms/src/apps/registrations/templates/submission_form/registration_form_body.html @@ -56,6 +56,24 @@ +
+ + + + + +
+
diff --git a/apcd-cms/src/apps/utils/apcd_database.py b/apcd-cms/src/apps/utils/apcd_database.py index 795dcb7f..950f1a9d 100644 --- a/apcd-cms/src/apps/utils/apcd_database.py +++ b/apcd-cms/src/apps/utils/apcd_database.py @@ -225,7 +225,7 @@ def create_registration(form, renewal=False): _clean_value(form['city']), form['state'][:2], form['zip_code'], - "{}".format(datetime.now().year + (1 if renewal else 0)) + form['reg_year'] ) cur.execute(operation, values) conn.commit() @@ -264,7 +264,8 @@ def update_registration(form, reg_id): city = %s, state = %s, zip = %s, - updated_at= %s + updated_at= %s, + registration_year = %s WHERE registration_id = %s RETURNING registration_id""" values = ( @@ -276,6 +277,7 @@ def update_registration(form, reg_id): form['state'][:2], form['zip_code'], datetime.now(), + form['reg_year'], reg_id ) cur.execute(operation, values) diff --git a/apcd-cms/src/apps/utils/registrations_data_formatting.py b/apcd-cms/src/apps/utils/registrations_data_formatting.py index 13c560c1..c36f6365 100644 --- a/apcd-cms/src/apps/utils/registrations_data_formatting.py +++ b/apcd-cms/src/apps/utils/registrations_data_formatting.py @@ -74,6 +74,7 @@ def _set_modal_content(reg, reg_ent, reg_cont, org_types): 'address': reg[8], 'zip': reg[11], 'for_self': reg[4], + 'year': reg[12], 'entities': [_set_entities(ent) for ent in reg_ent], 'contacts': [_set_contacts(cont) for cont in reg_cont], 'org_types': org_types,