Adding some enhancements.
This commit is contained in:
parent
013d1c0bd5
commit
a8b07eb115
4 changed files with 24 additions and 9 deletions
|
|
@ -1,6 +1,7 @@
|
|||
from typing import List, Optional, TYPE_CHECKING
|
||||
|
||||
from sqlalchemy import Boolean, Integer, ForeignKey, Unicode
|
||||
from sqlalchemy import Boolean, Integer, ForeignKey, Unicode, func
|
||||
from sqlalchemy.ext.hybrid import hybrid_property
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from sqlalchemy.sql import expression as sql
|
||||
|
||||
|
|
@ -37,3 +38,11 @@ class User(Base, CRUDMixin):
|
|||
|
||||
def __repr__(self):
|
||||
return f"<User(id={self.id}, first_name={repr(self.first_name)}, last_name={repr(self.last_name)})>"
|
||||
|
||||
@hybrid_property
|
||||
def label(self):
|
||||
return f"{self.first_name} {self.last_name}"
|
||||
|
||||
@label.expression
|
||||
def label(cls):
|
||||
return func.concat(cls.first_name, " ", cls.last_name)
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@ def init_index_routes(app):
|
|||
"complete__ne": 1,
|
||||
"fields": [
|
||||
"start_time",
|
||||
"contact.last_name",
|
||||
"contact.first_name",
|
||||
"contact.label",
|
||||
"work_item.label",
|
||||
"work_item.device_type.description"
|
||||
],
|
||||
|
|
@ -30,7 +29,7 @@ def init_index_routes(app):
|
|||
|
||||
columns = [
|
||||
{"field": "start_time", "label": "Start", "format": "date"},
|
||||
{"field": "contact.last_name", "label": "Contact",
|
||||
{"field": "contact.label", "label": "Contact",
|
||||
"link": {"endpoint": "user.get_item", "params": {"id": "{contact.id}"}}},
|
||||
{"field": "work_item.label", "label": "Work Item",
|
||||
"link": {"endpoint": "inventory.get_item", "params": {"id": "{work_item.id}"}}},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue