|
|
|
|
@ -16,6 +16,8 @@ from django.views.generic.edit import BaseFormView |
|
|
|
|
from django.shortcuts import redirect |
|
|
|
|
|
|
|
|
|
from apps.notification.utils import send_email |
|
|
|
|
from apps.config.models import Config |
|
|
|
|
|
|
|
|
|
from .forms import LearnerRegistrationForm |
|
|
|
|
from .tokens import verification_email_token |
|
|
|
|
|
|
|
|
|
@ -49,11 +51,12 @@ class LearnerRegistrationView(FormView): |
|
|
|
|
|
|
|
|
|
# fixme: change email text |
|
|
|
|
# fixme: async send email |
|
|
|
|
config = Config.load() |
|
|
|
|
refferer = urlsplit(self.request.META.get('HTTP_REFERER')) |
|
|
|
|
refferer = refferer[0] + '://' + refferer[1] |
|
|
|
|
token = verification_email_token.make_token(user) |
|
|
|
|
url = refferer + str(reverse_lazy('lilcity:verification-email', args=[token])) |
|
|
|
|
send_email('Verification Email', email, "notification/email/verification_email.html", url=url) |
|
|
|
|
send_email('Verification Email', email, "notification/email/verification_email.html", url=url, config=config) |
|
|
|
|
|
|
|
|
|
return JsonResponse({"success": True}, status=201) |
|
|
|
|
|
|
|
|
|
@ -111,6 +114,10 @@ class PasswordResetView(views.PasswordContextMixin, BaseFormView): |
|
|
|
|
def form_valid(self, form): |
|
|
|
|
refferer = urlsplit(self.request.META.get('HTTP_REFERER')) |
|
|
|
|
refferer = refferer[0] + '://' + refferer[1] |
|
|
|
|
config = Config.load() |
|
|
|
|
extra_email_context = {'config': config} |
|
|
|
|
if self.extra_email_context and isinstance(self.extra_email_context, dict): |
|
|
|
|
extra_email_context.update(self.extra_email_context) |
|
|
|
|
opts = { |
|
|
|
|
'domain_override': refferer, |
|
|
|
|
'use_https': self.request.is_secure(), |
|
|
|
|
@ -120,7 +127,7 @@ class PasswordResetView(views.PasswordContextMixin, BaseFormView): |
|
|
|
|
'subject_template_name': self.subject_template_name, |
|
|
|
|
'request': self.request, |
|
|
|
|
'html_email_template_name': self.html_email_template_name, |
|
|
|
|
'extra_email_context': self.extra_email_context, |
|
|
|
|
'extra_email_context': extra_email_context, |
|
|
|
|
} |
|
|
|
|
form.save(**opts) |
|
|
|
|
return JsonResponse({"success": True}) |
|
|
|
|
|