06/18 Add inspections' filter by ID, and add id column on inspections/issues page
This commit is contained in:
+26
-17
@@ -228,16 +228,19 @@ def index():
|
|||||||
else:
|
else:
|
||||||
q = q.filter(Inspection.facility_id.in_(customer_facility_ids))
|
q = q.filter(Inspection.facility_id.in_(customer_facility_ids))
|
||||||
|
|
||||||
status_filter = request.args.get('status', '')
|
status_filter = request.args.get('status', '')
|
||||||
facility_filter = request.args.get('facility_id', '')
|
facility_filter = request.args.get('facility_id', '')
|
||||||
follow_up_filter = request.args.get('follow_up', '')
|
follow_up_filter = request.args.get('follow_up', '')
|
||||||
contract_filter = request.args.get('contract_id', '')
|
contract_filter = request.args.get('contract_id', '')
|
||||||
date_from_filter = request.args.get('date_from', '')
|
date_from_filter = request.args.get('date_from', '')
|
||||||
date_to_filter = request.args.get('date_to', '')
|
date_to_filter = request.args.get('date_to', '')
|
||||||
score_min_filter = request.args.get('score_min', '')
|
score_min_filter = request.args.get('score_min', '')
|
||||||
score_max_filter = request.args.get('score_max', '')
|
score_max_filter = request.args.get('score_max', '')
|
||||||
inspector_filter = request.args.get('inspector_id', '')
|
inspector_filter = request.args.get('inspector_id', '')
|
||||||
|
inspection_id_filter = request.args.get('inspection_id', '')
|
||||||
|
|
||||||
|
if inspection_id_filter.isdigit():
|
||||||
|
q = q.filter(Inspection.id == int(inspection_id_filter))
|
||||||
if status_filter == 'follow_up':
|
if status_filter == 'follow_up':
|
||||||
q = q.filter(
|
q = q.filter(
|
||||||
Inspection.follow_up_required == True,
|
Inspection.follow_up_required == True,
|
||||||
@@ -334,6 +337,7 @@ def index():
|
|||||||
score_min_filter=score_min_filter,
|
score_min_filter=score_min_filter,
|
||||||
score_max_filter=score_max_filter,
|
score_max_filter=score_max_filter,
|
||||||
inspector_filter=inspector_filter,
|
inspector_filter=inspector_filter,
|
||||||
|
inspection_id_filter=inspection_id_filter,
|
||||||
now=now_eastern())
|
now=now_eastern())
|
||||||
|
|
||||||
|
|
||||||
@@ -1004,15 +1008,18 @@ def export_list_pdf():
|
|||||||
else:
|
else:
|
||||||
q = q.filter(Inspection.facility_id.in_(customer_facility_ids))
|
q = q.filter(Inspection.facility_id.in_(customer_facility_ids))
|
||||||
|
|
||||||
status_filter = request.args.get('status', '')
|
status_filter = request.args.get('status', '')
|
||||||
facility_filter = request.args.get('facility_id', '')
|
facility_filter = request.args.get('facility_id', '')
|
||||||
contract_filter = request.args.get('contract_id', '')
|
contract_filter = request.args.get('contract_id', '')
|
||||||
date_from_filter = request.args.get('date_from', '')
|
date_from_filter = request.args.get('date_from', '')
|
||||||
date_to_filter = request.args.get('date_to', '')
|
date_to_filter = request.args.get('date_to', '')
|
||||||
score_min_filter = request.args.get('score_min', '')
|
score_min_filter = request.args.get('score_min', '')
|
||||||
score_max_filter = request.args.get('score_max', '')
|
score_max_filter = request.args.get('score_max', '')
|
||||||
inspector_filter = request.args.get('inspector_id', '')
|
inspector_filter = request.args.get('inspector_id', '')
|
||||||
|
inspection_id_filter = request.args.get('inspection_id', '')
|
||||||
|
|
||||||
|
if inspection_id_filter.isdigit():
|
||||||
|
q = q.filter(Inspection.id == int(inspection_id_filter))
|
||||||
if status_filter == 'follow_up':
|
if status_filter == 'follow_up':
|
||||||
q = q.filter(
|
q = q.filter(
|
||||||
Inspection.follow_up_required == True,
|
Inspection.follow_up_required == True,
|
||||||
@@ -1058,6 +1065,8 @@ def export_list_pdf():
|
|||||||
|
|
||||||
# Build a human-readable filter summary for the PDF header
|
# Build a human-readable filter summary for the PDF header
|
||||||
filter_parts = []
|
filter_parts = []
|
||||||
|
if inspection_id_filter.isdigit():
|
||||||
|
filter_parts.append(f'Inspection #: {inspection_id_filter}')
|
||||||
if status_filter:
|
if status_filter:
|
||||||
label = {'follow_up': 'Flagged Follow-up', 'has_issues': 'Has Issues'}.get(
|
label = {'follow_up': 'Flagged Follow-up', 'has_issues': 'Has Issues'}.get(
|
||||||
status_filter, status_filter.replace('_', ' ').title()
|
status_filter, status_filter.replace('_', ' ').title()
|
||||||
|
|||||||
@@ -15,6 +15,11 @@
|
|||||||
<div class="card-body py-2">
|
<div class="card-body py-2">
|
||||||
<form method="get">
|
<form method="get">
|
||||||
<div class="row g-2 align-items-end">
|
<div class="row g-2 align-items-end">
|
||||||
|
<div class="col-md-1">
|
||||||
|
<label class="form-label small mb-1">Inspection #</label>
|
||||||
|
<input type="number" name="inspection_id" class="form-control form-control-sm"
|
||||||
|
min="1" placeholder="ID" value="{{ inspection_id_filter }}">
|
||||||
|
</div>
|
||||||
<div class="col-md-2">
|
<div class="col-md-2">
|
||||||
<label class="form-label small mb-1">Status</label>
|
<label class="form-label small mb-1">Status</label>
|
||||||
<select name="status" class="form-select form-select-sm">
|
<select name="status" class="form-select form-select-sm">
|
||||||
@@ -100,7 +105,7 @@
|
|||||||
<table class="table table-hover mb-0">
|
<table class="table table-hover mb-0">
|
||||||
<thead class="table-light">
|
<thead class="table-light">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Date</th><th>Contract</th><th>Facility</th><th>Area</th>
|
<th>#</th><th>Date</th><th>Contract</th><th>Facility</th><th>Area</th>
|
||||||
<th>Template</th><th>Inspector</th><th>Score</th>
|
<th>Template</th><th>Inspector</th><th>Score</th>
|
||||||
<th>Status</th><th></th>
|
<th>Status</th><th></th>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -108,6 +113,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
{% for ins in inspections.items %}
|
{% for ins in inspections.items %}
|
||||||
<tr>
|
<tr>
|
||||||
|
<td><small class="text-muted">#{{ ins.id }}</small></td>
|
||||||
<td>{{ ins.inspection_date.strftime('%Y-%m-%d %H:%M') }}</td>
|
<td>{{ ins.inspection_date.strftime('%Y-%m-%d %H:%M') }}</td>
|
||||||
<td><small>{{ ins.facility.project.name if ins.facility and ins.facility.project else '—' }}</small></td>
|
<td><small>{{ ins.facility.project.name if ins.facility and ins.facility.project else '—' }}</small></td>
|
||||||
<td>{{ ins.facility.name }}</td>
|
<td>{{ ins.facility.name }}</td>
|
||||||
@@ -169,7 +175,7 @@
|
|||||||
{% for p in inspections.iter_pages(left_edge=1, right_edge=1, left_current=2, right_current=2) %}
|
{% for p in inspections.iter_pages(left_edge=1, right_edge=1, left_current=2, right_current=2) %}
|
||||||
{% if p %}
|
{% if p %}
|
||||||
<li class="page-item {{ 'active' if p == inspections.page }}">
|
<li class="page-item {{ 'active' if p == inspections.page }}">
|
||||||
<a class="page-link" href="{{ url_for('inspections.index', page=p, status=status_filter, contract_id=contract_filter, facility_id=facility_filter, date_from=date_from_filter, date_to=date_to_filter, score_min=score_min_filter, score_max=score_max_filter, inspector_id=inspector_filter) }}">{{ p }}</a>
|
<a class="page-link" href="{{ url_for('inspections.index', page=p, inspection_id=inspection_id_filter, status=status_filter, contract_id=contract_filter, facility_id=facility_filter, date_from=date_from_filter, date_to=date_to_filter, score_min=score_min_filter, score_max=score_max_filter, inspector_id=inspector_filter) }}">{{ p }}</a>
|
||||||
</li>
|
</li>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li class="page-item disabled"><span class="page-link">…</span></li>
|
<li class="page-item disabled"><span class="page-link">…</span></li>
|
||||||
|
|||||||
@@ -92,6 +92,7 @@
|
|||||||
<table class="table table-hover mb-0">
|
<table class="table table-hover mb-0">
|
||||||
<thead class="table-light">
|
<thead class="table-light">
|
||||||
<tr>
|
<tr>
|
||||||
|
<th>#</th>
|
||||||
<th>Reported</th>
|
<th>Reported</th>
|
||||||
<th>Severity</th>
|
<th>Severity</th>
|
||||||
<th>Contract</th>
|
<th>Contract</th>
|
||||||
@@ -108,6 +109,7 @@
|
|||||||
{% set is_following = issue.id in followed_ids %}
|
{% set is_following = issue.id in followed_ids %}
|
||||||
{% set sla = sla_status(issue) %}
|
{% set sla = sla_status(issue) %}
|
||||||
<tr class="{{ 'table-danger' if sla == 'breached' else 'table-warning' if sla == 'at_risk' else '' }}">
|
<tr class="{{ 'table-danger' if sla == 'breached' else 'table-warning' if sla == 'at_risk' else '' }}">
|
||||||
|
<td><small class="text-muted">#{{ issue.id }}</small></td>
|
||||||
<td><small>{{ issue.reported_at.strftime('%Y-%m-%d %H:%M') }}</small></td>
|
<td><small>{{ issue.reported_at.strftime('%Y-%m-%d %H:%M') }}</small></td>
|
||||||
<td>
|
<td>
|
||||||
<span class="badge bg-{{ 'danger' if issue.severity in ['critical','high'] else 'warning text-dark' if issue.severity == 'medium' else 'secondary' }}">
|
<span class="badge bg-{{ 'danger' if issue.severity in ['critical','high'] else 'warning text-dark' if issue.severity == 'medium' else 'secondary' }}">
|
||||||
|
|||||||
Reference in New Issue
Block a user