Implement work log creation and update API; add new worklog entry route and enhance worklog template with JavaScript functionality

This commit is contained in:
Yaro Kasear 2025-07-08 09:55:25 -05:00
parent 146dcafab3
commit bb564809ea
5 changed files with 209 additions and 33 deletions

View file

@ -1,4 +1,4 @@
from typing import Optional, TYPE_CHECKING
from typing import Optional, Any, TYPE_CHECKING
if TYPE_CHECKING:
from .inventory import Inventory
from .users import User
@ -57,4 +57,20 @@ class WorkLog(db.Model):
'contact_id': self.contact_id,
'analysis': self.analysis,
'work_item_id': self.work_item_id
}
}
@classmethod
def from_dict(cls, data: dict[str, Any]) -> "WorkLog":
start_time_str = data.get("start_time")
end_time_str = data.get("end_time")
return cls(
start_time=datetime.datetime.fromisoformat(str(start_time_str)) if start_time_str else datetime.datetime.now(),
end_time=datetime.datetime.fromisoformat(str(end_time_str)) if end_time_str else None,
notes=data.get("notes"),
complete=bool(data.get("complete", False)),
followup=bool(data.get("followup", False)),
analysis=bool(data.get("analysis", False)),
contact_id=data.get("contact_id"),
work_item_id=data.get("work_item_id")
)