From: Guillaume Pellerin Date: Tue, 4 Jul 2017 22:54:22 +0000 (+0200) Subject: Fix all upload views X-Git-Tag: 1.1~10 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=ef37e6e8191b3f4e54c5f4214ec0514da09a1b61;p=teleforma.git Fix all upload views --- diff --git a/teleforma/exam/views.py b/teleforma/exam/views.py index 7c147f9a..022bd640 100644 --- a/teleforma/exam/views.py +++ b/teleforma/exam/views.py @@ -176,8 +176,13 @@ class ScriptCreateView(CreateView): def get_context_data(self, **kwargs): context = super(ScriptCreateView, self).get_context_data(**kwargs) - context['upload'] = (getattr(settings, 'TELEFORMA_EXAM_SCRiIPT_UPLOAD', True) or self.request.user.is_superuser) - context['period'] = Period.objects.get(id=self.kwargs['period_id']) + period = Period.objects.get(id=self.kwargs['period_id']) + context['period'] = period + if getattr(settings, 'TELEFORMA_EXAM_SCRIPT_UPLOAD', True) and period.date_exam_end: + context['upload'] = datetime.datetime.now() <= period.date_exam_end + else: + context['upload'] = False + context['period'] = period context['create_fields'] = ['course', 'session', 'type', 'file' ] course_pk_list = [c['course'].id for c in get_courses(self.request.user)] context['form'].fields['course'].queryset = Course.objects.filter(pk__in=course_pk_list) @@ -344,12 +349,6 @@ class ScoreCreateView(ScriptCreateView): def get_context_data(self, **kwargs): context = super(ScriptCreateView, self).get_context_data(**kwargs) - period = Period.objects.get(id=self.kwargs['period_id']) - context['period'] = period - if getattr(settings, 'TELEFORMA_EXAM_SCRIPT_UPLOAD', True) and period.date_exam_end: - context['upload'] = datetime.datetime.now() <= period.date_exam_end - else: - context['upload'] = False context['create_fields'] = ['course', 'session', 'type', 'score' ] course_pk_list = [c['course'].id for c in get_courses(self.request.user)] context['form'].fields['course'].queryset = Course.objects.filter(pk__in=course_pk_list)