Renaming type relationship to device_type.
This commit is contained in:
parent
c93aa973bf
commit
1aee318853
4 changed files with 6 additions and 6 deletions
|
@ -42,7 +42,7 @@ class Inventory(db.Model, ImageAttachable):
|
|||
# item: Mapped['Item'] = relationship('Item', back_populates='inventory')
|
||||
work_logs: Mapped[List['WorkLog']] = relationship('WorkLog', back_populates='work_item')
|
||||
image: Mapped[Optional['Image']] = relationship('Image', back_populates='inventory', passive_deletes=True)
|
||||
type: Mapped[Optional['Item']] = relationship('Item', back_populates='inventory')
|
||||
device_type: Mapped[Optional['Item']] = relationship('Item', back_populates='inventory')
|
||||
|
||||
def __init__(self, timestamp: datetime.datetime, condition: str, type_id: Optional[int] = None,
|
||||
name: Optional[str] = None, serial: Optional[str] = None,
|
||||
|
@ -68,8 +68,8 @@ class Inventory(db.Model, ImageAttachable):
|
|||
if self.name:
|
||||
parts.append(f"name={repr(self.name)}")
|
||||
|
||||
if self.type:
|
||||
parts.append(f"item={repr(self.type.description)}")
|
||||
if self.device_type:
|
||||
parts.append(f"item={repr(self.device_type.description)}")
|
||||
|
||||
if self.notes:
|
||||
parts.append(f"notes={repr(self.notes)}")
|
||||
|
|
|
@ -16,7 +16,7 @@ class Item(ValidatableMixin, db.Model):
|
|||
id: Mapped[int] = mapped_column(Integer, Identity(start=1, increment=1), primary_key=True)
|
||||
description: Mapped[Optional[str]] = mapped_column(Unicode(255), nullable=True)
|
||||
|
||||
inventory: Mapped[List['Inventory']] = relationship('Inventory', back_populates='type')
|
||||
inventory: Mapped[List['Inventory']] = relationship('Inventory', back_populates='device_type')
|
||||
|
||||
def __init__(self, description: Optional[str] = None):
|
||||
self.description = description
|
||||
|
|
|
@ -18,7 +18,7 @@ inventory_headers = {
|
|||
"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.type.description} if i.type else {"text": None},
|
||||
"Item Type": lambda i: {"text": i.device_type.description} if i.device_type 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.identifier, "url": url_for("main.user", id=i.owner.id)} if i.owner else {"text": None},
|
||||
"Location": lambda i: {"text": i.location.identifier} if i.location else {"Text": None},
|
||||
|
|
|
@ -12,7 +12,7 @@ def eager_load_inventory_relationships(query):
|
|||
return query.options(
|
||||
joinedload(Inventory.owner),
|
||||
joinedload(Inventory.brand),
|
||||
joinedload(Inventory.type),
|
||||
joinedload(Inventory.device_type),
|
||||
selectinload(Inventory.location).selectinload(Room.room_function)
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue