Coverage for portality / notifications / application_emails.py: 0%
39 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-05-05 00:09 +0100
« prev ^ index » next coverage.py v7.13.5, created at 2026-05-05 00:09 +0100
1# ~~ Email:Notifications~~
2from flask import url_for
3import json
5from portality import models, app_email, constants
6from portality.core import app
7from portality.dao import Facetview2
8from portality.ui.messages import Messages
9from portality.lib import dates
10from portality.ui import templates
13def send_editor_completed_email(application):
14 """ inform the editor in charge of an application that it has been completed by an associate editor """
15 journal_name = application.bibjson().title
16 url_root = app.config.get("BASE_URL")
17 query_for_id = Facetview2.make_query(query_string=application.id)
18 string_id_query = json.dumps(query_for_id).replace(' ', '') # Avoid '+' being added to URLs by removing spaces
19 url_for_application = url_root + url_for("editor.group_suggestions", source=string_id_query)
21 # This is to the editor in charge of this application's assigned editor group
22 editor_group_name = application.editor_group
23 editor_group_id = models.EditorGroup.group_exists_by_name(name=editor_group_name)
24 editor_group = models.EditorGroup.pull(editor_group_id)
25 editor_acc = editor_group.get_editor_account()
27 editor_id = editor_acc.id
28 to = [editor_acc.email]
29 fro = app.config.get('SYSTEM_EMAIL_FROM', 'helpdesk@doaj.org')
30 subject = app.config.get("SERVICE_NAME", "") + " - application marked 'completed'"
32 # The status change will have come from the associate editor assigned to the journal
33 assoc_id = application.editor
35 app_email.send_mail(to=to,
36 fro=fro,
37 subject=subject,
38 template_name=templates.EMAIL_EDITOR_APPLICATION_COMPLETED,
39 editor=editor_id,
40 associate_editor=assoc_id,
41 application_title=journal_name,
42 url_for_application=url_for_application)
45def send_account_created_email(account):
46 reset_url = url_for('account.reset', reset_token=account.reset_token, _external=True)
47 forgot_pw_url = url_for('account.forgot', _external=True)
49 password_create_timeout_seconds = int(
50 app.config.get("PASSWORD_CREATE_TIMEOUT", app.config.get('PASSWORD_RESET_TIMEOUT', 86400) * 14))
51 password_create_timeout_days = password_create_timeout_seconds / (60 * 60 * 24)
53 to = [account.email]
54 fro = app.config.get('SYSTEM_EMAIL_FROM', 'helpdesk@doaj.org')
55 subject = app.config.get("SERVICE_NAME", "") + " - account created, please verify your email address"
57 app_email.send_mail(to=to,
58 fro=fro,
59 subject=subject,
60 template_name=templates.EMAIL_ACCOUNT_CREATED,
61 reset_url=reset_url,
62 email=account.email,
63 timeout_days=password_create_timeout_days,
64 forgot_pw_url=forgot_pw_url
65 )
68def send_account_password_reset_email(account):
69 reset_url = url_for('account.reset', reset_token=account.reset_token, _external=True)
71 to = [account.email]
72 fro = app.config.get('SYSTEM_EMAIL_FROM', app.config['ADMIN_EMAIL'])
73 subject = app.config.get("SERVICE_NAME", "") + " - password reset"
75 app_email.send_mail(to=to,
76 fro=fro,
77 subject=subject,
78 template_name=templates.EMAIL_PASSWORD_RESET,
79 email=account.email,
80 reset_url=reset_url,
81 forgot_pw_url=url_for('account.forgot', _external=True)
82 )