[events] Respect backup assignment
This commit is contained in:
parent
d75574e078
commit
51a3a8dfc8
|
@ -195,11 +195,14 @@ def create_event(event_type, start, end=None, jobs=[], is_template=None, name=No
|
||||||
raise BadRequest
|
raise BadRequest
|
||||||
|
|
||||||
|
|
||||||
def get_job(job_slot_id, event_id):
|
def get_job(job_id, event_id=None) -> Job:
|
||||||
js = Job.query.filter(Job.id == job_slot_id).filter(Job.event_id_ == event_id).one_or_none()
|
query = Job.query.filter(Job.id == job_id)
|
||||||
if js is None:
|
if event_id is not None:
|
||||||
|
query = query.filter(Job.event_id_ == event_id)
|
||||||
|
job = query.one_or_none()
|
||||||
|
if job is None:
|
||||||
raise NotFound
|
raise NotFound
|
||||||
return js
|
return job
|
||||||
|
|
||||||
|
|
||||||
def add_job(event, job_type, required_services, start, end=None, comment=None):
|
def add_job(event, job_type, required_services, start, end=None, comment=None):
|
||||||
|
@ -233,13 +236,13 @@ def delete_job(job: Job):
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
|
||||||
def assign_job(job: Job, user, value):
|
def assign_job(job: Job, user, value, is_backup=False):
|
||||||
assert value > 0
|
assert value > 0
|
||||||
service = Service.query.get((job.id, user.id_))
|
service = Service.query.get((job.id, user.id_))
|
||||||
if service:
|
if service:
|
||||||
service.value = value
|
service.value = value
|
||||||
else:
|
else:
|
||||||
service = Service(user_=user, value=value, job_=job)
|
service = Service(user_=user, value=value, is_backup=is_backup, job_=job)
|
||||||
db.session.add(service)
|
db.session.add(service)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue