equal
deleted
inserted
replaced
|
1 import os |
|
2 |
|
3 from django.conf import settings |
|
4 from django.template.loader import render_to_string |
|
5 |
|
6 def save_invoice(user, registration, template_name): |
|
7 content = render_to_string(template_name, |
|
8 {'registration' : registration, 'user': user}) |
|
9 filename = '%s.html' % registration.slug |
|
10 filepath = os.path.join(settings.USER_MEDIA_PDF, filename) |
|
11 save_to_file(content, filepath) |
|
12 |
|
13 def save_to_pdf(content, filepath): |
|
14 import pisa |
|
15 pisa.CreatePDF(str(content), file(filepath, 'wb')) |
|
16 |
|
17 def save_to_file(content, filepath): |
|
18 fout = file(filepath, 'wb') |
|
19 fout.write(content) |
|
20 fout.close() |