summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tbc/templates/tbc/get-certificate.html32
-rw-r--r--tbc/urls.py1
-rwxr-xr-xtbc/views.py44
3 files changed, 39 insertions, 38 deletions
diff --git a/tbc/templates/tbc/get-certificate.html b/tbc/templates/tbc/get-certificate.html
new file mode 100644
index 0000000..e54763d
--- /dev/null
+++ b/tbc/templates/tbc/get-certificate.html
@@ -0,0 +1,32 @@
+{% extends 'base.html' %}
+{% load static %}
+
+{% block content %}
+ <center><h3>Book(s) completed by you</h3></center>
+ <table class="table table-bordered table-hover">
+ <th>Sr #</th>
+ <th>Book</th>
+ <th>Certificate Link
+ {% for book in books %}
+ <tr>
+ <td>
+ {{ forloop.counter }}
+ </td>
+ <td>
+ {{ book.title }} by {{ book.author }}, {{ book.edition }} Edition
+ </td>
+ <td>
+ <a class="btn btn-primary" href="{% url 'tbc:GetCertificate' book.id %}">Get Certificate</a>
+ </td>
+ </tr>
+ {% endfor %}
+ </table>
+{% endblock %}
+
+
+
+
+ {% for book in completed_books %}
+
+ {% endfor %}
+ </table>
diff --git a/tbc/urls.py b/tbc/urls.py
index 413374d..75a9a7d 100644
--- a/tbc/urls.py
+++ b/tbc/urls.py
@@ -36,6 +36,7 @@ urlpatterns = patterns('',
url(r'^books-under-progress/$', 'tbc.views.BooksUnderProgress', name='BooksUnderProgress'),
url(r'^redirect-ipynb/(?P<notebook_path>.+)$', 'tbc.views.RedirectToIpynb', name='RedirectToIpynb'),
url(r'^get-certificate/$', 'tbc.views.GetCertificate', name='GetCertificate'),
+ url(r'^get-certificate/(?P<book_id>\d+)/$', 'tbc.views.GetCertificate', name='GetCertificate'),
url(r'^book-review/$', 'tbc.views.BookReview', name='BookReview'),
diff --git a/tbc/views.py b/tbc/views.py
index 13fe26a..10b96dc 100755
--- a/tbc/views.py
+++ b/tbc/views.py
@@ -1132,50 +1132,18 @@ def BooksUnderProgress(request):
return render_to_response('tbc/books_under_progress.html', context)
-def GetCertificate(request):
+def GetCertificate(request, book_id=None):
user = request.user
user_profile = Profile.objects.get(user=user)
books = Book.objects.filter(contributor=user_profile, approved=True)
context = {}
context['user'] = user
context['books'] = books
- width, height = A4
- styles = getSampleStyleSheet()
- styleN = styles["BodyText"]
- styleN.alignment = TA_LEFT
- styleBH = styles["Normal"]
- styleBH.alignment = TA_CENTER
- def coord(x, y, unit=1):
- x, y = x * unit, height - y * unit
- return x, y
- # Headers
- hdescrpcion = Paragraph('''<b>descrpcion</b>''', styleBH)
- hpartida = Paragraph('''<b>partida</b>''', styleBH)
- hcandidad = Paragraph('''<b>candidad</b>''', styleBH)
- hprecio_unitario = Paragraph('''<b>precio_unitario</b>''', styleBH)
- hprecio_total = Paragraph('''<b>precio_total</b>''', styleBH)
- # Texts
- descrpcion = Paragraph('long paragraph', styleN)
- partida = Paragraph('1', styleN)
- candidad = Paragraph('120', styleN)
- precio_unitario = Paragraph('$52.00', styleN)
- precio_total = Paragraph('$6240.00', styleN)
- data= [[hdescrpcion, hcandidad,hcandidad, hprecio_unitario, hprecio_total],
- [partida, candidad, descrpcion, precio_unitario, precio_total]]
- table = Table(data, colWidths=[2.05 * cm, 2.7 * cm, 5 * cm,
- 3* cm, 3 * cm])
- table.setStyle(TableStyle([
- ('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
- ('BOX', (0,0), (-1,-1), 0.25, colors.black),
- ]))
- c = canvas.Canvas("a.pdf", pagesize=A4)
- table.wrapOn(c, width, height)
- table.drawOn(c, *coord(1.8, 9.6, cm))
- c.save()
- response = HttpResponse(content_type='application/pdf')
- response['Content-Disposition'] = c
- # Create the PDF object, using the response object as its "file."
- return response
+ if book_id:
+ book = Book.objects.get(id=book_id)
+ #replace this with the code for certificate.
+ return HttpResponse(book.title)
+ return render_to_response('tbc/get-certificate.html', context)
def RedirectToIpynb(request, notebook_path=None):