예제 #1
0
파일: views.py 프로젝트: 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))
예제 #2
0
파일: views.py 프로젝트: 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))
예제 #3
0
파일: tests.py 프로젝트: 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())
예제 #4
0
파일: views.py 프로젝트: 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))
예제 #5
0
파일: views.py 프로젝트: piepmatz/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.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))
예제 #6
0
파일: views.py 프로젝트: sebastianoe/EvaP
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))
예제 #7
0
파일: views.py 프로젝트: piepmatz/EvaP
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))