From f0c44ec5f4b0513ab8b39c78476c3df736cd2bc6 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Wed, 5 Jul 2017 01:31:17 +0200 Subject: [PATCH] Filter script form by allowed course --- teleforma/exam/views.py | 2 +- teleforma/models/core.py | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) 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 -- 2.39.5