[plugin] schedule: Allow ID for types (e.g. creating new events)
This commit is contained in:
parent
a476e4f5b1
commit
02959587e1
|
@ -1,7 +1,7 @@
|
|||
from __future__ import annotations # TODO: Remove if python requirement is >= 3.10
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
from typing import Optional, Union
|
||||
|
||||
from sqlalchemy import UniqueConstraint
|
||||
|
||||
|
@ -55,8 +55,8 @@ class Job(db.Model, ModelSerializeMixin):
|
|||
id: int = db.Column(db.Integer, primary_key=True)
|
||||
start: datetime = db.Column(UtcDateTime, nullable=False)
|
||||
end: Optional[datetime] = db.Column(UtcDateTime)
|
||||
comment: str = db.Column(db.String(256))
|
||||
type: JobType = db.relationship("JobType")
|
||||
type: Union[JobType, int] = db.relationship("JobType")
|
||||
comment: Optional[str] = db.Column(db.String(256))
|
||||
services: list[Service] = db.relationship("Service", back_populates="job_")
|
||||
required_services: float = db.Column(db.Numeric(precision=4, scale=2, asdecimal=False), nullable=False)
|
||||
|
||||
|
@ -82,7 +82,7 @@ class Event(db.Model, ModelSerializeMixin):
|
|||
start: datetime = db.Column(UtcDateTime, nullable=False)
|
||||
end: Optional[datetime] = db.Column(UtcDateTime)
|
||||
description: Optional[str] = db.Column(db.String(255))
|
||||
type: EventType = db.relationship("EventType")
|
||||
type: Union[EventType, int] = db.relationship("EventType")
|
||||
jobs: list[Job] = db.relationship(
|
||||
"Job", back_populates="event_", cascade="all,delete,delete-orphan", order_by="[Job.start, Job.end]"
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue