]> err.no Git - peojumk/commitdiff
Add support for print template, remove text version
authorTollef Fog Heen <tfheen@err.no>
Sun, 10 Jun 2012 06:17:57 +0000 (08:17 +0200)
committerTollef Fog Heen <tfheen@err.no>
Sun, 10 Jun 2012 06:17:57 +0000 (08:17 +0200)
invoice/urls.py
invoice/views.py
templates/invoice/invoice_detail_print.html [new file with mode: 0644]

index f4781a5aa350265f003aca0fb1e5855092d81dc9..92067aacdcde8befeba9947d05f3aaa07a47805b 100644 (file)
@@ -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<pk>\d+)$', DetailInvoice.as_view(), name='invoice_view'),
-                url(r'^invoice/(?P<pk>\d+)/text$', invoice_text, name='invoice_view'),
+                url(r'^invoice/(?P<pk>\d+)/print$', DetailInvoicePrint.as_view(), name='invoice_print_view'),
 )
index 32f38c2fe48757d586ed92e6d71f762c9d4f0c26..68f296e9bef2bafc349031a2546b5b6765531f3c 100644 (file)
@@ -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 (file)
index 0000000..ecbb80b
--- /dev/null
@@ -0,0 +1,116 @@
+<!DOCTYPE html>
+<html lang="{{ LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif %}>
+  <head>
+    <meta charset="utf-8">
+    <title>{% block title %}{% endblock %}</title>
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <meta name="description" content="{% block description %}{% endblock %}">
+    <meta name="author" content="{% block author %}{% endblock %}">
+
+<link rel="stylesheet" type="text/css" href="/static/css/bootstrap.css" />
+
+    <style type="text/css">
+      body {
+        padding-top: 60px;
+        padding-bottom: 40px;
+      }
+      .sidebar-nav {
+        padding: 9px 0;
+      }
+      .ta-right {
+        text-align: right;
+      }
+    </style>
+  </head>
+  <body>
+    <div class="container">
+      <div class="page-header">
+       <h1>Invoice #{{invoice.id}}</h1>
+      </div>
+      <div class="row">
+       <div class="span4">
+         <ul class="unstyled">
+           <li><strong>{{invoice.customer.name}}</strong></li>
+           <li><p style="white-space: pre">{{invoice.customer.address}}</p></li>
+         </ul>
+         
+       </div>
+       
+       <div class="span4 offset4" class="border: 5px solid red">
+         <!-- Some metadata -->
+         <ul class="unstyled">
+           <li><big>err.no AS</big></li>
+           <li>Disengrenda 5b</li>
+           <li>0587 Oslo</li>
+           <li>Norway</li>
+           <li>Foretaksregisteret NO 998 270 189</li>
+           <li>info@err.no</li>
+         </ul>
+         <hr>
+         <ul class="unstyled">
+           <li>Invoice no: {{ invoice.id }}</li>
+           <li>Date: {{ invoice.date|date:"Y-m-d" }}</li>
+           <li>Due date: {{ invoice.due_date|date:"Y-m-d" }}</li>
+         </ul>
+         
+       </div>
+      </div>
+      <hr>
+
+      <div class="row">
+       <div class="span4">
+         <strong>Description</strong>
+       </div>
+       <div class="span2 ta-right">
+         <strong>Hours</strong>
+       </div>
+       <div class="span2 ta-right">
+         <strong>Rate ({{ invoice.currency }})</strong>
+       </div>
+       <div class="span2 ta-right">
+         <strong>Total</strong>
+       </div>
+      </div>
+      {% for line in invoice.invoiceline_set.all %}
+      <div class="row">
+       <div class="span4">
+         {{ line.description }}
+       </div>
+       <div class="span2 ta-right">
+           {{ line.time }}
+       </div>
+       <div class="span2 ta-right">
+         {{ line.hourly_rate }}
+       </div>
+       <div class="span2 ta-right">
+         {{ line.amount }}
+       </div>
+      </div>
+      {% endfor %}
+      <div>{{ invoice.comment }}</div>
+
+      <hr>
+      <div>Total: {{ invoice.currency }} {{ invoice.total_sum }}</div>
+
+       
+      </div>
+    </div>
+    <!-- Le javascript
+        ================================================== -->
+    <!-- Placed at the end of the document so the pages load faster -->
+    <script src="/static/js/jquery.js"></script>
+    <script src="/static/js/bootstrap-transition.js"></script>
+    <script src="/static/js/bootstrap-alert.js"></script>
+    <script src="/static/js/bootstrap-modal.js"></script>
+    <script src="/static/js/bootstrap-dropdown.js"></script>
+    <script src="/static/js/bootstrap-scrollspy.js"></script>
+    <script src="/static/js/bootstrap-tab.js"></script>
+    <script src="/static/js/bootstrap-tooltip.js"></script>
+    <script src="/static/js/bootstrap-popover.js"></script>
+    <script src="/static/js/bootstrap-button.js"></script>
+    <script src="/static/js/bootstrap-collapse.js"></script>
+    <script src="/static/js/bootstrap-carousel.js"></script>
+    <script src="/static/js/bootstrap-typeahead.js"></script>
+    
+  </body>
+</html>