Skip to content

Commit

Permalink
task/WP-383: Allow user input of registration year (#250)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
edmondsgarrett authored Nov 10, 2023
1 parent 398d3e3 commit d7da1f2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ <h4>Organization</h4>
Other
{% endif %}
</dd>
<dt class="c-data-list__key">Registration Year</dt>
<dd class="c-data-list__value">{{r.view_modal_content.year}}</dd>
<dt class="c-data-list__key">Type</dt>
<dd class="c-data-list__value">{{r.view_modal_content.type}}</dd>
<dt class="c-data-list__key">Business Name</dt>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,24 @@
</div>
</div>

<div class="field-wrapper textinput required">
<div class="field-errors" style="display: none"></div>

<label for="reg_year">
Registration Year<span class="asterisk">*</span>
</label>

<input
type="text"
class="textinput"
name="reg_year"
id="reg_year"
pattern="(202[3-9]|20[3-9][0-9]|2100)"
value='{% if renew %}{{r.year|add:"1"}}{% else %}{{r.year}}{% endif %}'
required
>
</div>

<div class="field-wrapper select required">
<div class="field-errors" style="display: none"></div>

Expand Down
6 changes: 4 additions & 2 deletions apcd-cms/src/apps/utils/apcd_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 = (
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions apcd-cms/src/apps/utils/registrations_data_formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d7da1f2

Please sign in to comment.