[Plugin] schedule: Fixed set JobType by JSON.
This commit is contained in:
parent
a8c7ddae3d
commit
a4a9d05a31
|
@ -232,7 +232,10 @@ def _add_job(event, data):
|
||||||
|
|
||||||
if "required_services" not in data:
|
if "required_services" not in data:
|
||||||
raise BadRequest
|
raise BadRequest
|
||||||
job_type = event_controller.get_job_type(data["type"])
|
job_type = data["type"]
|
||||||
|
if isinstance(job_type, dict):
|
||||||
|
job_type = data["type"]["id"]
|
||||||
|
job_type = event_controller.get_job_type(job_type)
|
||||||
event_controller.add_job(event, job_type, data["required_services"], start, end, comment=data.get("comment"))
|
event_controller.add_job(event, job_type, data["required_services"], start, end, comment=data.get("comment"))
|
||||||
|
|
||||||
|
|
||||||
|
@ -261,7 +264,6 @@ def create_event(current_session):
|
||||||
except (NotFound, KeyError, ValueError):
|
except (NotFound, KeyError, ValueError):
|
||||||
raise BadRequest("Missing POST parameter")
|
raise BadRequest("Missing POST parameter")
|
||||||
|
|
||||||
data = request.get_json()
|
|
||||||
event = event_controller.create_event(
|
event = event_controller.create_event(
|
||||||
start=start, event_type=event_type, description=data["description"] if "description" in data else None
|
start=start, event_type=event_type, description=data["description"] if "description" in data else None
|
||||||
)
|
)
|
||||||
|
|
|
@ -19,8 +19,11 @@ def get_event_type(identifier):
|
||||||
|
|
||||||
if isinstance(identifier, int):
|
if isinstance(identifier, int):
|
||||||
et = EventType.query.get(identifier)
|
et = EventType.query.get(identifier)
|
||||||
else:
|
elif isinstance(identifier, str):
|
||||||
et = EventType.query.filter(EventType.name == identifier).one_or_none()
|
et = EventType.query.filter(EventType.name == identifier).one_or_none()
|
||||||
|
else:
|
||||||
|
logger.debug("Invalid identifier type for EventType")
|
||||||
|
raise BadRequest
|
||||||
if not et:
|
if not et:
|
||||||
raise NotFound
|
raise NotFound
|
||||||
return et
|
return et
|
||||||
|
|
Loading…
Reference in New Issue