Implement work log creation and update API; add new worklog entry route and enhance worklog template with JavaScript functionality
This commit is contained in:
parent
146dcafab3
commit
bb564809ea
5 changed files with 209 additions and 33 deletions
|
@ -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")
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue