def __init__(self, wf_module: 'WfModule',
                 old_result: Optional[ProcessResult],
                 new_result: ProcessResult):
        workflow = wf_module.workflow

        self.user = workflow.owner
        self.workflow_name = workflow.name
        self.wf_module_id = wf_module.id
        self.module_name = wf_module.module_id_name
        self.workflow_url = get_absolute_url(workflow.get_absolute_url())
        self.old_result = old_result
        self.new_result = new_result
Exemple #2
0
def email_notification(user, wfm):
    ctx = {
        'user_name': user_display(user),
        'workflow_name': wfm.workflow.name,
        'workflow_url': get_absolute_url(wfm.workflow.get_absolute_url()),
        'date': wfm.stored_data_version.strftime('%b %-d, %Y at %-I:%M %p')
    }
    subject = render_to_string("notifications/new_data_version_subject.txt",
                               ctx)
    subject = "".join(subject.splitlines())
    message = render_to_string("notifications/new_data_version.txt", ctx)
    mail = EmailMultiAlternatives(subject=subject,
                                  body=message,
                                  from_email=settings.DEFAULT_FROM_EMAIL,
                                  to=[user.email])
    mail.attach_alternative(message, "text/html")
    mail.send()
 def workflow_url(self) -> str:
     return get_absolute_url(self.workflow.get_absolute_url())