+
+ if page.template.mimetype == 'text/html':
+ msg = EmailMultiAlternatives(subject, striptags(text_content), from_email, [email])
+ msg.attach_alternative(text_content, 'text/html')
+ msg.send()
+ else:
+ send_mail(subject, text_content, from_email, [email])
+
+ def password_reset(self, request, extra_context=None, token_generator=password_token_generator):
+ if request.user.is_authenticated():
+ return HttpResponseRedirect(request.node.get_absolute_url())
+
+ if request.method == 'POST':
+ form = PasswordResetForm(request.POST)
+ if form.is_valid():
+ current_site = Site.objects.get_current()
+ for user in form.users_cache:
+ token = token_generator.make_token(user)
+ link = 'http://%s/%s/%s/' % (current_site.domain, request.node.get_absolute_url().strip('/'), reverse('password_reset_confirm', urlconf=self, kwargs={'uidb36': int_to_base36(user.id), 'token': token}).strip('/'))
+ context = {
+ 'link': link,
+ 'username': user.username
+ }
+ self.send_confirmation_email('Confirm password reset for account at %s' % current_site.domain, user.email, self.password_reset_confirmation_email, context)
+ messages.add_message(request, messages.SUCCESS, "An email has been sent to the address you provided with details on resetting your password.", fail_silently=True)
+ return HttpResponseRedirect('')
+ else:
+ form = PasswordResetForm()
+
+ context = self.get_context({'form': form})
+ context.update(extra_context or {})
+ return self.password_reset_page.render_to_response(request, extra_context=context)