Skip to content
Snippets Groups Projects
Commit ccc0e178 authored by Jan Mach's avatar Jan Mach
Browse files

More logging to better control where the registration confirmation emails are sent to.

(Redmine issue: #7106)
parent 6b4870df
No related branches found
No related tags found
No related merge requests found
......@@ -47,6 +47,9 @@
<th>
{{ _('State') }}
</th>
<th>
{{ _('Managed') }}
</th>
<th data-toggle="tooltip" title="{{ _('Contextual item actions') }}">
{{ get_icon('actions') }} {{ _('Actions') }}
</th>
......@@ -67,6 +70,9 @@
<td>
{{ macros_site.render_label_item_state(item.enabled, True) }}
</td>
<td>
{{ macros_site.render_label_item_state(item.managed, True) }}
</td>
<td class="column-actions">
{{ macros_page.render_menu_context_actions(item) }}
</td>
......
......@@ -1942,6 +1942,11 @@ class BaseRegisterView(ItemCreateView): # pylint: disable=locally-disabled,abst
Send information about new account registration to system
admins. Use default locale for email content translations.
"""
flask.current_app.logger.info(
"Attempting to send information about registration of new account '{}' to system admins @: '{}'.".format(
account.login, flask.current_app.config['EMAIL_ADMINS'].join(', ')
)
)
mail_locale = flask.current_app.config['BABEL_DEFAULT_LOCALE']
with force_locale(mail_locale):
msg = flask_mail.Message(
......@@ -1962,17 +1967,27 @@ class BaseRegisterView(ItemCreateView): # pylint: disable=locally-disabled,abst
@classmethod
def inform_managers(cls, account, form_data):
"""
Send information about new account registration to the user.
Send information about new account registration to the group managers.
Use manager`s locale for email content translations.
"""
for group in account.memberships_wanted:
flask.current_app.logger.info(
"Attempting to send information about registration of new account '{}' to managers of group '{}'.".format(
account.login, group.name
)
)
if not group.managed:
flask.current_app.logger.info(
"Unable to send information about registration of new account '{}' to managers of group '{}': group is not marked as self managed.".format(
account.login, group.name
)
)
return
if not group.managers:
flask.current_app.logger.error(
"Group '{}' is marked as self-managed, but there are no managers.".format(
group.name
"Unable to send information about registration of new account '{}' to managers of group '{}': group is marked as self managed, but there are no managers configured.".format(
account.login, group.name
)
)
return
......@@ -1998,6 +2013,11 @@ class BaseRegisterView(ItemCreateView): # pylint: disable=locally-disabled,abst
justification = form_data['justification']
)
flask.current_app.mailer.send(msg)
flask.current_app.logger.info(
"Sent information about registration of new account '{}' to manager '{}' of group '{}'.".format(
account.login, manager.email, group.name
)
)
@classmethod
def inform_user(cls, account, form_data):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment