Jul 30 - Internal handler files
This commit is contained in:
+41
-3
@@ -462,8 +462,19 @@ def view(issue_id):
|
||||
issue.vendor_contact = form.vendor_contact.data.strip() or None
|
||||
issue.vendor_notes = form.vendor_notes.data.strip() or None
|
||||
|
||||
# Handler type (phase39)
|
||||
ht = form.handler_type.data or None
|
||||
# Handler type (phase39; NOT NULL since phase44)
|
||||
# Coerce empty/unknown to 'internal' explicitly. This is NOT
|
||||
# preventing a crash: handler_type carries a Python-side
|
||||
# default='internal', and SQLAlchemy applies a column default when
|
||||
# the attribute is None — so the previous `or None` would have been
|
||||
# silently rescued to 'internal' rather than raising. The point is to
|
||||
# not depend on that fairly obscure behaviour, and to state the
|
||||
# intended value at the point of assignment. The membership check
|
||||
# also backstops a crafted POST, though SelectField.pre_validate
|
||||
# already rejects out-of-choice values.
|
||||
ht = form.handler_type.data or 'internal'
|
||||
if ht not in ('internal', 'facility', 'vendor'):
|
||||
ht = 'internal'
|
||||
issue.handler_type = ht
|
||||
if ht == 'facility':
|
||||
issue.facility_handler_name = form.facility_handler_name.data.strip() or None
|
||||
@@ -474,6 +485,13 @@ def view(issue_id):
|
||||
issue.facility_handler_contact = None
|
||||
issue.facility_handler_notes = None
|
||||
|
||||
# Janitorial staff handler (phase44). Written unconditionally, the
|
||||
# same way vendor_* above is: the work-order dispatch route also
|
||||
# writes vendor_name, so clearing non-active handler fields here
|
||||
# would discard data set elsewhere.
|
||||
issue.internal_handler_name = (form.internal_handler_name.data or '').strip() or None
|
||||
issue.internal_handler_contact = (form.internal_handler_contact.data or '').strip() or None
|
||||
|
||||
from app.routes.inspections import _save_photo
|
||||
new_photos = []
|
||||
for file_obj in request.files.getlist('result_photos'):
|
||||
@@ -752,6 +770,25 @@ def create():
|
||||
reported_at = now_eastern(),
|
||||
reported_by = current_user.id,
|
||||
)
|
||||
|
||||
# "Handled By" — staff only; customer-created issues stay internal.
|
||||
# (phase44) Previously the create form carried no handler fields at all,
|
||||
# so a handler chosen here was silently discarded and had to be re-entered
|
||||
# on the update form.
|
||||
if current_user.role != 'customer':
|
||||
handler = form.handler_type.data or 'internal'
|
||||
if handler not in ('internal', 'facility', 'vendor'):
|
||||
handler = 'internal'
|
||||
issue.handler_type = handler
|
||||
issue.facility_handler_name = (form.facility_handler_name.data or '').strip() or None
|
||||
issue.facility_handler_contact = (form.facility_handler_contact.data or '').strip() or None
|
||||
issue.facility_handler_notes = (form.facility_handler_notes.data or '').strip() or None
|
||||
issue.vendor_name = (form.vendor_name.data or '').strip() or None
|
||||
issue.vendor_contact = (form.vendor_contact.data or '').strip() or None
|
||||
issue.vendor_notes = (form.vendor_notes.data or '').strip() or None
|
||||
issue.internal_handler_name = (form.internal_handler_name.data or '').strip() or None
|
||||
issue.internal_handler_contact = (form.internal_handler_contact.data or '').strip() or None
|
||||
|
||||
db.session.add(issue)
|
||||
db.session.commit()
|
||||
current_app.logger.info(
|
||||
@@ -804,7 +841,8 @@ def create():
|
||||
return redirect(url_for('issues.index'))
|
||||
|
||||
return render_template('issues/form.html', form=form, title='Log New Issue',
|
||||
projects=projects, selected_project_id=selected_project_id)
|
||||
projects=projects, selected_project_id=selected_project_id,
|
||||
issue_handler_descriptions=Issue.HANDLER_DESCRIPTIONS)
|
||||
|
||||
|
||||
# ── Supervisor verify resolved issue ─────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user