]> git.parisson.com Git - teleforma.git/commitdiff
Allow auto exam ending thanks to Period date property
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Tue, 4 Jul 2017 22:44:30 +0000 (00:44 +0200)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Tue, 4 Jul 2017 22:44:30 +0000 (00:44 +0200)
teleforma/exam/views.py
teleforma/models/core.py

index f863d0f47bb741b6ba98150995ca34d8aee8380d..8abb8dda3f81ecdc7118cd2800cdcdee13425367 100644 (file)
@@ -344,8 +344,9 @@ class ScoreCreateView(ScriptCreateView):
 
     def get_context_data(self, **kwargs):
         context = super(ScriptCreateView, self).get_context_data(**kwargs)
-        context['upload'] = getattr(settings, 'TELEFORMA_EXAM_SCRIPT_UPLOAD', True)
-        context['period'] = Period.objects.get(id=self.kwargs['period_id'])
+        period = Period.objects.get(id=self.kwargs['period_id'])
+        context['period'] = period
+        context['upload'] = datetime.datetime.now() <= period.date_exam_end
         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)
index d78e88033f780f54d227d438cb547db63e3b1844..81cd02b7df36d02c03a3508d094de814bea7c5dc 100644 (file)
@@ -135,6 +135,7 @@ class Period(Model):
     message_platform = models.TextField(_('message pour internaute'), blank=True)
     message_local = models.TextField(_('message pour presentielle'), blank=True)
     is_open = models.BooleanField(_('is open'), default=True)
+    date_exam_end = models.DateTimeField(_("date de fin d'examens"), null=True, blank=True)
 
     def __unicode__(self):
         return self.name