summaryrefslogtreecommitdiff
path: root/project/kiwipycon/registration/pdf.py
diff options
context:
space:
mode:
authorMadhusudan.C.S2009-10-30 15:09:12 +0530
committerMadhusudan.C.S2009-10-30 15:09:12 +0530
commitf89410559c20dd88d78ccd6b9d24e7941da9d5ff (patch)
tree3ad4fb64efc7523d1f3065e0dd03693871d6ce55 /project/kiwipycon/registration/pdf.py
parent75f0773685ef0724d8ccc1eb1aab16bba55cd7a7 (diff)
downloadscipycon-f89410559c20dd88d78ccd6b9d24e7941da9d5ff.tar.gz
scipycon-f89410559c20dd88d78ccd6b9d24e7941da9d5ff.tar.bz2
scipycon-f89410559c20dd88d78ccd6b9d24e7941da9d5ff.zip
Added all the files from kiwipycon and the changes made for SciPy.in.
Diffstat (limited to 'project/kiwipycon/registration/pdf.py')
-rw-r--r--project/kiwipycon/registration/pdf.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/project/kiwipycon/registration/pdf.py b/project/kiwipycon/registration/pdf.py
new file mode 100644
index 0000000..7fec07a
--- /dev/null
+++ b/project/kiwipycon/registration/pdf.py
@@ -0,0 +1,20 @@
+import os
+
+from django.conf import settings
+from django.template.loader import render_to_string
+
+def save_invoice(user, registration, template_name):
+ content = render_to_string(template_name,
+ {'registration' : registration, 'user': user})
+ filename = '%s.html' % registration.slug
+ filepath = os.path.join(settings.USER_MEDIA_PDF, filename)
+ save_to_file(content, filepath)
+
+def save_to_pdf(content, filepath):
+ import pisa
+ pisa.CreatePDF(str(content), file(filepath, 'wb'))
+
+def save_to_file(content, filepath):
+ fout = file(filepath, 'wb')
+ fout.write(content)
+ fout.close()