def new_pass(request, key): pas = get_object_or_404(PassChange, activation_key=key) user = get_object_or_404(Users, id=pas.user_id) registration_form = PasswordForm(user_id=user.id) context = RequestContext(request) l = [] if request.method == 'POST': form = PasswordForm(request.POST, user_id=user.id) if form.is_valid(): datas = {} datas['first_name'] = user.first_name datas['last_name'] = user.last_name datas['username'] = user.username datas['password'] = form.cleaned_data['password1'] datas['email'] = user.email datas['timezone'] = settings.TIME_ZONE datas[ 'preferred_languages'] = "[\"" + settings.LANGUAGE_CODE + "\"]" datas['activation_key'] = pas.activation_key form.save(datas) #Save the user and his profile el = get_object_or_404(Users, username=user.username) request.session['registered'] = True #For display purposes PassChange.objects.filter(activation_key=key).delete() return redirect(settings.URL + settings.SUCCESS + "/") else: registration_form = form #Display form with error messages (incorrect fields, etc) return render( request, 'set_pass.html', { 'user': user, 'formset': registration_form, 'u': settings.CMS_URL, 'lpl': lpl }, locals())
def user_password(request): form = PasswordForm(request.user, request.POST or None) if form.is_valid(): form.save() info(request, 'Password changed.') return HttpResponseRedirect(reverse("user-edit", args=[request.user.pk])) return direct_to_template(request, "user_password.html", extra_context={ "form": form, })
def user_password(request): form = PasswordForm(request.user, request.POST or None) if form.is_valid(): form.save() info(request, 'Password changed.') return HttpResponseRedirect( reverse("user-edit", args=[request.user.pk])) return direct_to_template(request, "user_password.html", extra_context={ "form": form, })