From: Guillaume Pellerin Date: Fri, 30 Jan 2015 12:37:00 +0000 (+0100) Subject: add script period detection X-Git-Tag: 1.1~299 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=eaeb28a650ea23150f8088e28c0cab422b65f438;p=teleforma.git add script period detection --- diff --git a/teleforma/exam/views.py b/teleforma/exam/views.py index 2154d9e0..765a5f45 100644 --- a/teleforma/exam/views.py +++ b/teleforma/exam/views.py @@ -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