diff options
author | amit@shrike.aero.iitb.ac.in | 2010-11-30 17:53:10 +0530 |
---|---|---|
committer | amit@shrike.aero.iitb.ac.in | 2010-11-30 17:53:10 +0530 |
commit | 4eba9082dfb7c94a23aa106dd2b29c8c4862f645 (patch) | |
tree | 53eedf453dd236a6e6c3e11331d9b51ff346d3d0 /project | |
parent | 3cd5011bd56213f9fecf2d2a79c3f51896604dfc (diff) | |
parent | 4bba2ee9046e924d506bc10047b29093c4733370 (diff) | |
download | scipycon-4eba9082dfb7c94a23aa106dd2b29c8c4862f645.tar.gz scipycon-4eba9082dfb7c94a23aa106dd2b29c8c4862f645.tar.bz2 scipycon-4eba9082dfb7c94a23aa106dd2b29c8c4862f645.zip |
Merging heads
Diffstat (limited to 'project')
-rw-r--r-- | project/scipycon/user/views.py | 53 | ||||
-rw-r--r-- | project/urls.py | 4 |
2 files changed, 56 insertions, 1 deletions
diff --git a/project/scipycon/user/views.py b/project/scipycon/user/views.py index 5822157..3c5e011 100644 --- a/project/scipycon/user/views.py +++ b/project/scipycon/user/views.py @@ -34,6 +34,11 @@ from django.http import Http404 #for user_dump creation from project.scipycon.registration.models import Accommodation +#Pdf badge generation +from reportlab.pdfgen import canvas +from reportlab.lib.units import cm +from reportlab.platypus import Image as reportlabImage + @login_required def account(request, scope, template_name="user/account.html"): @@ -319,3 +324,51 @@ def get_user_dump(request, scope,template_name='user/dump.html'): else: raise Http404 + + +@login_required +def badge(request,scope): + # Create the HttpResponse object with the appropriate PDF headers. + response = HttpResponse(mimetype='application/pdf') + response['Content-Disposition'] = 'attachment; filename=scipybadge.pdf' + + # Create the PDF object, using the response object as its "file." + c = canvas.Canvas(response) + + ref=5*cm + # Draw things on the PDF. Here's where the PDF generation happens. + # See the ReportLab documentation for the full list of functionality. + c.rect(ref,ref,9.45*cm,6.45*cm) + + im = reportlabImage("project/static/img/scipyshiny_small.png", width=1.75*cm, height=1.75*cm) + im.drawOn(c,(ref+0.8*cm),(ref+4.5*cm)) + c.setFont('Helvetica', 6) + c.drawString((ref+1.0*cm),(ref+4.4*cm),'scipy.in 2010') + c.drawString((ref+1.1*cm),(ref+4.2*cm),'Hyderabad') + + c.setFont('Helvetica', 12) + print request.user.id + reg_obj=Registration.objects.get(registrant=request.user.id) + + c.drawString((ref+5*cm),(ref+5*cm),str(reg_obj.slug)) + c.setFont('Helvetica-Bold', 14) + c.drawString((ref+0.6*cm),(ref+3.5*cm),str(request.user.get_full_name())) + c.setFont('Helvetica', 10) + c.drawString((ref+2.8*cm),(ref+2.8*cm),reg_obj.organisation) + c.setFont('Helvetica', 10) + try: + c.drawString((ref+2.8*cm),(ref+2.3*cm),reg_obj.occupation.split(':')[1]) + except IndexError: + c.drawString((ref+2.8*cm),(ref+2.3*cm),reg_obj.occupation) + + c.setFont('Helvetica', 10) + c.drawString((ref+2.8*cm),(ref+1.8*cm),reg_obj.city) + c.setFont('Helvetica', 10) + c.drawString((ref+2.8*cm),(ref+1*cm),'Delegate') + + + + # Close the PDF object cleanly, and we're done. + c.showPage() + c.save() + return response diff --git a/project/urls.py b/project/urls.py index 6c5ac69..b404d4c 100644 --- a/project/urls.py +++ b/project/urls.py @@ -74,7 +74,9 @@ urlpatterns += patterns('project.scipycon.user.views', url(r'^%s/get-usernames/$' % (SCOPE_ARG_PATTERN), 'get_usernames', name='scipycon_get_usernames'), url(r'^%s/get-user-dump/$' % (SCOPE_ARG_PATTERN), - 'get_user_dump', name='scipycon_get_usernames')) + 'get_user_dump', name='scipycon_get_usernames'), + url(r'^%s/badge/$' % (SCOPE_ARG_PATTERN), + 'badge', name='scipycon_badge')) # Proceedings |