Initial commit.
This commit is contained in:
commit
189f73b7c2
34 changed files with 1064 additions and 0 deletions
35
models/work_log.py
Normal file
35
models/work_log.py
Normal file
|
@ -0,0 +1,35 @@
|
|||
from typing import Optional, TYPE_CHECKING
|
||||
if TYPE_CHECKING:
|
||||
from .inventory import Inventory
|
||||
from .inventory import User
|
||||
|
||||
from sqlalchemy import Boolean, ForeignKeyConstraint, Identity, Integer, ForeignKey, Unicode, text
|
||||
from sqlalchemy.dialects.mssql import DATETIME2
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
import datetime
|
||||
|
||||
from . import db
|
||||
|
||||
class WorkLog(db.Model):
|
||||
__tablename__ = 'Work Log'
|
||||
__table_args__ = (
|
||||
ForeignKeyConstraint(['Work Item'], ['Inventory.ID'], name='Work Log$InventoryWork Log'),
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column("ID", Integer, Identity(start=1, increment=1), primary_key=True)
|
||||
start_time: Mapped[Optional[datetime.datetime]] = mapped_column('Start Timestamp', DATETIME2)
|
||||
end_time: Mapped[Optional[datetime.datetime]] = mapped_column('End Timestamp', DATETIME2)
|
||||
notes: Mapped[Optional[str]] = mapped_column('Description & Notes', Unicode())
|
||||
complete: Mapped[Optional[bool]] = mapped_column("Complete", Boolean, server_default=text('((0))'))
|
||||
followup: Mapped[Optional[bool]] = mapped_column('Needs Follow-Up', Boolean, server_default=text('((0))'))
|
||||
contact_id: Mapped[Optional[int]] = mapped_column('Point of Contact', Integer, ForeignKey("Users.ID"))
|
||||
analysis: Mapped[Optional[bool]] = mapped_column('Needs Quick Analysis', Boolean, server_default=text('((0))'))
|
||||
work_item_id: Mapped[Optional[int]] = mapped_column("Work Item", Integer, ForeignKey("Inventory.ID"))
|
||||
|
||||
work_item: Mapped[Optional['Inventory']] = relationship('Inventory', back_populates='work_logs')
|
||||
contact: Mapped[Optional['User']] = relationship('User', back_populates='work_logs')
|
||||
|
||||
def __repr__(self):
|
||||
return f"<WorkLog(id={self.id}, start_time={self.start_time}, end_time={self.end_time}, " \
|
||||
f"notes={repr(self.notes)}, complete={self.complete}, followup={self.followup}, " \
|
||||
f"contact_id={self.contact_id}, analysis={self.analysis}, work_item_id={self.work_item_id})>"
|
Loading…
Add table
Add a link
Reference in a new issue