]> git.parisson.com Git - teleforma.git/commitdiff
remove automatic teacher selection with postman : https://trackers.pilotsystems.net...
authorYoan Le Clanche <yoan@ellington.pilotsystems.net>
Thu, 25 Apr 2019 13:30:18 +0000 (15:30 +0200)
committerYoan Le Clanche <yoan@ellington.pilotsystems.net>
Thu, 25 Apr 2019 13:30:18 +0000 (15:30 +0200)
teleforma/fields.py
teleforma/forms.py
teleforma/templates/postman/base_write.html

index 9a9d9c5f3f5e1537c7108de60d219612f5127a14..76b15eb727716af74d7ca0c21b269566efc084cc 100644 (file)
@@ -2,7 +2,6 @@
 import django.db.models as models
 from django.forms import ModelForm, TextInput, Textarea
 from south.modelsinspector import add_introspection_rules
-from postman.fields import BasicCommaSeparatedUserField as PostmanBasicCommaSeparatedUserField
 from django.core.exceptions import ValidationError
 
 try:
@@ -23,40 +22,3 @@ add_introspection_rules([], ["^teleforma\.fields\.ShortTextField"])
 
 
 
-class BasicCommaSeparatedUserField(PostmanBasicCommaSeparatedUserField):
-    def clean(self, value):
-        """Check names are valid and filter them."""
-        names = super(PostmanBasicCommaSeparatedUserField, self).clean(value)
-        if not names:
-            return []
-        user_model = get_user_model()
-        users = list(user_model.objects.filter(is_active=True, **{'{0}__in'.format(user_model.USERNAME_FIELD): names}))
-        unknown_names = set(names) ^ set([u.get_username() for u in users])
-        errors = []
-
-        if unknown_names == set(['auto']):
-            return 'auto'
-
-        if unknown_names:
-            errors.append(self.error_messages['unknown'].format(users=', '.join(unknown_names)))
-
-        if self.user_filter:
-            filtered_names = []
-            for u in users[:]:
-                try:
-                    reason = self.user_filter(u)
-                    if reason is not None:
-                        users.remove(u)
-                        filtered_names.append(
-                            self.error_messages[
-                                'filtered_user_with_reason' if reason else 'filtered_user'
-                            ].format(username=u.get_username(), reason=reason)
-                        )
-                except ValidationError as e:
-                    users.remove(u)
-                    errors.extend(e.messages)
-            if filtered_names:
-                errors.append(self.error_messages['filtered'].format(users=', '.join(filtered_names)))
-        if errors:
-            raise ValidationError(errors)
-        return users
\ No newline at end of file
index 2e25878a4fcc24f0bd1726504feffeb053b9e1f3..998ab42e479260d45355fa230eb3e377ccaa4f41 100644 (file)
@@ -1,7 +1,6 @@
 from django.forms import ModelForm, ModelChoiceField
 from postman.forms import WriteForm as PostmanWriteForm
-
-from teleforma.fields import BasicCommaSeparatedUserField
+from postman.fields import BasicCommaSeparatedUserField
 from teleforma.models import *
 from registration.forms import RegistrationForm
 from django.utils.translation import ugettext_lazy as _
@@ -111,22 +110,4 @@ class WriteForm(PostmanWriteForm):
         """compute recipient if 'auto' is set"""
         recipients = self.cleaned_data['recipients']
         course = self.cleaned_data.get('course')
-        if recipients == 'auto':
-            professors = Professor.objects.filter(courses__in=[course]).order_by('user__last_name').all()
-            if course.last_professor_sent:
-                try:
-                    index = list(professors).index(course.last_professor_sent)
-                except ValueError:
-                    index = 0
-
-                if index < len(professors)-1:
-                    professor = professors[index+1]
-                else:
-                    professor = professors[0]
-            else:
-                professor = professors[0]
-            course.last_professor_sent = professor
-            course.save()
-            recipients = [professor.user,]
-
         return recipients
\ No newline at end of file
index d3eb8d325d57b5bade5c22ada9e9c01496c2b3a9..f0be07525258aad343e27e2038aa32f6541559a7 100644 (file)
@@ -56,7 +56,7 @@
                     </select>
 
                     <select id="_professorSelect" name="professors">
-                        <option value="auto">N'importe quel professeur</option>
+                        <option value="">Choisir un professeur</option>
                         {% get_all_professors_with_courses as professors %}
                         {% for p in professors %}
                             <option value="{{ p.username }}"
             if($('#_adminSelect').val() && recipientCategory === 'admin')
                 $("#id_recipients").val($('#_adminSelect').val());
 
-            if($("#id_recipients").val()==='auto')
-                $('#id_recipients').parent().parent().hide();
-            else
-                $('#id_recipients').parent().parent().show();
         }
 
         // hide recipients fields