示例#1
0
def invoice(request):

    if request.method == 'POST':
        form = DatePickerForm(request.POST)

        if form.is_valid():
            month = request.POST['month']
            year = request.POST['year']
            client = request.POST['client']

            if client:
                client = Client.objects.filter(pk=client)
            else:
                client = None

            invoice = Invoice(int(year), int(month))
            invoice.calculateInvoice(client)

            return render_to_response(
                'invoice-success.html', {
                    'listName': invoice.getListFilename(),
                    'invoiceName': invoice.getInvoiceFilename()
                },
                context_instance=RequestContext(request))
        else:
            return HttpResponse('Invalid form data.' + str(form))

    form = DatePickerForm()
    return render_to_response('invoice.html', {'form': form},
                              context_instance=RequestContext(request))
示例#2
0
def invoice(request):

  if request.method == 'POST':
    form = DatePickerForm(request.POST)

    if form.is_valid():
      month = request.POST['month']
      year = request.POST['year']
      client = request.POST['client']

      if client:
        client = Client.objects.filter(pk=client)
      else:
        client = None

      invoice = Invoice(int(year), int(month))
      invoice.calculateInvoice(client)

      return render_to_response('invoice-success.html', {'listName': invoice.getListFilename(), 'invoiceName': invoice.getInvoiceFilename()}, context_instance=RequestContext(request))
    else:
      return HttpResponse('Invalid form data.' + str(form))

  form = DatePickerForm()
  return render_to_response('invoice.html', {'form': form}, context_instance=RequestContext(request))