From 02959587e188dd98dd1cbe84421d02439707716b Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Sat, 20 Mar 2021 01:00:55 +0100 Subject: [PATCH] [plugin] schedule: Allow ID for types (e.g. creating new events) --- flaschengeist/plugins/schedule/models.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/flaschengeist/plugins/schedule/models.py b/flaschengeist/plugins/schedule/models.py index 228ed0d..3b5993e 100644 --- a/flaschengeist/plugins/schedule/models.py +++ b/flaschengeist/plugins/schedule/models.py @@ -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]" )