Пример #1
0
def edit_work(request, work_id=None):
    profile = get_profile()
    forms = map(lambda x: FormWork(instance=x, prefix='%s' % x.id),
                profile.work_set.all())
    if request.method == "POST":
        work = None
        if work_id is not None:
            work = Work.objects.filter(id=work_id)
        if work:
            form = FormWork(request.POST, instance=work[0],
                            prefix='%s' % work[0].id)
        else:
            form = FormWork(request.POST)
        if form.is_valid():
            form.save()
            if not work:
                forms.append(form)
            else:
                return HttpResponseRedirect('.')
            form = FormWork()
    else:
        form = FormWork()
    forms.append(form)
    return render_to_response('edit/work.html',
                              {'profile': get_profile(),
                               'forms': forms,
                               },
                              context_instance=RequestContext(request))
Пример #2
0
def edit_profile(request):
    profile = get_profile()
    if request.method == "POST":
        form = EditProfile(request.POST, instance=profile)
        if form.is_valid():
            form.save()
            image = _save_image(request)
            if image:
                form.instance.avatar = image[0]
                form.instance.save()
    else:
        form = EditProfile(instance=profile)
    return render_to_response('edit/profile.html',
                              {'profile': get_profile(),
                               'form': form},
                              context_instance=RequestContext(request))
Пример #3
0
def edit(request):
    return render_to_response('edit/index.html',
                              {'profile': get_profile(),
                               'posts': Post.objects.all()},
                              context_instance=RequestContext(request))