summaryrefslogtreecommitdiff
path: root/tbc/views.py
diff options
context:
space:
mode:
authorHardik Ghaghada2014-11-18 11:37:37 +0530
committerHardik Ghaghada2014-11-18 11:37:37 +0530
commitf274a1c41d6bb94229fffde4d9c30afece3f5c4f (patch)
tree7a11f3723a1fa7d066c24df5f7d42bd5fb9af63f /tbc/views.py
parent091035077a129dd14b1bb83cc5552956e1cac2e0 (diff)
parent475a7b16aa8c24ff2d42e71a84db32949c0f4cf8 (diff)
downloadPython-TBC-Interface-f274a1c41d6bb94229fffde4d9c30afece3f5c4f.tar.gz
Python-TBC-Interface-f274a1c41d6bb94229fffde4d9c30afece3f5c4f.tar.bz2
Python-TBC-Interface-f274a1c41d6bb94229fffde4d9c30afece3f5c4f.zip
Merge pull request #5 from prathamesh920/link_chapters_images
Screenshots will be linked to corresponding chapter
Diffstat (limited to 'tbc/views.py')
-rwxr-xr-xtbc/views.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tbc/views.py b/tbc/views.py
index d5ff195..cc3d12c 100755
--- a/tbc/views.py
+++ b/tbc/views.py
@@ -738,6 +738,7 @@ def SubmitCode(request):
curr_book = curr_proposal.accepted
except:
return HttpResponseRedirect('/?no_book_alloted=true')
+ dict = {}
if curr_proposal.status == "codes disapproved":
if request.method == 'POST':
chapters = Chapters.objects.filter(book=curr_book)
@@ -746,6 +747,8 @@ def SubmitCode(request):
for chapter in chapters:
chapter.name = request.POST['chapter'+str(counter)]
chapter.notebook = request.FILES['notebook'+str(counter)]
+ dict['chapter'+str(counter)] = chapter.name
+ chapter.screen_shots.clear()
chapter.save()
counter += 1
counter = 1
@@ -753,6 +756,12 @@ def SubmitCode(request):
screenshot.caption = request.POST['caption'+str(counter)]
screenshot.image = request.FILES['image'+str(counter)]
screenshot.save()
+ chapter_image = request.POST['chapter_image'+str(counter)]
+ # if chapter name is unique then no need to convert the query
+ # set to list. Instead of filter get can be used then.
+ chapter = list(Chapters.objects.filter(name=dict[chapter_image]))[-1]
+ chapter.screen_shots.add(screenshot)
+ chapter.save()
counter += 1
curr_proposal.status = "codes submitted"
curr_proposal.save()
@@ -763,6 +772,7 @@ def SubmitCode(request):
for i in range(1, curr_book.no_chapters+1):
chapter = Chapters()
chapter.name = request.POST['chapter'+str(i)]
+ dict['chapter'+str(i)] = chapter.name
chapter.notebook = request.FILES['notebook'+str(i)]
chapter.book = curr_book
chapter.save()
@@ -772,6 +782,10 @@ def SubmitCode(request):
screenshot.image = request.FILES['image'+str(i)]
screenshot.book = curr_book
screenshot.save()
+ chapter_image = request.POST['chapter_image'+str(i)]
+ chapter = list(Chapters.objects.filter(name=dict[chapter_image]))[-1]
+ chapter.screen_shots.add(screenshot)
+ chapter.save()
book = Book.objects.order_by("-id")[0]
proposal = Proposal.objects.get(accepted=book)
proposal.status = "codes submitted"