mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-06-22 05:50:34 +00:00
handle email job status updates with the sqlalchemy event handlers
This commit is contained in:
@ -1,8 +1,7 @@
|
||||
from datetime import datetime
|
||||
from flask import current_app
|
||||
from werkzeug.utils import secure_filename
|
||||
from .. import db, mail
|
||||
from ..email import create_message
|
||||
from .. import db
|
||||
from ..models import Job, JobResult
|
||||
import docker
|
||||
import json
|
||||
@ -105,8 +104,6 @@ class CheckJobsMixin:
|
||||
return
|
||||
else:
|
||||
job.status = 'queued'
|
||||
finally:
|
||||
self.send_job_notification(job)
|
||||
|
||||
def checkout_job_service(self, job):
|
||||
service_name = 'job_{}'.format(job.id)
|
||||
@ -162,8 +159,6 @@ class CheckJobsMixin:
|
||||
db.session.refresh(job_result)
|
||||
job.end_date = datetime.utcnow()
|
||||
job.status = task_state
|
||||
finally:
|
||||
self.send_job_notification(job)
|
||||
|
||||
def remove_job_service(self, job):
|
||||
service_name = 'job_{}'.format(job.id)
|
||||
@ -203,17 +198,3 @@ class CheckJobsMixin:
|
||||
+ '"docker.errors.APIError" The server returned an error. '
|
||||
+ 'Details: {}'.format(e)
|
||||
)
|
||||
|
||||
def send_job_notification(self, job):
|
||||
if job.creator.setting_job_status_mail_notifications == 'none':
|
||||
return
|
||||
if (job.creator.setting_job_status_mail_notifications == 'end'
|
||||
and job.status not in ['complete', 'failed']):
|
||||
return
|
||||
msg = create_message(
|
||||
job.creator.email,
|
||||
'Status update for your Job "{}"'.format(job.title),
|
||||
'tasks/email/notification',
|
||||
job=job
|
||||
)
|
||||
mail.send(msg)
|
||||
|
Reference in New Issue
Block a user