Пример #1
0
    def save(self):
        education_group_year = super().save()

        self.postpone_start_year = education_group_year.academic_year.year
        self.postpone_end_year = _compute_end_year(education_group_year.education_group)
        self._start_postponement(education_group_year)

        create.create_initial_group_element_year_structure(self.education_group_year_postponed)
        return education_group_year
Пример #2
0
    def save(self):
        education_group_year = super().save()
        self.postpone_start_year = education_group_year.academic_year.year
        self.postpone_end_year = _compute_end_year(
            education_group_year.education_group)
        self._start_postponement(education_group_year)

        create.create_initial_group_element_year_structure(
            self.education_group_year_postponed)
        return education_group_year
Пример #3
0
    def test_should_copy_data_from_previous_year(self):
        previous_academic_year = AcademicYearFactory(
            year=self.egy.academic_year.year - 1)
        previous_egy = EducationGroupYearFactory(
            education_group_type=self.master_type,
            acronym="TEST2M",
            partial_acronym="LTEST100B",
            academic_year=previous_academic_year,
            education_group=self.egy.education_group,
        )
        previous_child = EducationGroupYearFactory(
            education_group_type=self.finality_type,
            partial_acronym="LTEST503G",
            academic_year=previous_academic_year,
        )
        previous_grp_ele = GroupElementYearFactory(parent=previous_egy,
                                                   child_branch=previous_child)

        current_child = EducationGroupYearFactory(
            education_group_type=self.finality_type,
            partial_acronym="LTEST504G",
            academic_year=self.current_academic_year,
        )
        current_grp_ele = GroupElementYearFactory(parent=self.egy,
                                                  child_branch=current_child)
        children_egys = create_initial_group_element_year_structure(
            [previous_egy, self.egy, self.egy_next_year])

        self.assertEqual(
            current_child.partial_acronym, children_egys[self.egy_next_year.id]
            [0].child_branch.partial_acronym)
Пример #4
0
    def test_should_reuse_past_partial_acronym(self):
        previous_academic_year = AcademicYearFactory(year=self.egy.academic_year.year - 1)
        previous_egy = EducationGroupYearFactory(
            education_group_type=self.master_type,
            acronym="TEST2M",
            partial_acronym="LTEST100B",
            academic_year=previous_academic_year,
            education_group=self.egy.education_group,
        )
        previous_child = EducationGroupYearFactory(
            education_group_type=self.finality_type,
            partial_acronym="LTEST503G",
            academic_year=previous_academic_year,
        )
        previous_grp_ele = GroupElementYearFactory(
            parent=previous_egy,
            child_branch=previous_child
        )
        children_egys = create_initial_group_element_year_structure([self.egy])

        self.assertEqual(
            previous_child.partial_acronym,
            children_egys[self.egy.id][0].child_branch.partial_acronym
        )

        self.assertEqual(
            previous_child.education_group,
            children_egys[self.egy.id][0].child_branch.education_group
        )
Пример #5
0
 def test_should_increment_cnum_of_child_partial_acronym_to_avoid_conflicted_acronyms(
         self):
     EducationGroupYearFactory(partial_acronym="LTEST400G")
     EducationGroupYearFactory(partial_acronym="LTEST401G")
     child_egy = create_initial_group_element_year_structure(
         [self.egy])[self.egy.id][0].child_branch
     self.assertEqual(child_egy.partial_acronym, "LTEST402G")
Пример #6
0
    def test_education_group_year_children_attribute_empty_partial_acronym(
            self):
        """ Check if the app can handle an empty partial acronym
        TODO : Remove that test when the db will be cleaned.
        """
        attributes_to_inherit = ("academic_year", "main_teaching_campus",
                                 "management_entity")
        expected_title = "{} {}".format(
            self.validation_rule_title.initial_value, self.egy.acronym)
        expected_acronym = "{}{}".format(
            self.validation_rule_title.initial_value.replace(" ", "").upper(),
            self.egy.acronym)

        self.egy.partial_acronym = None

        child_egy = create_initial_group_element_year_structure(
            [self.egy])[self.egy.id][0].child_branch

        for field in attributes_to_inherit:
            self.assertEqual(getattr(child_egy, field),
                             getattr(self.egy, field))
        self.assertEqual(child_egy.education_group_type, self.finality_type)
        self.assertEqual(child_egy.title, expected_title)
        self.assertEqual(child_egy.partial_acronym, "")
        self.assertEqual(child_egy.acronym, expected_acronym)
        self.assertTrue(child_egy.id)
Пример #7
0
 def test_should_keep_partial_acronym_between_years(self):
     children_egys = create_initial_group_element_year_structure([self.egy, self.egy_next_year])
     partial_acronym = children_egys[self.egy.id][0].child_branch.partial_acronym
     partial_acronym_next_year = children_egys[self.egy_next_year.id][0].child_branch.partial_acronym
     self.assertTrue(
         partial_acronym == partial_acronym_next_year == "LTEST400G"
     )
