Updated password reset template

This commit is contained in:
PCoder 2017-09-02 15:56:17 +05:30
parent 5381e0fa67
commit 7c70ee637a
3 changed files with 32 additions and 34 deletions

View file

@ -1,13 +1,14 @@
{% load i18n %}{% autoescape off %}
{% blocktrans %}You're receiving this email because you requested a password reset for your user account at {{ site_name }}.{% endblocktrans %}
{% trans "Please go to the following page and choose a new password:" %}
{% block reset_link %}
{{ base_url }}{% url 'hosting:reset_password_confirm' uidb64=uid token=token %}
{% endblock %}
{% trans "Thanks for using our site!" %}
{% blocktrans %}The {{ site_name }} team{% endblocktrans %}
{% endautoescape %}
{% extends "datacenterlight/emails/base_email_datacenterlight.html" %}
{% load i18n %}
{% block email_head %}
{% trans 'Password Reset' %}
{% endblock %}
{% block email_body %}
{% url 'hosting:reset_password_confirm' uidb64=uid token=token as password_reset_url %}
{% blocktrans %}
You're receiving this email because you requested a password reset for your user account at {{site_name}}.
Please go to the following page and choose a new password: {{base_url}}{{ password_reset_url }}
If you didn't request a new password, ignore this e-mail.
Thank you!
{% endblocktrans %}
{% endblock %}

View file

@ -1,13 +1,14 @@
{% load i18n %}{% autoescape off %}
{% blocktrans %}You're receiving this email because you requested a password reset for your user account at {{ site_name }}.{% endblocktrans %}
{% trans "Please go to the following page and choose a new password:" %}
{% block reset_link %}
{{ base_url }}{% url 'hosting:reset_password_confirm' uidb64=uid token=token %}
{% endblock %}
{% trans "Thanks for using our site!" %}
{% blocktrans %}The {{ site_name }} team{% endblocktrans %}
{% endautoescape %}
{% extends "datacenterlight/emails/base_email_datacenterlight.txt" %}
{% load i18n %}
{% block email_head %}
{% trans 'Password Reset' %}
{% endblock %}
{% block email_body %}
{% url 'hosting:reset_password_confirm' uidb64=uid token=token as password_reset_url %}
{% blocktrans with amount=article.price%}
You're receiving this email because you requested a password reset for your user account at {{site_name}}.
Please go to the following page and choose a new password: {{base_url}}{{ password_reset_url }}
If you didn't request a new password, ignore this e-mail.
Thank you!
{% endblocktrans %}
{% endblock %}

View file

@ -1,11 +1,12 @@
from django.views.generic import FormView, CreateView
from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode
from django.conf import settings
from django.contrib import messages
from django.contrib.auth.tokens import default_token_generator
from django.utils.encoding import force_bytes
from django.http import HttpResponseRedirect
from django.contrib.auth import authenticate, login
from django.utils.translation import ugettext_lazy as _
from membership.models import CustomUser
from .mailer import BaseEmail
@ -65,10 +66,8 @@ class LoginViewMixin(FormView):
class PasswordResetViewMixin(FormView):
# template_name = 'hosting/reset_password.html'
# form_class = PasswordResetRequestForm
success_message = "The link to reset your email has been sent to your email"
success_message = _("The link to reset your email has been sent to your email")
site = ''
success_message = "Thank you! You will shortly receive a password reset mail from us"
# success_url = reverse_lazy('hosting:login')
def test_generate_email_context(self, user):
context = {
@ -82,12 +81,9 @@ class PasswordResetViewMixin(FormView):
return context
def form_valid(self, form):
email = form.cleaned_data.get('email')
user = CustomUser.objects.get(email=email)
messages.add_message(self.request, messages.SUCCESS, self.success_message)
context = self.test_generate_email_context(user)
email_data = {
'subject': 'Password Reset',
@ -97,7 +93,7 @@ class PasswordResetViewMixin(FormView):
'template_path': self.template_email_path
}
if self.site == 'dcl':
email_data['from_address'] = '(Data Center Light) Data Center Light Support <support@datacenterlight.ch>'
email_data['from_address'] = settings.DCL_SUPPORT_FROM_ADDRESS
email = BaseEmail(**email_data)
email.send()