project/scipycon/user/views.py
changeset 333 142f7f94de19
parent 325 1255f442e4f8
equal deleted inserted replaced
332:2eb286e89615 333:142f7f94de19
   327             raise Http404
   327             raise Http404
   328 
   328 
   329 
   329 
   330 @login_required
   330 @login_required
   331 def badge(request,scope):
   331 def badge(request,scope):
       
   332 
       
   333     from django.conf import settings
       
   334 
   332     # Create the HttpResponse object with the appropriate PDF headers.
   335     # Create the HttpResponse object with the appropriate PDF headers.
   333     response = HttpResponse(mimetype='application/pdf')
   336     response = HttpResponse(mimetype='application/pdf')
   334     response['Content-Disposition'] = 'attachment; filename=scipybadge.pdf'
   337     response['Content-Disposition'] = 'attachment; filename=scipybadge.pdf'
   335 
   338 
   336     # Create the PDF object, using the response object as its "file."
   339     # Create the PDF object, using the response object as its "file."
   339     ref=5*cm
   342     ref=5*cm
   340     # Draw things on the PDF. Here's where the PDF generation happens.
   343     # Draw things on the PDF. Here's where the PDF generation happens.
   341     # See the ReportLab documentation for the full list of functionality.
   344     # See the ReportLab documentation for the full list of functionality.
   342     c.rect(ref,ref,9*cm,6*cm)
   345     c.rect(ref,ref,9*cm,6*cm)
   343 
   346 
   344     im = reportlabImage("project/static/img/scipyshiny_small.png", width=1.75*cm, height=1.75*cm)
   347     img_path = os.path.join(settings.STATIC_ROOT, 'img', 'scipyshiny_small.png')
       
   348     im = reportlabImage(img_path, width=1.75*cm, height=1.75*cm)
   345     im.drawOn(c,(ref+0.8*cm),(ref+4.3*cm))
   349     im.drawOn(c,(ref+0.8*cm),(ref+4.3*cm))
   346     c.setFont('Helvetica', 6)
   350     c.setFont('Helvetica', 6)
   347     c.drawString((ref+1.0*cm),(ref+4.2*cm),'scipy.in 2010') 
   351     c.drawString((ref+1.0*cm),(ref+4.2*cm),'scipy.in 2010') 
   348     c.drawString((ref+1.1*cm),(ref+4.0*cm),'Hyderabad') 
   352     c.drawString((ref+1.1*cm),(ref+4.0*cm),'Hyderabad') 
   349 
   353