From: Tollef Fog Heen Date: Sun, 10 Jun 2012 06:17:57 +0000 (+0200) Subject: Add support for print template, remove text version X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fef89a0b5904a596e4547b797449a3017820a688;p=peojumk Add support for print template, remove text version --- diff --git a/invoice/urls.py b/invoice/urls.py index f4781a5..92067aa 100644 --- a/invoice/urls.py +++ b/invoice/urls.py @@ -1,7 +1,7 @@ from django.conf.urls import patterns, include, url import django.contrib.auth.views from invoice.views import UpdateClient, DeleteClient, CreateClient, DetailClient, \ - CreateInvoice, DetailInvoice, invoice_text + CreateInvoice, DetailInvoice, DetailInvoicePrint import invoice.views @@ -15,5 +15,5 @@ urlpatterns = patterns('invoice.views', url(r'^accounts/login/$', django.contrib.auth.views.login), url(r'^invoice/new$', CreateInvoice.as_view(), name="invoice_new"), url(r'^invoice/(?P\d+)$', DetailInvoice.as_view(), name='invoice_view'), - url(r'^invoice/(?P\d+)/text$', invoice_text, name='invoice_view'), + url(r'^invoice/(?P\d+)/print$', DetailInvoicePrint.as_view(), name='invoice_print_view'), ) diff --git a/invoice/views.py b/invoice/views.py index 32f38c2..68f296e 100644 --- a/invoice/views.py +++ b/invoice/views.py @@ -20,12 +20,6 @@ def index(request): sent_invoices = Invoice.objects.filter(status = 'S') return render_to_response('invoice/index.html', locals()) -@login_required -def invoice_text(request, pk): - invoice = Invoice.objects.get(pk = pk) - - return render_to_response('invoice/invoice_detail.txt', locals(), mimetype="text/plain") - # ------------------- CLIENT --------------- class DetailClient(DetailView): @@ -73,6 +67,9 @@ class DetailInvoice(DetailView): def dispatch(self, *args, **kwargs): return super(DetailInvoice, self).dispatch(*args, **kwargs) +class DetailInvoicePrint(DetailInvoice): + template_name = 'invoice/invoice_detail_print.html' + class CreateInvoice(CreateWithInlinesView): model = Invoice inlines = [InvoiceLineInline] diff --git a/templates/invoice/invoice_detail_print.html b/templates/invoice/invoice_detail_print.html new file mode 100644 index 0000000..ecbb80b --- /dev/null +++ b/templates/invoice/invoice_detail_print.html @@ -0,0 +1,116 @@ + + + + + {% block title %}{% endblock %} + + + + + + + + + +
+ +
+
+
    +
  • {{invoice.customer.name}}
  • +
  • {{invoice.customer.address}}

  • +
+ +
+ +
+ +
    +
  • err.no AS
  • +
  • Disengrenda 5b
  • +
  • 0587 Oslo
  • +
  • Norway
  • +
  • Foretaksregisteret NO 998 270 189
  • +
  • info@err.no
  • +
+
+
    +
  • Invoice no: {{ invoice.id }}
  • +
  • Date: {{ invoice.date|date:"Y-m-d" }}
  • +
  • Due date: {{ invoice.due_date|date:"Y-m-d" }}
  • +
+ +
+
+
+ +
+
+ Description +
+
+ Hours +
+
+ Rate ({{ invoice.currency }}) +
+
+ Total +
+
+ {% for line in invoice.invoiceline_set.all %} +
+
+ {{ line.description }} +
+
+ {{ line.time }} +
+
+ {{ line.hourly_rate }} +
+
+ {{ line.amount }} +
+
+ {% endfor %} +
{{ invoice.comment }}
+ +
+
Total: {{ invoice.currency }} {{ invoice.total_sum }}
+ + +
+ + + + + + + + + + + + + + + + + + +