Пример #1
0
def create(request):
    if request.method == 'POST':
        form = TaxForm(request.POST)
        if form.is_valid():
            tax = form.save()
            messages.success(request, 'Tax created')
            return redirect('taxes:update', tax.pk)
    else:
        form = TaxForm()

    data = {
        'form': form,
    }

    return render_to_response(
        'taxes/create.html',
        data,
        context_instance=RequestContext(request),
    )
Пример #2
0
def update(request, tax_id):
    tax = get_object_or_404(Tax, pk=tax_id)

    if request.method == 'POST':
        form = TaxForm(request.POST, instance=tax)
        if form.is_valid():
            updated_tax = form.save()
            messages.success(request, 'Tax updated.')
    else:
        form = TaxForm(instance=tax)

    data = {
        'tax': tax,
        'form': form,
    }

    return render_to_response(
        'taxes/update.html',
        data,
        context_instance=RequestContext(request),
    )
Пример #3
0
    my_count = {'count': count}
    json_count.append(my_count)
    return render_to_response('taxes/display_all_forms.html', {'projects': projects,
                                                               'tax_years': json.dumps(json_files),
                                                               'item_count': json.dumps(json_count)}, context_instance=RequestContext(request))


def createTaxForm(request):
    try:
        projects = Project.objects.all()
    except Exception, e:
        raise e
    tax_year = TaxYearForms()
    if request.method == 'POST':
        tax_form = TaxForm(request.POST, instance=tax_year)
        if tax_form.is_valid():
            tax_year = tax_form.save()
            return redirect('taxes.views.viewAllForms')
        else:
            print(tax_form.errors)
    else:
        tax_form = TaxForm(instance=tax_year)

    return render_to_response('taxes/tax_form.html', {'projects': projects}, context_instance=RequestContext(request))


def submitProjectForm(request):
    try:
        projects = Project.objects.all()
    except Exception, e:
        print(e)