Exemplo n.º 1
0
Arquivo: tests.py Projeto: Nef10/EvaP
    def test_user_form(self):
        """ Tests the UserForm with one valid and one invalid input dataset. """
        userprofile = UserProfile.objects.get(pk=1)
        another_userprofile = UserProfile.objects.get(pk=2)
        data = {"username": "******", "email": "*****@*****.**"}
        form = UserForm(instance=userprofile, data=data)
        self.assertTrue(form.is_valid())

        data = {"username": another_userprofile.user.username, "email": "[email protected]"}
        form = UserForm(instance=userprofile, data=data)
        self.assertFalse(form.is_valid())
Exemplo n.º 2
0
Arquivo: views.py Projeto: Nef10/EvaP
def user_edit(request, user_id):
    user = get_object_or_404(User, id=user_id)
    form = UserForm(request.POST or None, request.FILES or None, instance=UserProfile.get_for_user(user))

    if form.is_valid():
        form.save()
        messages.success(request, _("Successfully updated user."))
        return redirect('evap.fsr.views.user_index')
    else:
        return render_to_response("fsr_user_form.html", dict(form=form, object=user), context_instance=RequestContext(request))
Exemplo n.º 3
0
Arquivo: views.py Projeto: Nef10/EvaP
def user_create(request):
    profile = UserProfile(user=User())
    form = UserForm(request.POST or None, instance=profile)

    if form.is_valid():
        form.save()
        messages.success(request, _("Successfully created user."))
        return redirect('evap.fsr.views.user_index')
    else:
        return render_to_response("fsr_user_form.html", dict(form=form), context_instance=RequestContext(request))
Exemplo n.º 4
0
Arquivo: views.py Projeto: mswart/EvaP
def user_edit(request, user_id):
    user = get_object_or_404(User, id=user_id)
    form = UserForm(request.POST or None, request.FILES or None, instance=user.get_profile())
    
    if form.is_valid():
        form.save()
        
        messages.add_message(request, messages.INFO, _("Successfully updated user."))
        
        if "filter" in request.GET:
            return custom_redirect('evap.fsr.views.user_index', filter=request.GET['filter'])
        else:
            return redirect('evap.fsr.views.user_index')
    else:
        return render_to_response("fsr_user_form.html", dict(form=form, object=user), context_instance=RequestContext(request))
Exemplo n.º 5
0
def user_edit(request, user_id):
    user = get_object_or_404(User, id=user_id)
    form = UserForm(request.POST or None, request.FILES or None, instance=UserProfile.get_for_user(user))

    if form.is_valid():
        form.save()

        messages.add_message(request, messages.INFO, _("Successfully updated user."))

        if "filter" in request.GET:
            return custom_redirect('evap.fsr.views.user_index', filter=request.GET['filter'])
        else:
            return redirect('evap.fsr.views.user_index')
    else:
        return render_to_response("fsr_user_form.html", dict(form=form, object=user), context_instance=RequestContext(request))
Exemplo n.º 6
0
def user_create(request):
    profile = UserProfile(user=User())
    form = UserForm(request.POST or None, instance=profile)
    
    if form.is_valid():
        #profile.user.save()
        form.save()
        
        messages.add_message(request, messages.INFO, _("Successfully created user."))
        
        if "filter" in request.GET:
            return custom_redirect('evap.fsr.views.user_index', filter=request.GET['filter'])
        else:
            return redirect('evap.fsr.views.user_index')
    else:
        return render_to_response("fsr_user_form.html", dict(form=form), context_instance=RequestContext(request))
Exemplo n.º 7
0
def user_create(request):
    profile = UserProfile(user=User())
    form = UserForm(request.POST or None, instance=profile)

    if form.is_valid():
        #profile.user.save()
        form.save()

        messages.add_message(request, messages.INFO, _("Successfully created user."))

        if "filter" in request.GET:
            return custom_redirect('evap.fsr.views.user_index', filter=request.GET['filter'])
        else:
            return redirect('evap.fsr.views.user_index')
    else:
        return render_to_response("fsr_user_form.html", dict(form=form), context_instance=RequestContext(request))