def register(request): """Create a registration profile.""" form = forms.RegisterForm(request.POST or None) if request.method == "POST" and form.is_valid(): # Create a registration profile, which also emails # activation details profile = RegisterProfile.objects.create_profile( form.cleaned_data["display_name"], form.cleaned_data["email"], form.cleaned_data["password"] ) return jingo.render(request, "users/register_done.html", {"profile": profile}) return home(request, register_form=form)
def login(request): form = forms.LoginForm(data=(request.POST or None)) if request.method == 'POST': # TODO: Handle inactive users if form.is_valid(): auth_login(request, form.get_user()) # Set session to not expire on browser close if form.cleaned_data['remember_me']: request.session.set_expiry(settings.SESSION_REMEMBER_DURATION) return HttpResponseRedirect(reverse('my_badges')) return home(request, login_form=form)
form.cleaned_data['password']) # Sign the user up for mailing lists if they wanted if form.cleaned_data['email_subscribe']: try: subscribe(settings.RESPONSYS_CAMPAIGN, form.cleaned_data['email'], lang=get_language(), source_url=request.build_absolute_uri()) except Exception, err: log.warning(err) return jingo.render(request, 'users/register_done.html', {'profile': profile}) return home(request, register_form=form) @anonymous_csrf def activate(request, activation_key=None): """Activate a registration profile and create a user.""" user = RegisterProfile.objects.activate_profile(activation_key) return jingo.render(request, 'users/activate_done.html', {'activated_user': user}) @login_required def edit_profile(request): """Edit an existing UserProfile.""" form = forms.EditProfileForm(request.POST or None, instance=request.user.get_profile())