Example #1
0
    def update(self, request, profile):
        profile = Profile.objects.get(name=profile)

        form = ProfileForm(instance=profile, data=request.data)
        if form.is_valid():
            form.save()
            return rc.ALL_OK
        raise FormValidationError(form)
Example #2
0
def add_profile(request):
    if request.method == 'POST':
        form = ProfileForm(request.POST)
        if form.is_valid():
            profile = form.save()
            return HttpResponseRedirect(profile.get_absolute_url())
    else:
        form = ProfileForm()

    context = RequestContext(request, {
        'form': form,
        'state': 'profile',
    })
    return render_to_response('add.html', context)
Example #3
0
def edit_profile(request, profile):
    profile = get_object_or_404(Profile, name=profile)
    if request.method == 'POST':
        form = ProfileForm(instance=profile, data=request.POST)
        if form.is_valid():
            profile = form.save()
            return HttpResponseRedirect(profile.get_absolute_url())
    else:
        form = ProfileForm(instance=profile)

    context = RequestContext(request, {
        'form': form,
        'state': 'profile',
    })
    return render_to_response('edit.html', context)