Пример #8
0
 def test_should_create_education_group_with_start_and_year_equal_to_parent_academic_year(
         self):
     child_egy = create_initial_group_element_year_structure(
         [self.egy])[self.egy.id][0].child_branch
     self.assertEqual(child_egy.education_group.start_year,
                      self.egy.academic_year.year)
     self.assertEqual(child_egy.education_group.end_year,
                      self.egy.academic_year.year)
Пример #9
0
    def save(self):
        start_year = None
        if self._is_creation() and not self.education_group_form.instance.start_year:
            start_year = self.education_group_year_form.cleaned_data['academic_year'].year

        education_group = self.education_group_form.save(start_year=start_year)
        self.education_group_year_form.instance.education_group = education_group
        education_group_year = self.education_group_year_form.save()
        self._save_group_element_year(self.education_group_year_form.parent, education_group_year)

        if hasattr(self, '_post_save'):
            post_save = self._post_save()
            self.education_group_year_deleted = post_save.get('object_list_deleted', [])

        create.create_initial_group_element_year_structure([education_group_year])

        return education_group_year
Пример #10
0
 def test_should_create_children_for_education_group_year_equal_to_number_of_authorized_relationships(self):
     AuthorizedRelationshipFactory(
         parent_type=self.master_type,
         child_type=self.major_type,
         min_count_authorized=1,
     )
     children_egy = create_initial_group_element_year_structure([self.egy])[self.egy.id]
     self.assertEqual(len(children_egy), 2)
Пример #11
0
 def test_should_not_recreate_existing_children(self):
     child = EducationGroupYearFactory(
         education_group_type=self.finality_type,
         partial_acronym="LTEST503G",
         academic_year=self.egy.academic_year,
     )
     grp_ele = GroupElementYearFactory(parent=self.egy, child_branch=child)
     children_egys = create_initial_group_element_year_structure([self.egy])
     self.assertEqual(grp_ele.id, children_egys[self.egy.id][0].id)
Пример #12
0
def step_impl(context, acronym, year):
    """
    :type context: behave.runner.Context
    """
    entity = Entity.objects.filter(entityversion__acronym='DRT').first()
    campus = Campus.objects.filter(organization__type='MAIN').first()

    training = TrainingFactory(
        acronym=acronym,
        partial_acronym='LDROI200S',
        education_group_type=EducationGroupType.objects.get(name=TrainingType.MASTER_MS_120.name),
        academic_year__year=int(year),
        management_entity=entity,
        administration_entity=entity,
        enrollment_campus=campus,
        main_teaching_campus=campus,
        title='Master [120] en , à finalité spécialisée'

    )
    create_initial_group_element_year_structure([training])
Пример #13
0
    def save(self):
        start_year = None
        if self._is_creation(
        ) and not self.education_group_form.instance.start_year:
            start_year = self.education_group_year_form.cleaned_data[
                'academic_year'].year

        education_group = self.education_group_form.save(start_year=start_year)
        self.education_group_year_form.instance.education_group = education_group
        education_group_year = self.education_group_year_form.save()
        self._save_group_element_year(self.education_group_year_form.parent,
                                      education_group_year)

        if hasattr(self, '_post_save'):
            post_save = self._post_save()
            self.education_group_year_deleted = post_save.get(
                'object_list_deleted', [])

        create.create_initial_group_element_year_structure(
            [education_group_year])

        return education_group_year
Пример #14
0
    def test_education_group_year_children_attribute(self):
        attributes_to_inherit = ("academic_year", "main_teaching_campus", "management_entity")
        expected_title = "{} {}".format(self.validation_rule_title.initial_value, self.egy.acronym)
        expected_acronym = "{}{}".format(
            self.validation_rule_title.initial_value.replace(" ", "").upper(),
            self.egy.acronym
        )

        child_egy = create_initial_group_element_year_structure([self.egy])[self.egy.id][0].child_branch

        for field in attributes_to_inherit:
            self.assertEqual(getattr(child_egy, field), getattr(self.egy, field))
        self.assertEqual(child_egy.education_group_type, self.finality_type)
        self.assertEqual(child_egy.title, expected_title)
        self.assertEqual(child_egy.partial_acronym, "LTEST400G")
        self.assertEqual(child_egy.acronym, expected_acronym)
        self.assertTrue(child_egy.id)
Пример #15
0
 def post_extend(self, original_object, list_postponed_objects):
     """ After the main postponement, we need to create the structure of the education_group_years """
     create_initial_group_element_year_structure([original_object] +
                                                 list_postponed_objects)
Пример #16
0
 def test_should_return_empty_result_when_no_education_group_years_parent(
         self):
     children = create_initial_group_element_year_structure([])
     self.assertDictEqual(children, {})
Пример #17
0
 def test_should_create_children_for_each_education_group_year(self):
     children_egys = create_initial_group_element_year_structure(
         [self.egy, self.egy_next_year])
     self.assertEqual(len(children_egys), 2)
     self.assertEqual(len(children_egys[self.egy.id]), 1)
     self.assertEqual(len(children_egys[self.egy_next_year.id]), 1)
Пример #18
0
 def post_extend(self, original_object, list_postponed_objects):
     """ After the main postponement, we need to create the structure of the education_group_years """
     create_initial_group_element_year_structure([original_object] + list_postponed_objects)