From: Guillaume Pellerin Date: Tue, 4 Jul 2017 23:31:17 +0000 (+0200) Subject: Filter script form by allowed course X-Git-Tag: 1.1~5 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=f0c44ec5f4b0513ab8b39c78476c3df736cd2bc6;p=teleforma.git Filter script form by allowed course --- diff --git a/teleforma/exam/views.py b/teleforma/exam/views.py index dc6560ee..4de61a3d 100644 --- a/teleforma/exam/views.py +++ b/teleforma/exam/views.py @@ -184,7 +184,7 @@ class ScriptCreateView(ScriptMixinView, CreateView): def get_context_data(self, **kwargs): context = super(ScriptCreateView, self).get_context_data(**kwargs) context['create_fields'] = ['course', 'session', 'type', 'file' ] - course_pk_list = [c['course'].id for c in get_courses(self.request.user)] + course_pk_list = [c['course'].id for c in get_courses(self.request.user) if c.exam_scripts] context['form'].fields['course'].queryset = Course.objects.filter(pk__in=course_pk_list) return context diff --git a/teleforma/models/core.py b/teleforma/models/core.py index 81cd02b7..dbe2cad2 100644 --- a/teleforma/models/core.py +++ b/teleforma/models/core.py @@ -160,22 +160,23 @@ class CourseType(Model): class Course(Model): - department = models.ForeignKey('Department', related_name='course', + department = models.ForeignKey('Department', related_name='course', verbose_name=_('department')) - title = models.CharField(_('title'), max_length=255) - description = models.CharField(_('description'), max_length=255, blank=True) - code = models.CharField(_('code'), max_length=255) - title_tweeter = models.CharField(_('tweeter title'), max_length=255) - date_modified = models.DateTimeField(_('date modified'), auto_now=True, null=True) - number = models.IntegerField(_('number'), blank=True, null=True) - synthesis_note = models.BooleanField(_('synthesis note')) - obligation = models.BooleanField(_('obligations')) - magistral = models.BooleanField(_('magistral')) + title = models.CharField(_('title'), max_length=255) + description = models.CharField(_('description'), max_length=255, blank=True) + code = models.CharField(_('code'), max_length=255) + title_tweeter = models.CharField(_('tweeter title'), max_length=255) + date_modified = models.DateTimeField(_('date modified'), auto_now=True, null=True) + number = models.IntegerField(_('number'), blank=True, null=True) + synthesis_note = models.BooleanField(_('synthesis note')) + obligation = models.BooleanField(_('obligations')) + magistral = models.BooleanField(_('magistral')) procedure = models.BooleanField(_('procedure')) written_speciality = models.BooleanField(_('written_speciality')) oral_speciality = models.BooleanField(_('oral_speciality')) oral_1 = models.BooleanField(_('oral_1')) oral_2 = models.BooleanField(_('oral_2')) + exam_scripts = models.BooleanField(_("copies d'examen"), default=True) def __unicode__(self): return self.title