Remove obsolete junk.

This commit is contained in:
Yaro Kasear 2025-09-08 10:12:57 -05:00
parent 559fd56f33
commit 11673eb515
4 changed files with 8 additions and 42 deletions

View file

@ -7,17 +7,11 @@ class CrudMixin:
id = Column(Integer, primary_key=True) id = Column(Integer, primary_key=True)
created_at = Column(DateTime, default=dt.datetime.utcnow, nullable=False) created_at = Column(DateTime, default=dt.datetime.utcnow, nullable=False)
updated_at = Column(DateTime, default=dt.datetime.utcnow, onupdate=dt.datetime.utcnow, nullable=False) updated_at = Column(DateTime, default=dt.datetime.utcnow, onupdate=dt.datetime.utcnow, nullable=False)
deleted = Column("deleted", Boolean, default=False, nullable=False) is_deleted = Column(Boolean, default=False, nullable=False)
version = Column(Integer, default=1, nullable=False)
@hybrid_property @hybrid_property
def is_deleted(self): def is_deleted(self):
return self.deleted return self.is_deleted
def mark_deleted(self): def mark_deleted(self):
self.deleted = True self.is_deleted = True
self.version += 1
@declared_attr
def __mapper_args__(cls):
return {"version_id_col": cls.version}

View file

@ -21,11 +21,11 @@ class WorkLog(db.Model, ImageAttachable, CrudMixin):
id: Mapped[int] = mapped_column(Integer, Identity(start=1, increment=1), primary_key=True) id: Mapped[int] = mapped_column(Integer, Identity(start=1, increment=1), primary_key=True)
start_time: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime) start_time: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime)
end_time: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime) end_time: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime)
notes: Mapped[Optional[str]] = mapped_column(Unicode()) # notes: Mapped[Optional[str]] = mapped_column(Unicode())
complete: Mapped[Optional[bool]] = mapped_column(Boolean, server_default=text('((0))')) complete: Mapped[Optional[bool]] = mapped_column(Boolean, server_default=text('((0))'))
followup: Mapped[Optional[bool]] = mapped_column(Boolean, server_default=text('((0))')) # followup: Mapped[Optional[bool]] = mapped_column(Boolean, server_default=text('((0))'))
contact_id: Mapped[Optional[int]] = mapped_column(Integer, ForeignKey("users.id"), nullable=True, index=True) contact_id: Mapped[Optional[int]] = mapped_column(Integer, ForeignKey("users.id"), nullable=True, index=True)
analysis: Mapped[Optional[bool]] = mapped_column(Boolean, server_default=text('((0))')) # analysis: Mapped[Optional[bool]] = mapped_column(Boolean, server_default=text('((0))'))
work_item_id: Mapped[Optional[int]] = mapped_column(Integer, ForeignKey("inventory.id"), nullable=True, index=True) work_item_id: Mapped[Optional[int]] = mapped_column(Integer, ForeignKey("inventory.id"), nullable=True, index=True)
work_item: Mapped[Optional['Inventory']] = relationship('Inventory', back_populates='work_logs') work_item: Mapped[Optional['Inventory']] = relationship('Inventory', back_populates='work_logs')
@ -42,28 +42,22 @@ class WorkLog(db.Model, ImageAttachable, CrudMixin):
self, self,
start_time: Optional[datetime.datetime] = None, start_time: Optional[datetime.datetime] = None,
end_time: Optional[datetime.datetime] = None, end_time: Optional[datetime.datetime] = None,
notes: Optional[str] = None,
complete: Optional[bool] = False, complete: Optional[bool] = False,
followup: Optional[bool] = False,
contact_id: Optional[int] = None, contact_id: Optional[int] = None,
analysis: Optional[bool] = False,
work_item_id: Optional[int] = None, work_item_id: Optional[int] = None,
updates: Optional[List[WorkNote]] = None updates: Optional[List[WorkNote]] = None
) -> None: ) -> None:
self.start_time = start_time self.start_time = start_time
self.end_time = end_time self.end_time = end_time
self.notes = notes
self.complete = complete self.complete = complete
self.followup = followup
self.contact_id = contact_id self.contact_id = contact_id
self.analysis = analysis
self.work_item_id = work_item_id self.work_item_id = work_item_id
self.updates = updates or [] self.updates = updates or []
def __repr__(self): def __repr__(self):
return f"<WorkLog(id={self.id}, start_time={self.start_time}, end_time={self.end_time}, " \ 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"complete={self.complete}, " \
f"contact_id={self.contact_id}, analysis={self.analysis}, work_item_id={self.work_item_id})>" f"contact_id={self.contact_id}, work_item_id={self.work_item_id})>"
def serialize(self): def serialize(self):
return { return {

View file

@ -90,8 +90,6 @@ worklog_headers = {
"Start Time": lambda i: {"text": i.start_time.strftime("%Y-%m-%d")}, "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}, "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}, "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): def link(text, endpoint, **values):

View file

@ -21,8 +21,6 @@
start_time: document.querySelector("input[name='start']").value, start_time: document.querySelector("input[name='start']").value,
end_time: document.querySelector("input[name='end']").value, end_time: document.querySelector("input[name='end']").value,
complete: document.querySelector("input[name='complete']").checked, complete: document.querySelector("input[name='complete']").checked,
analysis: document.querySelector("input[name='analysis']").checked,
followup: document.querySelector("input[name='followup']").checked,
contact_id: parseInt(document.querySelector("input[name='contact']").value) || null, contact_id: parseInt(document.querySelector("input[name='contact']").value) || null,
work_item_id: parseInt(document.querySelector("input[name='item']").value) || null, work_item_id: parseInt(document.querySelector("input[name='item']").value) || null,
updates: updates updates: updates
@ -182,24 +180,6 @@
</label> </label>
</div> </div>
</div> </div>
<div class="row">
<div class="col">
<input type="checkbox" id="followup" class="form-check-input" name="followup" {% if log.followup %}
checked{% endif %}{% if log.complete %} disabled{% endif %}>
<label for="followup" class="form-check-label">
Follow Up?
</label>
</div>
</div>
<div class="row">
<div class="col">
<input type="checkbox" id="analysis" class="form-check-input" name="analysis" {% if log.analysis %}
checked{% endif %}{% if log.complete %} disabled{% endif %}>
<label for="analysis" class="form-check-label">
Quick Analysis?
</label>
</div>
</div>
</div> </div>
</div> </div>
<div class="container" id="updates-container"> <div class="container" id="updates-container">