diff options
author | luxagraf <sng@luxagraf.net> | 2019-01-13 11:51:02 -0600 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2019-01-13 11:51:02 -0600 |
commit | c4da428fc9ec439389b7473ba5638d9f82085475 (patch) | |
tree | 2c135804e201b3008fe56db25d993881a49da686 /app/income/views.py | |
parent | 120021d565eefa0318c487f0ff5707c7b9893b43 (diff) |
updated income and resume apps
Diffstat (limited to 'app/income/views.py')
-rw-r--r-- | app/income/views.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/app/income/views.py b/app/income/views.py index 2c3e34a..fc22c0d 100644 --- a/app/income/views.py +++ b/app/income/views.py @@ -20,8 +20,7 @@ class MonthlyInvoiceView(DetailView): total_time = [] for item in context['object_list']: total_time.append(item.rounded_total) - duration = (sum(total_time, datetime.timedelta())) - hours = duration.total_seconds() // 3600 + hours = (sum(total_time)) context['total_hours'] = hours context['total_billed'] = int(hours * 100) context['invoice_number'] = self.object.id+21 @@ -37,10 +36,17 @@ class DownloadMonthlyInvoiceView(MonthlyInvoiceView): logger = logging.getLogger('weasyprint') logger.addHandler(logging.FileHandler('weasyprint.log')) self.object = self.get_object() # assign the object to the view - c = {'object': self.object} + context = self.get_context_data() + c = { + 'object': self.object, + 'object_list': context['object_list'], + 'total_hours': context['total_hours'], + 'total_billed': context['total_billed'], + 'invoice_number': self.object.id+23 + } t = render_to_string('details/invoice.html', c).encode('utf-8') html = HTML(string=t, base_url=self.request.build_absolute_uri()) - pdf = html.write_pdf(stylesheets=[CSS(settings.MEDIA_ROOT + 'site/media/pdf_gen.css')], presentational_hints=True) + pdf = html.write_pdf(stylesheets=[CSS(settings.MEDIA_ROOT + '/pdf_gen.css')], presentational_hints=True) response = HttpResponse(pdf, content_type='application/pdf') response['Content-Disposition'] = 'inline; filename="invoice.pdf"' return response |