コード例 #1
0
 def test_is_continuing_education_manager(self):
     self.assertFalse(
         perms.is_continuing_education_manager(self.training_manager.user))
     self.assertTrue(
         perms.is_continuing_education_manager(self.manager.user))
     self.assertFalse(
         perms.is_continuing_education_manager(self.student_worker.user))
コード例 #2
0
def filter_authorized_admissions(user, admission_list):
    if not is_continuing_education_manager(user):
        person_trainings = PersonTraining.objects.filter(
            person=user.person).values_list('training', flat=True)
        admission_list = admission_list.filter(
            formation_id__in=person_trainings)
    return admission_list
コード例 #3
0
 def __init__(self, data, user=None, **kwargs):
     super().__init__(data=data, **kwargs)
     self.fields['additional_information_label'].widget.attrs[
         'placeholder'] = _(
             "Describe here additional information that will be asked to the participant:\n"
             "- as a list of question(s) - maximum 1 sentence by question \n"
             "- numbered 1., 2., 3.,... if multiple questions \n\n"
             "This text will appear the same on the participant's admission form\n\n"
             "Example: \n"
             "1. What is your pedagogical title ? \n"
             "2. ...")
     if user and not is_continuing_education_manager(user):
         self.fields['active'].disabled = True
コード例 #4
0
    def __init__(self, data, user=None, **kwargs):
        super().__init__(data, **kwargs)
        try:
            starting_year = AcademicYear.objects.current().year
            self.fields['academic_year'].queryset = AcademicYear.objects.filter(year__gte=starting_year - 2)\
                .order_by('year')
        except AttributeError:
            self.fields['academic_year'].queryset = AcademicYear.objects.none()

        if user and is_continuing_education_manager(user):
            self.fields['academic_year'].disabled = False
            self.fields['academic_year'].required = True
        else:
            self.fields['academic_year'].disabled = True
            self.fields['academic_year'].required = False

        if user and not user.groups.filter(
                name='continuing_education_managers').exists():
            self.fields['formation'].queryset = self.fields[
                'formation'].queryset.filter(managers=user.person)
        set_participant_required_fields(self.fields,
                                        ADMISSION_PARTICIPANT_REQUIRED_FIELDS)
コード例 #5
0
def _can_edit_formation(request, formation):
    person_trainings = PersonTraining.objects.filter(
        person=request.user.person).values_list('training', flat=True)
    return formation.id in person_trainings or is_continuing_education_manager(
        request.user)