-wl_register_view = WLRegisterView.as_view()
-
-
-class RegisterFormView(AjaxableFormView):
- form_class = RegistrationForm
- template = "auth/register.html"
- placeholdize = True
- title = _('Register')
- submit = _('Register')
- ajax_redirect = True
- form_prefix = 'register'
- honeypot = True
-
- def __call__(self, request):
- if request.EXPERIMENTS['layout'].value:
- return wl_register_view(request)
-
- if request.user.is_authenticated:
- return self.redirect_or_refresh(
- request, '/',
- message=_('Already logged in as user %(user)s', ) % {'user': request.user.username})
- return super(RegisterFormView, self).__call__(request)
-
- def success(self, form, request):
- form.save()
- user = auth.authenticate(
- username=form.cleaned_data['username'],
- password=form.cleaned_data['password1']
- )
- auth.login(request, user)
-
-
-class LoginRegisterFormView(LoginFormView):
- template = 'auth/login_register.html'
- title = _('You have to be logged in to continue')
-
- def extra_context(self, request, obj):
- return {
- "register_form": placeholdized(RegistrationForm(prefix='register')),
- "register_submit": _('Register'),
- }
-