aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2016-02-18 22:01:17 +0100
committerCédric Bonhomme <cedric@cedricbonhomme.org>2016-02-18 22:01:17 +0100
commit5f53d8c5416a3f4ce6f7d12eb480192f2d80980a (patch)
tree7f2aa62cc663a26687e1c626dcb2aa419232bcaf /src
parentRephrasing... (diff)
downloadnewspipe-5f53d8c5416a3f4ce6f7d12eb480192f2d80980a.tar.gz
newspipe-5f53d8c5416a3f4ce6f7d12eb480192f2d80980a.tar.bz2
newspipe-5f53d8c5416a3f4ce6f7d12eb480192f2d80980a.zip
Added a template for the password recovery notifications.
Diffstat (limited to 'src')
-rw-r--r--src/web/notifications.py14
-rw-r--r--src/web/templates/emails/new_account.txt11
-rw-r--r--src/web/templates/emails/new_password.txt8
-rw-r--r--src/web/views/admin.py20
4 files changed, 13 insertions, 40 deletions
diff --git a/src/web/notifications.py b/src/web/notifications.py
index 4f276123..f10cff73 100644
--- a/src/web/notifications.py
+++ b/src/web/notifications.py
@@ -56,22 +56,12 @@ def new_account_notification(user):
emails.send(to=user.email, bcc=conf.NOTIFICATION_EMAIL,
subject="[JARR] Account creation", plaintext=plaintext)
-def new_account_activation(user):
- """
- Account activation notification.
- """
- plaintext = """Hello,\n\nYour account has been activated. You can now connect to the platform:\n%s\n\nSee you,""" % \
- (conf.PLATFORM_URL)
- emails.send(to=user.email, bcc=conf.NOTIFICATION_EMAIL,
- subject="[JARR] Account activated", plaintext=plaintext)
-
def new_password_notification(user, password):
"""
New password notification.
"""
- plaintext = """Hello,\n\nA new password has been generated at your request:\n\n%s""" % \
- (password, )
- plaintext += "\n\nIt is advised to replace it as soon as connected to jarr.\n\nSee you,"
+ plaintext = render_template('emails/new_password.txt',
+ user=user, password=password)
emails.send(to=user.email,
bcc=conf.NOTIFICATION_EMAIL,
subject="[JARR] New password", plaintext=plaintext)
diff --git a/src/web/templates/emails/new_account.txt b/src/web/templates/emails/new_account.txt
deleted file mode 100644
index 6335a34e..00000000
--- a/src/web/templates/emails/new_account.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-Hello {{ user.firstname }} {{ user.lastname }},
-
-An account has been created for you.
-You can now access the JARR platform ({{ platform_url }}).
-Your login is your e-mail address and your password is:
-
----
-{{ password }}
----
-
-Regards,
diff --git a/src/web/templates/emails/new_password.txt b/src/web/templates/emails/new_password.txt
new file mode 100644
index 00000000..40bdc207
--- /dev/null
+++ b/src/web/templates/emails/new_password.txt
@@ -0,0 +1,8 @@
+Hello {{ user.nickname }},
+
+A new password has been generated at your request:
+{{ password }}
+
+It is advised to replace it as soon as connected to JARR.
+
+See you,
diff --git a/src/web/views/admin.py b/src/web/views/admin.py
index 832c134d..b5b0fd54 100644
--- a/src/web/views/admin.py
+++ b/src/web/views/admin.py
@@ -144,21 +144,7 @@ def toggle_user(user_id=None):
flash(gettext('This user does not exist.'), 'danger')
return redirect(url_for('admin.dashboard'))
- if not user.enabled:
- # Send the confirmation email
- try:
- notifications.new_account_activation(user)
- user_contr.update({'id': user.id}, {'enabled': True})
- message = gettext('Account of the user %(nick)s successfully '
- 'activated.', nick=user.nickname)
- except Exception as error:
- flash(gettext('Problem while sending activation email %(error)s:',
- error=error), 'danger')
- return redirect(url_for('admin.dashboard'))
-
- else:
- user_contr.update({'id': user.id}, {'enabled': False})
- message = gettext('Account of the user %(nick)s successfully disabled',
- nick=user.nickname)
- flash(message, 'success')
+ user_contr.update({'id': user.id}, {'enabled': not user.enabled})
+ flash(gettext('Account of the user %(nick)s successfully '
+ 'updated.', nick=user.nickname), 'success')
return redirect(url_for('admin.dashboard'))
bgstack15