

@login_required
def password_set(request, **kwargs):
    form_class = kwargs.pop('form_class', SetPasswordForm)
    template_name = kwargs.pop('template_name', 'account/password_set.html')
    (group, bridge) = group_and_bridge(kwargs)
    if request.user.password:
        return HttpResponseRedirect(reverse('acct_passwd'))
    if (request.method == 'POST'):
        password_set_form = form_class(request.user, request.POST)
        if password_set_form.is_valid():
            password_set_form.save()
            messages.add_message(request, messages.SUCCESS, ugettext('Password successfully set.'))
            return HttpResponseRedirect(reverse('acct_passwd'))
    else:
        password_set_form = form_class(request.user)
    ctx = group_context(group, bridge)
    ctx.update({
        'password_set_form': password_set_form,
    })
    return render_to_response(template_name, RequestContext(request, ctx))

dataset/ETHPy150Open amarandon/smeuhsocial/apps/account/views.py password_set/original