]> git.parisson.com Git - teleforma.git/commitdiff
add script period detection
authorGuillaume Pellerin <yomguy@parisson.com>
Fri, 30 Jan 2015 12:37:00 +0000 (13:37 +0100)
committerGuillaume Pellerin <yomguy@parisson.com>
Fri, 30 Jan 2015 12:37:00 +0000 (13:37 +0100)
teleforma/exam/views.py

index 2154d9e037a7dfb169575f57649cf9eb3925cb7a..765a5f45954565d4530165cf2af1ae78f50cfc41 100644 (file)
@@ -15,7 +15,10 @@ class ScriptView(CourseAccessMixin, UpdateView):
     model = Script
     template_name='exam/script_detail.html'
     form_class = ScriptForm
-    success_url = reverse_lazy('teleforma-exam-scripts-pending', kwargs={'period_id':1})
+
+    def get_success_url(self):
+        period = Period.objects.get(id=self.kwargs['period_id'])
+        return reverse_lazy('teleforma-exam-scripts-pending', kwargs={'period_id':period.id})
 
     def get_context_data(self, **kwargs):
         context = super(ScriptView, self).get_context_data(**kwargs)
@@ -123,7 +126,10 @@ class ScriptCreateView(CreateView):
     model = Script
     template_name='exam/script_form.html'
     form_class = ScriptForm
-    success_url = reverse_lazy('teleforma-exam-scripts-pending', kwargs={'period_id':1})
+    
+    def get_success_url(self):
+        period = Period.objects.get(id=self.kwargs['period_id'])
+        return reverse_lazy('teleforma-exam-scripts-pending', kwargs={'period_id':period.id})
 
     def form_valid(self, form):
         form.instance.author = self.request.user