def login(request): context = { 'signin': AuthenticationForm(), 'signup': SignupForm(), 'signup_opt': SignupOptionalForm() } if request.method == 'POST': if request.POST['action-type'] == 'signup': form = SignupOptionalForm(request.POST) if not form.is_valid(): context['signup'] = SignupOptionalForm(request.POST) context['signup_opt'] = form context['default_tab'] = 1 else: context['signup_opt'] = SignupOptionalForm(request.POST) context['action'] = 'signup' context['default_tab'] = 1 response = views.signup( request, signup_form=SignupForm, template_name='cs_auth/login.jinja2', extra_context=context, ) # It redirects on success: we intercept add the extra # information if isinstance(response, http.HttpResponseRedirect): # Fill extra info in signup form aux = request.POST success_url = '/accounts/%s' % aux['username'] user = User.objects.get(username=aux['username']) user.first_name = aux['first_name'] user.last_name = aux['last_name'] # Fill extra profile info form = SignupOptionalForm(request.POST) form.is_valid() aux = form.cleaned_data user.profile.about_me = aux['about_me'] user.profile.gender = aux['gender'] user.profile.date_of_birth = aux['date_of_birth'] # Save modifications and go user.save() user.profile.save() return redirect(success_url) return response else: context['action'] = 'signin' return views.signin( request, template_name='cs_auth/login.jinja2', extra_context=context, ) return render(request, 'cs_auth/login.jinja2', context)
def signup(request): is_account_form =True if 'cancel' in request.POST: return HttpResponsePermanentRedirect('/') return userena_views.signup(request, signup_form=SignupForm, extra_context={ 'is_account_form': is_account_form })
def post(self, request, *args, **kwargs): page = request.POST.get('page') if int(page) == 1: form = ChooseUniversityForm(request.POST) if form.is_valid(): university_id = int(form.cleaned_data.get('university_id')) signup_form = self.get_signup_form(university_id) request.method = "GET" # Return the `signup` output as if it were a GET request return signup(request, signup_form=signup_form) return render(request, 'accounts/signup_start.html', {'form': form}) elif int(page) == 2: university_id = int(request.POST.get('university')) signup_form = self.get_signup_form(university_id) return signup(request, signup_form=signup_form)
def login(request): context = {'signin': AuthenticationForm(), 'signup': SignupForm(), 'signup_opt': SignupOptionalForm()} if request.method == 'POST': if request.POST['action-type'] == 'signup': form = SignupOptionalForm(request.POST) if not form.is_valid(): context['signup'] = SignupOptionalForm(request.POST) context['signup_opt'] = form context['default_tab'] = 1 else: context['signup_opt'] = SignupOptionalForm(request.POST) context['action'] = 'signup' context['default_tab'] = 1 response = views.signup( request, signup_form=SignupForm, template_name='cs_auth/login.jinja2', extra_context=context, ) # It redirects on success: we intercept add the extra # information if isinstance(response, http.HttpResponseRedirect): # Fill extra info in signup form aux = request.POST success_url = '/accounts/%s' % aux['username'] user = User.objects.get(username=aux['username']) user.first_name = aux['first_name'] user.last_name = aux['last_name'] # Fill extra profile info form = SignupOptionalForm(request.POST) form.is_valid() aux = form.cleaned_data user.profile.about_me = aux['about_me'] user.profile.gender = aux['gender'] user.profile.date_of_birth = aux['date_of_birth'] # Save modifications and go user.save() user.profile.save() return redirect(success_url) return response else: context['action'] = 'signin' return views.signin( request, template_name='cs_auth/login.jinja2', extra_context=context, ) return render(request, 'cs_auth/login.jinja2', context)
def signup(request, extra_context=None, **kwargs): success = reverse("profile_signup_complete") response = userena_views.signup( request=request, extra_context=extra_context, success_url=success, **kwargs, ) return response
def signup(request): institutions = Institution.objects.all() primary_interests = PrimaryInterest.objects.all() extra_context = { 'institutions': institutions, 'primary_interests': primary_interests } return userena_views.signup(request, signup_form=CustomSignupForm, template_name='accounts/signup.html', extra_context=extra_context)
def signup(request, signup_form=SignupFormBeta, template_name='userena/signup_form.html', success_url=None, extra_context=None): form = SignupFormBeta() if request.method == 'POST': # If the form has been submitted... form = SignupFormBeta(request.POST, request.FILES) if request.POST.get('beta_access') == 'noisetracker': return userena_views.signup(request, signup_form) if not extra_context: extra_context = dict() extra_context['form'] = form return ExtraContextTemplateView.as_view(template_name=template_name, extra_context=extra_context)(request)
def signup(request, site_short_name, extra_context=None,**kwargs): extra_context = get_extra_context(site_short_name) # signup_form, template_name, success_url, extra_context if "next" in request.GET: success = request.GET["next"] + "?user_just_registered=True" else: success = reverse("comicsite_signup_complete",kwargs={"site_short_name":site_short_name}) response = userena_views.signup(request=request, extra_context=extra_context, success_url=success, **kwargs) return response
def bookstore_signup(request): # do stuff before userena signup view is called extra_context=dict() extra_context['override_base'] = 'bookstore/bookstore-base.html' # call the original view response = userena_views.signup(request,extra_context=extra_context) # do stuff after userena signup view is done if request.method=='POST': try: if response.url: response = HttpResponseRedirect('/bookstore/topup/') except: pass # do stuff after userena signup view is done # return the response # return the response return response
def post_signup(self, request): context = self.get_context_data(action='signup') form = SignupForm(request.POST) opt_form = SignupOptionalForm(request.POST) # Render forms if they are invalid if not (opt_form.is_valid() and form.is_valid()): context['signup'] = form context['signup_opt'] = opt_form return super().render_to_response(context) # Validate and proceed context['signup_opt'] = opt_form response = views.signup( request, signup_form=SignupForm, template_name=self.template_name, extra_context=context, success_url='/', ) # It redirects on success: we intercept and add extra # information if isinstance(response, http.HttpResponseRedirect): # Fill extra info in signup form aux = form.cleaned_data success_url = '/accounts/%s' % aux['username'] user = User.objects.get(username=aux['username']) user.first_name = aux['first_name'] user.last_name = aux['last_name'] # Fill extra profile info opt_form = SignupOptionalForm(request.POST) opt_form.is_valid() aux = opt_form.cleaned_data user.profile.about_me = aux['about_me'] user.profile.gender = aux['gender'] user.profile.date_of_birth = aux['date_of_birth'] # Save modifications and go user.save() user.profile.save() return redirect(success_url) return response
def signup(request): ''' a simple overwritten the signup view ''' return views.signup(request, success_url='/home/')
def signup_redirect(request, *args, **kwargs): if request.user.is_authenticated() and request.user.is_superuser: return signup(request, *args, **kwargs) return redirect("index")
def signup_view(request): return userena_views.signup( request, success_url=settings.USERENA_SIGNIN_REDIRECT_URL, )
def signup_redirect(request, *args, **kwargs): if (settings.OPTIONS.get("ENABLE_SIGNUP", False) or (request.user.is_authenticated() and request.user.is_superuser)): return signup(request, *args, **kwargs) return redirect("index")