From ab992e3da65de1ad9ab18a6496007dc3a3fc6295 Mon Sep 17 00:00:00 2001 From: hardythe1 Date: Tue, 8 Jul 2014 13:27:12 +0530 Subject: adding changes to link the screen shots to respective chapters --- tbc/models.py | 1 + tbc/templates/tbc/book-details.html | 2 +- tbc/templates/tbc/upload-content.html | 2 +- tbc/views.py | 2 ++ 4 files changed, 5 insertions(+), 2 deletions(-) (limited to 'tbc') diff --git a/tbc/models.py b/tbc/models.py index 76c9dc6..56ea268 100644 --- a/tbc/models.py +++ b/tbc/models.py @@ -101,6 +101,7 @@ class ScreenShots(models.Model): caption = models.CharField(max_length=128) image = models.FileField(upload_to=get_image_dir) book = models.ForeignKey(Book) + chapter = models.ForeignKey(Chapters) def __unicode__(self): name = self.caption or 'ScreenShots' return '%s'%(name) diff --git a/tbc/templates/tbc/book-details.html b/tbc/templates/tbc/book-details.html index 3099063..6684244 100644 --- a/tbc/templates/tbc/book-details.html +++ b/tbc/templates/tbc/book-details.html @@ -19,7 +19,7 @@ function redirectToIpynb(notebook)
Upload screenshots of Plots/Graphs/Charts(if any) "that you have plotted" and not from the textbook itself from any cahpter. If there are no plots/graphs/charts, then upload a screenshot of any chapter. Give proper captions for each of them. Only .png files are acceptable.
+Upload screenshots of Plots/Graphs/Charts(if any) "that you have plotted" and not from the textbook itself from any cahpter. If there are no plots/graphs/charts, then upload a screenshot of any chapter. Also give the name of the chapter the screen shot is taken from. The name of the chapter you give should match the name of the chapter given above for its .ipynb file. Only .png files are acceptable.
{% for i in no_images %} diff --git a/tbc/views.py b/tbc/views.py index bc3913b..f45df40 100755 --- a/tbc/views.py +++ b/tbc/views.py @@ -348,6 +348,8 @@ def ContentUpload(request, book_id=None): screenshot = ScreenShots() screenshot.caption = request.POST['caption'+str(i)] screenshot.image = request.FILES['image'+str(i)] + chapter = Chapters.objects.get(name=request.POST['caption'+str(i)], book=curr_book) + screenshot.chapter = chapter screenshot.book = curr_book screenshot.save() book = Book.objects.order_by("-id")[0] -- cgit