05/26 Add contract information to issues related pages
This commit is contained in:
+12
-1
@@ -449,13 +449,23 @@ def unfollow(issue_id):
|
||||
@login_required
|
||||
@supervisor_required
|
||||
def create():
|
||||
from app.models.project import Project
|
||||
form = IssueForm()
|
||||
facilities = Facility.query.filter_by(active=True).order_by(Facility.name).all()
|
||||
projects = Project.query.filter_by(active=True).order_by(Project.name).all()
|
||||
staff = User.query.filter(User.role.in_(['admin', 'director', 'inspector'])).order_by(User.username).all()
|
||||
|
||||
form.facility_id.choices = [(f.id, f.name) for f in facilities]
|
||||
form.assigned_to.choices = [(0, '— Unassigned —')] + [(u.id, u.username) for u in staff]
|
||||
|
||||
# On POST validation error: identify which contract the submitted facility
|
||||
# belongs to so the contract selector can be restored on re-render.
|
||||
selected_project_id = None
|
||||
if form.facility_id.data:
|
||||
_fac = db.session.get(Facility, form.facility_id.data)
|
||||
if _fac:
|
||||
selected_project_id = _fac.project_id
|
||||
|
||||
if form.validate_on_submit():
|
||||
from app.routes.inspections import _save_photo
|
||||
photo_path = _save_photo(form.photo.data, subfolder='issue_photos')
|
||||
@@ -520,7 +530,8 @@ def create():
|
||||
flash('Issue created.', 'success')
|
||||
return redirect(url_for('issues.index'))
|
||||
|
||||
return render_template('issues/form.html', form=form, title='Log New Issue')
|
||||
return render_template('issues/form.html', form=form, title='Log New Issue',
|
||||
projects=projects, selected_project_id=selected_project_id)
|
||||
|
||||
|
||||
# ── Supervisor verify resolved issue ─────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user