def __init__(self, data, person, subtype, *args, **kwargs): super().__init__(data, *args, **kwargs) self.instance.subtype = subtype self.person = person acronym = self.initial.get('acronym') if acronym: self.initial['acronym'] = split_acronym(acronym, subtype) if subtype == learning_unit_year_subtypes.PARTIM: self.fields['acronym'] = PartimAcronymField() self.fields['specific_title'].label = _( 'official_title_proper_to_partim') self.fields['specific_title_english'].label = _( 'official_english_title_proper_to_partim') # Disabled fields when it's an update if self.instance.pk: self.fields['academic_year'].disabled = True # we cannot edit the internship subtype if the container_type is not internship if self.instance.learning_container_year.container_type != INTERNSHIP: self.fields['internship_subtype'].disabled = True self.fields['campus'].queryset = find_main_campuses() self.fields['language'].queryset = find_all_languages()
def _get_initial_learning_unit_year_form(self): acronym = self.instance.acronym if self.instance else self.learning_unit_year_full.acronym initial_learning_unit_year = { 'acronym': acronym, 'academic_year': self.learning_unit_year_full.academic_year.id, 'internship_subtype': self.learning_unit_year_full.internship_subtype, 'attribution_procedure': self.learning_unit_year_full.attribution_procedure, 'subtype': self.subtype, 'credits': self.learning_unit_year_full.credits, 'session': self.learning_unit_year_full.session, 'quadrimester': self.learning_unit_year_full.quadrimester, 'status': self.learning_unit_year_full.status, 'specific_title': self.learning_unit_year_full.specific_title, 'specific_title_english': self.learning_unit_year_full.specific_title_english, 'language': self.learning_unit_year_full.language, 'campus': self.learning_unit_year_full.campus, 'periodicity': self.learning_unit_year_full.periodicity } acronym_splited = split_acronym(acronym, instance=self.instance) initial_learning_unit_year.update({ "acronym_{}".format(idx): acronym_part for idx, acronym_part in enumerate(acronym_splited) }) return initial_learning_unit_year
def __init__(self, data, person, subtype, *args, external=False, **kwargs): super().__init__(data, *args, **kwargs) self.external = external self.instance.subtype = subtype self.person = person acronym = self.initial.get('acronym') if acronym: self.initial['acronym'] = split_acronym(acronym, subtype, instance=self.instance) if subtype == learning_unit_year_subtypes.PARTIM: self.fields['acronym'] = PartimAcronymField() self.fields['specific_title'].label = _('Title proper to the partim') self.fields['specific_title_english'].label = _('English title proper to the partim') # Disabled fields when it's an update if self.instance.pk: self.fields['academic_year'].disabled = True # we cannot edit the internship subtype if the container_type is not internship if 'internship_subtype' in self.fields and \ self.instance.learning_container_year.container_type != INTERNSHIP: self.fields['internship_subtype'].disabled = True if not external: self.fields['campus'].queryset = find_main_campuses() self.fields['language'].queryset = find_all_languages()
def __init__(self, data, person, subtype, *args, external=False, **kwargs): self.person = person self.user = self.person.user super().__init__(data, *args, **kwargs) self.external = external self.instance.subtype = subtype acronym = self.initial.get('acronym') if acronym: self.initial['acronym'] = split_acronym(acronym, subtype, instance=self.instance) if subtype == learning_unit_year_subtypes.PARTIM: self.fields['acronym'] = PartimAcronymField() self.fields['specific_title'].label = _( 'Title proper to the partim') self.fields['specific_title_english'].label = _( 'English title proper to the partim') # Disabled fields when it's an update if self.instance.pk: self.fields['academic_year'].disabled = True # we cannot edit the internship subtype if the container_type is not internship if 'internship_subtype' in self.fields and \ self.instance.learning_container_year.container_type != INTERNSHIP: self.fields['internship_subtype'].disabled = True if not external: self.fields['campus'].queryset = find_main_campuses() self.fields['language'].queryset = Language.objects.all().order_by( 'name')
def get_valid_form_data(learning_unit_year_partim): acronym_splited = acronym_field.split_acronym( learning_unit_year_partim.acronym) return { # Learning unit year data model form 'acronym_2': 'B', 'subtype': learning_unit_year_partim.subtype, 'specific_title': learning_unit_year_partim.specific_title, 'specific_title_english': learning_unit_year_partim.specific_title_english, 'credits': learning_unit_year_partim.credits, 'session': learning_unit_year_partim.session, 'quadrimester': learning_unit_year_partim.quadrimester, 'status': learning_unit_year_partim.status, 'language': learning_unit_year_partim.language.id, 'campus': CampusFactory(name='Louvain-la-Neuve', organization__type=organization_type.MAIN).pk, 'periodicity': learning_unit_year_partim.periodicity, # Learning unit data model form 'faculty_remark': learning_unit_year_partim.learning_unit.faculty_remark, 'other_remark': learning_unit_year_partim.learning_unit.other_remark, # Learning component year data model form 'component-TOTAL_FORMS': '2', 'component-INITIAL_FORMS': '0', 'component-MAX_NUM_FORMS': '2', 'component-0-hourly_volume_total_annual': 20, 'component-0-hourly_volume_partial_q1': 10, 'component-0-hourly_volume_partial_q2': 10, 'component-0-planned_classes': 1, 'component-1-hourly_volume_total_annual': 20, 'component-1-hourly_volume_partial_q1': 10, 'component-1-hourly_volume_partial_q2': 10, 'component-1-planned_classes': 1, }