コード例 #1
0
ファイル: views.py プロジェクト: srgun95/apartment
def newUser(request):
    if request.method == 'POST':
        form = NewUserForm(request.POST)
        if form.is_valid():
            form.save()
            return redirect('/account/home')
    else:
        form = NewUserForm()
    args = {'form': form}
    return render(request, 'account/new-user.html', args)
コード例 #2
0
def test_NewUserForm_save(register_valid_post_request, db_w_group):
    from account.forms import NewUserForm
    from account.templatetags import user_utils

    request = register_valid_post_request
    form = NewUserForm(request.POST)
    form.save()

    user = User.objects.get(pk=1)

    assert user.username == request.POST.get('username')
    assert user.email == request.POST.get('email')
    assert user_utils.has_group(user, 'basic_web_user')
    assert user_utils.has_permission(user, 'do stuff')
コード例 #3
0
ファイル: views.py プロジェクト: Artikulpi/public_courts
def new(request):
    if request.method == "POST":
        form = NewUserForm(request.POST)
        if form.is_valid():
            new_user = form.save()
            return HttpResponseRedirect("./")
    else:
        form = NewUserForm()

    return render_to_response("account/new.html",
                            {"form": form,},
                            context_instance=RequestContext(request))
コード例 #4
0
ファイル: views.py プロジェクト: Artikulpi/public_courts
def new(request):
    if request.method == "POST":
        form = NewUserForm(request.POST)
        if form.is_valid():
            new_user = form.save()
            return HttpResponseRedirect("./")
    else:
        form = NewUserForm()

    return render_to_response("account/new.html", {
        "form": form,
    },
                              context_instance=RequestContext(request))
コード例 #5
0
ファイル: views.py プロジェクト: Aarti97/project
def registerPage(request):
    if request.method == "POST":
        form = NewUserForm(request.POST)
        if form.is_valid():
            user = form.save()
            login(request, user)
            messages.success(request, "Registration successful.")
            return redirect("index")
        messages.error(request,
                       "Unsuccessful registration. Invalid information.")
    form = NewUserForm
    return render(request=request,
                  template_name="register.html",
                  context={"form": form})