|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
|
import logging |
|
|
|
|
from django.conf import settings |
|
|
|
|
from django.contrib.auth.forms import SetPasswordForm |
|
|
|
|
from django.contrib.auth.views import ( |
|
|
|
|
LoginView as LoginViewBase, |
|
|
|
|
LogoutView, |
|
|
|
|
@ -7,8 +8,6 @@ from django.contrib.auth.views import ( |
|
|
|
|
PasswordResetDoneView as PasswordResetDoneViewBase, |
|
|
|
|
PasswordResetConfirmView as PasswordResetConfirmViewBase, |
|
|
|
|
PasswordResetCompleteView as PasswordResetCompleteViewBase, |
|
|
|
|
PasswordChangeView as PasswordChangeViewBase, |
|
|
|
|
PasswordChangeDoneView as PasswordChangeDoneViewBase |
|
|
|
|
) |
|
|
|
|
from django.views.generic import TemplateView |
|
|
|
|
|
|
|
|
|
@ -17,9 +16,8 @@ from registration.backends.default.views import ( |
|
|
|
|
ResendActivationView as ResendActivationViewBase |
|
|
|
|
) |
|
|
|
|
from django.contrib.messages.views import SuccessMessageMixin |
|
|
|
|
from django.http import JsonResponse |
|
|
|
|
from django.shortcuts import redirect, resolve_url |
|
|
|
|
from django.urls import reverse, reverse_lazy |
|
|
|
|
from django.urls import reverse_lazy |
|
|
|
|
from django.utils.http import is_safe_url, urlencode |
|
|
|
|
from django.utils.translation import ugettext_lazy as _ |
|
|
|
|
|
|
|
|
|
@ -75,20 +73,15 @@ class ResetPasswordView(PasswordResetViewBase): |
|
|
|
|
return context |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ResetPasswordDoneView(PasswordResetDoneViewBase): |
|
|
|
|
template_name = 'accounts_ext/reset_password_done.html' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ResetPasswordConfirmView(PasswordResetConfirmViewBase): |
|
|
|
|
form_class = PasswordResetForm |
|
|
|
|
template_name = 'accounts_ext/reset_password_confirm.html' |
|
|
|
|
form_class = SetPasswordForm |
|
|
|
|
template_name = 'accounts_ext/reset_password_change.html' |
|
|
|
|
success_url = reverse_lazy('accounts_ext:reset_password_complete') |
|
|
|
|
|
|
|
|
|
def get_form_kwargs(self): |
|
|
|
|
kwargs = super().get_form_kwargs() |
|
|
|
|
kwargs['request'] = self.request |
|
|
|
|
return kwargs |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ResetPasswordCompleteView(PasswordResetCompleteViewBase): |
|
|
|
|
template_name = 'accounts_ext/reset_password_complete.html' |
|
|
|
|
@ -133,16 +126,16 @@ class RegistrationView(RegistrationViewBase): |
|
|
|
|
else: |
|
|
|
|
return redirect(to, *args, **kwargs) |
|
|
|
|
|
|
|
|
|
def get_success_url(self,user): |
|
|
|
|
def get_success_url(self, user): |
|
|
|
|
url = reverse_lazy('accounts_ext:register_done') |
|
|
|
|
return "{}?{}".format(url, urlencode({'email':user.email})) |
|
|
|
|
return "{}?{}".format(url, urlencode({'email': user.email})) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class RegistrationDoneView(TemplateView): |
|
|
|
|
template_name = 'registration/registration_done.html' |
|
|
|
|
|
|
|
|
|
def dispatch(self, request, *args, **kwargs): |
|
|
|
|
if reverse_lazy('accounts_ext:register').__str__() in request.META.get('HTTP_REFERER',''): |
|
|
|
|
if reverse_lazy('accounts_ext:register').__str__() in request.META.get('HTTP_REFERER', ''): |
|
|
|
|
return super().dispatch(request, *args, **kwargs) |
|
|
|
|
return redirect(settings.LOGIN_REDIRECT_URL) |
|
|
|
|
|
|
|
|
|
@ -150,7 +143,7 @@ class RegistrationDoneView(TemplateView): |
|
|
|
|
context = super().get_context_data(**kwargs) |
|
|
|
|
context['title'] = _('Отправка письма активации') |
|
|
|
|
context['email'] = self.request.GET.get('email') |
|
|
|
|
context['email_domain'] = "http://"+self.request.GET.get('email').split('@')[-1] |
|
|
|
|
context['email_domain'] = "http://" + self.request.GET.get('email').split('@')[-1] |
|
|
|
|
return context |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -163,23 +156,5 @@ class ResendActivationView(ResendActivationViewBase): |
|
|
|
|
return context |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ChangePasswordForm(PasswordChangeViewBase): |
|
|
|
|
template_name = 'accounts_ext/password_reset_change.html' |
|
|
|
|
|
|
|
|
|
def get_context_data(self, **kwargs): |
|
|
|
|
context = super().get_context_data(**kwargs) |
|
|
|
|
context['title'] = _('Введение нового пароля') |
|
|
|
|
return context |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ChangePasswordDoneForm(PasswordChangeDoneViewBase): |
|
|
|
|
template_name = 'accounts_ext/password_reset_change_done.html' |
|
|
|
|
|
|
|
|
|
def get_context_data(self, **kwargs): |
|
|
|
|
context = super().get_context_data(**kwargs) |
|
|
|
|
context['title'] = _('Сброс пароля') |
|
|
|
|
return context |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ProfileView(ProtectedView): |
|
|
|
|
template_name = 'accounts_ext/index.html' |
|
|
|
|
|