Refactor worklog handling and rendering; enhance active worklog display and add settings page with brand management functionality
This commit is contained in:
parent
3915b97231
commit
e2b8579362
9 changed files with 145 additions and 42 deletions
42
routes.py
42
routes.py
|
@ -61,7 +61,7 @@ worklog_headers = {
|
|||
"Start Time": lambda i: {"text": i.start_time.strftime("%Y-%m-%d")},
|
||||
"End Time": lambda i: {"text": i.end_time.strftime("%Y-%m-%d")} if i.end_time else {"text": None},
|
||||
"Complete?": lambda i: {"text": i.complete, "type": "bool", "html": checked_box if i.complete else unchecked_box},
|
||||
"Follow Up?": lambda i: {"text": i.followup, "type": "bool", "html": checked_box if i.followup else unchecked_box},
|
||||
"Follow Up?": lambda i: {"text": i.followup, "type": "bool", "html": checked_box if i.followup else unchecked_box, "highlight": i.followup},
|
||||
"Quick Analysis?": lambda i: {"text": i.analysis, "type": "bool", "html": checked_box if i.analysis else unchecked_box},
|
||||
}
|
||||
|
||||
|
@ -136,13 +136,13 @@ def index():
|
|||
worklog_query = eager_load_worklog_relationships(
|
||||
db.session.query(WorkLog)
|
||||
).filter(
|
||||
(WorkLog.start_time < cutoff) & (WorkLog.complete == False)
|
||||
(WorkLog.complete == False)
|
||||
)
|
||||
|
||||
stale_worklogs = worklog_query.all()
|
||||
active_worklogs = worklog_query.all()
|
||||
|
||||
stale_count = len(stale_worklogs)
|
||||
stale_worklog_headers = {
|
||||
active_count = len(active_worklogs)
|
||||
active_worklog_headers = {
|
||||
k: v for k, v in worklog_headers.items()
|
||||
if k not in ['End Time', 'Quick Analysis?', 'Complete?', 'Follow Up?']
|
||||
}
|
||||
|
@ -179,15 +179,28 @@ def index():
|
|||
'name': 'Inventory Conditions'
|
||||
}]
|
||||
|
||||
active_worklog_rows = []
|
||||
for log in active_worklogs:
|
||||
# Create a dictionary of {column name: cell dict}
|
||||
cells_by_key = {k: fn(log) for k, fn in worklog_headers.items()}
|
||||
|
||||
# Use original, full header set for logic
|
||||
highlight = cells_by_key.get("Follow Up?", {}).get("highlight", False)
|
||||
|
||||
# Use only filtered headers — and in exact order
|
||||
cells = [cells_by_key[k] for k in active_worklog_headers]
|
||||
|
||||
active_worklog_rows.append({
|
||||
"id": log.id,
|
||||
"cells": cells,
|
||||
"highlight": highlight
|
||||
})
|
||||
|
||||
return render_template(
|
||||
"index.html",
|
||||
title="Inventory Manager",
|
||||
stale_count=stale_count,
|
||||
stale_worklog_headers=stale_worklog_headers,
|
||||
stale_worklog_rows=[{
|
||||
"id": log.id,
|
||||
"cells": [fn(log) for fn in stale_worklog_headers.values()]
|
||||
} for log in stale_worklogs],
|
||||
active_count=active_count,
|
||||
active_worklog_headers=active_worklog_headers,
|
||||
active_worklog_rows=active_worklog_rows,
|
||||
labels=labels,
|
||||
datasets=datasets
|
||||
)
|
||||
|
@ -416,3 +429,8 @@ def search():
|
|||
}
|
||||
|
||||
return render_template('search.html', title=f"Database Search ({query})" if query else "Database Search", results=results, query=query)
|
||||
|
||||
@main.route('/settings')
|
||||
def settings():
|
||||
brands = db.session.query(Brand).order_by(Brand.name).all()
|
||||
return render_template('settings.html', title="Settings", brands=brands)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue