Jul 20 - Update The Scheduled inspection's Start button on the Dashboard, only for Assignee
This commit is contained in:
@@ -4,7 +4,9 @@ app/routes/scheduled_inspections.py
|
||||
Planned / recurring inspection assignments (phase36).
|
||||
|
||||
Management (list/new/edit/delete) : admin, director, project_manager
|
||||
Start (execute the planned inspection): the assigned inspector, or admin/director/pm
|
||||
Start (execute the planned inspection): the assigned inspector ONLY (the person
|
||||
who must do it) — not managers. A manager
|
||||
who needs to run it assigns it to themselves.
|
||||
Cron reminders : POST /run?token=DIGEST_SECRET (no login)
|
||||
|
||||
Fulfillment (marking a schedule done and rolling recurring ones forward) happens
|
||||
@@ -224,11 +226,11 @@ def start(schedule_id):
|
||||
sched = db.session.get(ScheduledInspection, schedule_id)
|
||||
if sched is None:
|
||||
abort(404)
|
||||
if current_user.role == 'customer':
|
||||
abort(403)
|
||||
|
||||
# Only the assigned inspector, or a manager, may start it.
|
||||
if current_user.role == 'inspector' and sched.inspector_id != current_user.id:
|
||||
# Only the assigned inspector may start it — this inspection is theirs to do.
|
||||
# Managers (admin/director/pm) manage the schedule but do not start it for
|
||||
# someone else; if a manager needs to do the inspection, assign it to them.
|
||||
if not sched.inspector_id or sched.inspector_id != current_user.id:
|
||||
abort(403)
|
||||
|
||||
if not sched.active:
|
||||
|
||||
@@ -58,8 +58,8 @@
|
||||
<td class="small">{{ s.inspector.display_name if s.inspector else '—' }}</td>
|
||||
<td class="small">{{ s.next_due_date.strftime('%b %d') }}</td>
|
||||
<td class="text-end">
|
||||
{% if current_user.role in ['admin','director','project_manager','auditor']
|
||||
or (current_user.role == 'inspector' and s.inspector_id == current_user.id) %}
|
||||
{# Start is shown only to the assignee — the inspection is theirs to do. #}
|
||||
{% if s.inspector_id and s.inspector_id == current_user.id %}
|
||||
<a href="{{ url_for('scheduled_inspections.start', schedule_id=s.id) }}"
|
||||
class="btn btn-sm btn-success py-0"><i class="bi bi-play-fill"></i> Start</a>
|
||||
{% endif %}
|
||||
|
||||
@@ -60,8 +60,8 @@
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="text-end text-nowrap">
|
||||
{% if s.active and (current_user.role in ['admin','director','project_manager','auditor']
|
||||
or (current_user.role == 'inspector' and s.inspector_id == current_user.id)) %}
|
||||
{# Start is shown only to the assignee — the inspection is theirs to do. #}
|
||||
{% if s.active and s.inspector_id and s.inspector_id == current_user.id %}
|
||||
<a href="{{ url_for('scheduled_inspections.start', schedule_id=s.id) }}"
|
||||
class="btn btn-sm btn-success" title="Start this inspection">
|
||||
<i class="bi bi-play-fill"></i> Start
|
||||
|
||||
Reference in New Issue
Block a user