def __init__(self, selected_person, *args, **kwargs): super(ContinuingEducationPersonForm, self).__init__(*args, **kwargs) if not selected_person: set_participant_required_fields( self.fields, ADMISSION_PARTICIPANT_REQUIRED_FIELDS, True)
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 user.has_perm('continuing_education.link_admission_to_academic_year', obj=self.instance): 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 self.instance and self.instance.state not in STATES_ACADEMIC_YEAR_MANDATORY: self.fields['academic_year'].required = False if user and not user.has_perm('continuing_education.manage_all_trainings'): self.fields['formation'].queryset = self.fields['formation'].queryset.filter( managers=user.person ) set_participant_required_fields(self.fields, ADMISSION_PARTICIPANT_REQUIRED_FIELDS) self.fields['email'].required = True self.fields['formation'].queryset = ContinuingEducationTraining.objects.formations().select_related( 'education_group' )
def __init__(self, selected_person, no_first_name_checked, *args, **kwargs): super(PersonForm, self).__init__(*args, **kwargs) if not selected_person: set_participant_required_fields( self.fields, ADMISSION_PARTICIPANT_REQUIRED_FIELDS, True) self.fields['gender'].initial = IUFC_GENDER_CHOICES[0] if no_first_name_checked: self.fields['first_name'].required = False
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)