Add routes and functionality for inventory management, user management, worklogs, and settings
- Created a new Blueprint for main routes in `routes/__init__.py`. - Implemented inventory listing and item management in `routes/inventory.py`. - Added user listing and detail views in `routes/user.py`. - Developed worklog listing and entry views in `routes/worklog.py`. - Introduced search functionality across inventory, users, and worklogs in `routes/search.py`. - Established settings management for brands, items, rooms, and functions in `routes/settings.py`. - Enhanced helper functions for rendering headers and managing data in `routes/helpers.py`. - Updated index route to display active worklogs and inventory conditions in `routes/index.py`.
This commit is contained in:
parent
4c36621eba
commit
4d8d5b4e6a
9 changed files with 684 additions and 630 deletions
78
routes/helpers.py
Normal file
78
routes/helpers.py
Normal file
|
@ -0,0 +1,78 @@
|
|||
from flask import url_for
|
||||
|
||||
from ..models import Inventory
|
||||
|
||||
inventory_headers = {
|
||||
"Date Entered": lambda i: {"text": i.timestamp.strftime("%Y-%m-%d") if i.timestamp else None},
|
||||
"Identifier": lambda i: {"text": i.identifier},
|
||||
"Inventory #": lambda i: {"text": i.inventory_name},
|
||||
"Serial #": lambda i: {"text": i.serial},
|
||||
"Bar Code #": lambda i: {"text": i.barcode},
|
||||
"Brand": lambda i: {"text": i.brand.name} if i.brand else {"text": None},
|
||||
"Model": lambda i: {"text": i.model},
|
||||
"Item Type": lambda i: {"text": i.item.description} if i.item else {"text": None},
|
||||
"Shared?": lambda i: {"text": i.shared, "type": "bool", "html": checked_box if i.shared else unchecked_box},
|
||||
"Owner": lambda i: {"text": i.owner.full_name, "url": url_for("main.user", id=i.owner.id)} if i.owner else {"text": None},
|
||||
"Location": lambda i: {"text": i.location.full_name} if i.location else {"Text": None},
|
||||
"Condition": lambda i: {"text": i.condition},
|
||||
# "Notes": lambda i: {"text": i.notes}
|
||||
}
|
||||
|
||||
checked_box = '''
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-check2" viewBox="0 0 16 16">
|
||||
<path d="M13.854 3.646a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708 0l-3.5-3.5a.5.5 0 1 1 .708-.708L6.5 10.293l6.646-6.647a.5.5 0 0 1 .708 0"/>
|
||||
</svg>
|
||||
'''
|
||||
unchecked_box = ''
|
||||
|
||||
ACTIVE_STATUSES = [
|
||||
"Working",
|
||||
"Deployed",
|
||||
"Partially Inoperable",
|
||||
"Unverified"
|
||||
]
|
||||
|
||||
INACTIVE_STATUSES = [
|
||||
"Inoperable",
|
||||
"Removed",
|
||||
"Disposed"
|
||||
]
|
||||
|
||||
FILTER_MAP = {
|
||||
'user': Inventory.owner_id,
|
||||
'location': Inventory.location_id,
|
||||
'type': Inventory.type_id,
|
||||
}
|
||||
|
||||
user_headers = {
|
||||
"Last Name": lambda i: {"text": i.last_name},
|
||||
"First Name": lambda i: {"text": i.first_name},
|
||||
"Supervisor": lambda i: {"text": i.supervisor.full_name, "url": url_for("main.user", id=i.supervisor.id)} if i.supervisor else {"text": None},
|
||||
"Location": lambda i: {"text": i.location.full_name} if i.location else {"text": None},
|
||||
"Staff?": lambda i: {"text": i.staff, "type": "bool", "html": checked_box if i.staff else unchecked_box},
|
||||
"Active?": lambda i: {"text": i.active, "type": "bool", "html": checked_box if i.active else unchecked_box}
|
||||
}
|
||||
|
||||
worklog_headers = {
|
||||
"Contact": lambda i: {"text": i.contact.full_name, "url": url_for("main.user", id=i.contact.id)} if i.contact else {"Text": None},
|
||||
"Work Item": lambda i: {"text": i.work_item.identifier, "url": url_for('main.inventory_item',id=i.work_item.id)} if i.work_item else {"text": None},
|
||||
"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, "highlight": i.followup},
|
||||
"Quick Analysis?": lambda i: {"text": i.analysis, "type": "bool", "html": checked_box if i.analysis else unchecked_box},
|
||||
}
|
||||
|
||||
worklog_form_fields = {
|
||||
"start": lambda log: {"label": "Start Timestamp", "type": "date", "value": log.start_time.date().isoformat() if log.start_time else ""},
|
||||
"end": lambda log: {"label": "End Timestamp", "type": "date", "value": log.end_time.date().isoformat() if log.end_time else ""},
|
||||
"contact": lambda log: {"label": "Contact", "type": "datalist", "value": log.contact.full_name if log.contact else "", "list": "contactList"},
|
||||
"item": lambda log: {"label": "Work Item", "type": "datalist", "value": log.work_item.identifier if log.work_item else "", "list": "itemList"},
|
||||
"complete": lambda log: {"label": "Complete?", "type": "checkbox", "value": log.complete},
|
||||
"followup": lambda log: {"label": "Follow Up?", "type": "checkbox", "value": log.followup},
|
||||
"analysis": lambda log: {"label": "Quick Analysis?", "type": "checkbox", "value": log.analysis},
|
||||
"notes": lambda log: {"label": "Notes", "type": "textarea", "value": log.notes or "", "rows": 15}
|
||||
}
|
||||
|
||||
def link(text, endpoint, **values):
|
||||
return {"text": text, "url": url_for(endpoint, **values)}
|
Loading…
Add table
Add a link
Reference in a new issue