예제 #1
0
파일: views.py 프로젝트: omeinusch/Palco
def backstage_fee_form(request, project, fee):
    project = get_project(request, project, 'is_manager')
    fee = get_object_or_404(Fee, pk=fee)

    if request.POST:
        if request.POST.get('delete'):
            message_object_deleted(request, fee)
            fee.delete()
            return redirect('bs-fee-list', project=project.pk)

        form = FeeForm(request.POST, instance=fee)
        if form.is_valid():
            form.save()
            message_object_updated(request, fee)
            return redirect('bs-fee-list', project=project.pk)
    else:
        form = FeeForm(instance=fee)

    c = {
        'project': project,
        'view_title': Fee.objects.model._meta.verbose_name_plural,
        'view_url_list': 'bs-fee-list',
        'form': form,
        'object': fee
    }

    return render(request, 'project/form.html',
                  get_context_backstage_project(request, project, 'bs-fee-form', c))
예제 #2
0
파일: views.py 프로젝트: omeinusch/Palco
def backstage_fee_add(request, project):
    project = get_project(request, project, 'is_manager')
    if request.POST:
        form = FeeForm(request.POST)
        if form.is_valid():
            fee = form.save(commit=False)
            fee.project = project
            fee.save()
            message_object_created(request, fee)
            return redirect('bs-fee-list', project=project.pk)
    else:
        form = FeeForm()

    c = {
        'project': project,
        'view_title': Fee.objects.model._meta.verbose_name_plural,
        'view_url_list': 'bs-fee-list',
        'form': form,
    }

    return render(request, 'project/form.html',
                  get_context_backstage_project(request, project, 'bs-fee-add', c))