]> git.parisson.com Git - teleforma.git/commitdiff
Exam : remove 'type' field on "add exam form"
authorYoan Le Clanche <yoanl@pilotsystems.net>
Thu, 2 Jul 2020 09:34:40 +0000 (11:34 +0200)
committerYoan Le Clanche <yoanl@pilotsystems.net>
Thu, 2 Jul 2020 09:34:40 +0000 (11:34 +0200)
teleforma/exam/forms.py
teleforma/exam/models.py
teleforma/exam/views.py

index d695091449a4753604e990abfc1d75b4314f916f..1f5784621f325ab2a2858563789245e999fa1be0 100644 (file)
@@ -22,7 +22,7 @@ class ScriptForm(ModelForm):
 
     class Meta:
         model = Script
-        exclude = ['uuid', 'mime_type', 'sha1', 'url',
+        exclude = ['uuid', 'mime_type', 'sha1', 'url', 'type'
                     'date_submitted', 'date_rejected', 'date_marked',
                     'box_uuid',]
         #hidden_fields = ['status']
index fe7828accb8252f9d804ff97257faf52942ce699..3c78b09febc014703bbdd7afddc36ace3db71156 100755 (executable)
@@ -252,7 +252,7 @@ class Script(BaseResource):
     period = models.ForeignKey(Period, related_name='scripts', verbose_name=_('period'),
                                  null=True, blank=True, on_delete=models.SET_NULL)
     session = models.CharField(_('session'), max_length=16, default="1")
-    type = models.ForeignKey(ScriptType, related_name='scripts', verbose_name=_('type'), null=True, on_delete=models.SET_NULL)
+    type = models.ForeignKey(ScriptType, related_name='scripts', verbose_name=_('type'), null=True, blank=True, on_delete=models.SET_NULL)
     author = models.ForeignKey(User, related_name="author_scripts", verbose_name=_('author'), null=True, blank=True, on_delete=models.SET_NULL)
     corrector = models.ForeignKey(User, related_name="corrector_scripts", verbose_name=_('corrector'), blank=True, null=True, on_delete=models.SET_NULL)
     file = models.FileField(_('PDF file'), upload_to='scripts/%Y/%m/%d', max_length=1024, blank=True)
index 993247cb6a55525615a05557084d7bd4ec25e0da..99cf014c3b69cc59310a438814ce2c9ad9445a44 100755 (executable)
@@ -246,7 +246,7 @@ class ScriptCreateView(ScriptMixinView, CreateView):
 
     def form_valid(self, form):
         scripts = Script.objects.filter(course=form.cleaned_data['course'], session=form.cleaned_data['session'],
-                                        type=form.cleaned_data['type'], author=self.request.user, period=self.period).exclude(status=0)
+                                        author=self.request.user, period=self.period).exclude(status=0)
         if scripts:
             messages.error(self.request, _("Error: you have already submitted a script for this session, the same course and the same type!"))
             return redirect('teleforma-exam-script-create', self.period.id)
@@ -261,7 +261,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' ]
+        context['create_fields'] = ['course', 'session', 'file' ]
         context['form'].fields['course'].queryset = context['courses']
         return context
 
@@ -515,7 +515,6 @@ def get_mass_students(request):
     session = request.GET.get('session')
     course_id = request.GET.get('course_id')
     q = request.GET.get('q[term]')
-    # import pdb;pdb.set_trace()
     students = Student.objects.filter(period = period).filter(Q(user__username__icontains=q) | Q(user__last_name__icontains=q) | Q(user__first_name__icontains=q))
 
     # Exclude students who already have a script for this session