65 lines
2.9 KiB
Python
65 lines
2.9 KiB
Python
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 = '''
|
|
<i class="bi bi-check2"></i>
|
|
'''
|
|
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},
|
|
}
|
|
|
|
def link(text, endpoint, **values):
|
|
return {"text": text, "url": url_for(endpoint, **values)}
|