Пример #1
0
    def __init__(self, start_year, end_year):
        self.start_year = start_year
        self.end_year = end_year
        self.learning_container = LearningContainerFactory()
        self.learning_unit_full = LearningUnitFactory(learning_container=self.learning_container,
                                                      start_year=start_year,
                                                      end_year=end_year,
                                                      periodicity=learning_unit_periodicity.ANNUAL)
        self.learning_unit_partim = LearningUnitFactory(learning_container=self.learning_container,
                                                        start_year=start_year,
                                                        end_year=end_year,
                                                        periodicity=learning_unit_periodicity.ANNUAL)

        self._setup_entities()
        self._setup_common_data()

        self.generated_container_years = [
            GenerateContainerYear(
                academic_year=AcademicYearFactory(year=year),
                learning_unit_full=self.learning_unit_full,
                learning_unit_partim=self.learning_unit_partim,
                entities=self.entities,
                campus=self.campus,
                language=self.language
            )
            for year in range(self.start_year, self.end_year + 1)
        ]
Пример #2
0
 def setUpTestData(cls):
     cls.language_fr = LanguageFactory(code="FR")
     cls.language_en = LanguageFactory(code="EN")
     cls.user = UserFactory()
     flag, created = Flag.objects.get_or_create(name='learning_achievement_update')
     flag.users.add(cls.user)
     cls.person = PersonWithPermissionsFactory("can_access_learningunit", "can_create_learningunit", user=cls.user)
     cls.person_entity = PersonEntityFactory(person=cls.person)
     EntityVersionFactory(entity=cls.person_entity.entity)
     cls.academic_years = AcademicYearFactory.produce_in_future(quantity=5)
     cls.max_la_number = 2*len(cls.academic_years)
     cls.learning_unit = LearningUnitFactory(start_year=cls.academic_years[0], end_year=cls.academic_years[-1])
     cls.learning_container = LearningContainerFactory()
     cls.learning_unit_years = [LearningUnitYearFactory(
         academic_year=academic_year,
         subtype=learning_unit_year_subtypes.FULL,
         learning_container_year=LearningContainerYearFactory(
             academic_year=academic_year,
             learning_container=cls.learning_container,
             requirement_entity=cls.person_entity.entity
         ),
         learning_unit=cls.learning_unit,
         acronym="TEST0000"
     ) for academic_year in cls.academic_years]
     cls.learning_component_years = [LearningComponentYearFactory(
         learning_unit_year=luy,
     ) for luy in cls.learning_unit_years]
Пример #3
0
    def get_data_dict(self, container_type):
        learning_container = LearningContainerFactory()
        learning_container_yr = LearningContainerYearFactory(
            academic_year=self.current_academic_year,
            learning_container=learning_container)
        entity_version = EntityVersionFactory()
        a_learning_unit = LearningUnitFactory()
        requirement_entity_container_yr = EntityContainerYearFactory(
            learning_container_year=learning_container_yr,
            type=entity_container_year_link_type.REQUIREMENT_ENTITY)

        return {
            'new_learning_container_year': learning_container_yr,
            'data': {
                'quadrimester': '',
                'acronym': 'LTATO1200',
                'subtype': 'FULL',
                'allocation_entity': entity_version,
                'additional_requirement_entity_2': None,
                'status': True,
                'academic_year': self.current_academic_year,
                'requirement_entity': entity_version,
                'credits': Decimal('15'),
                'container_type': container_type,
                'session': '',
                'additional_requirement_entity_1': None
            },
            'new_learning_unit': a_learning_unit,
            'requirement_entity_containers': [requirement_entity_container_yr],
            'status': True,
            'academic_year': self.current_academic_year
        }
Пример #4
0
 def setUpTestData(cls):
     cls.current_academic_year = create_current_academic_year()
     cls.learning_container = LearningContainerFactory()
     cls.form = LearningUnitModelForm(cls.post_data)
     cls.save_kwargs = {
         'learning_container': cls.learning_container,
         'start_year': cls.current_academic_year
     }
Пример #5
0
 def test_most_recent_acronym(self):
     container = LearningContainerFactory()
     most_recent_year = 2018
     for year in range(2016, most_recent_year + 1):
         LearningContainerYearFactory(learning_container=container, academic_year=AcademicYearFactory(year=year))
     most_recent_container_year = LearningContainerYear.objects.get(academic_year__year=most_recent_year,
                                                                    learning_container=container)
     self.assertEqual(container.most_recent_acronym, most_recent_container_year.acronym)
    def test_create_learning_component_year(self):
        learning_container = LearningContainerFactory()
        learning_container_yr = LearningContainerYearFactory(academic_year=self.current_academic_year,
                                                             learning_container=learning_container)

        new_learning_component_yr = creation.create_learning_component_year(learning_container_yr,
                                                                            creation.DEFAULT_ACRONYM_LECTURING_COMPONENT,
                                                                            learning_component_year_type.LECTURING)
        self.assertEqual(new_learning_component_yr.learning_container_year, learning_container_yr)
        self.assertEqual(new_learning_component_yr.acronym,
                         creation.DEFAULT_ACRONYM_LECTURING_COMPONENT)
        self.assertEqual(new_learning_component_yr.type, learning_component_year_type.LECTURING)
    def setUp(self):
        self.country = CountryFactory()
        self.academic_yr = AcademicYearFactory(year=timezone.now().year)
        self.start_date = self.academic_yr.start_date
        self.end_date = self.academic_yr.end_date

        l_container = LearningContainerFactory()
        self.l_container_year = LearningContainerYearFactory(
            acronym=ACRONYM_LU,
            learning_container=l_container,
            academic_year=self.academic_yr)
        LearningUnitYearFactory(acronym=ACRONYM_LU,
                                learning_container_year=self.l_container_year,
                                academic_year=self.academic_yr,
                                learning_unit=LearningUnitFactory())
Пример #8
0
 def setUp(self):
     self.ac_years_containers = GenerateAcademicYear(start_year=2015,
                                                     end_year=2020)
     self.learning_container = LearningContainerFactory()
     self.learning_unit = LearningUnitFactory(
         learning_container=self.learning_container)
     self.luys = {}
     for ac_year in self.ac_years_containers.academic_years:
         self.luys[ac_year] = LearningUnitYearFactory(
             acronym="LBIR1200",
             learning_unit=self.learning_unit,
             academic_year=ac_year,
             learning_container_year__learning_container=self.
             learning_container,
             learning_container_year__academic_year=ac_year)
Пример #9
0
 def setUpTestData(cls):
     start_year = AcademicYearFactory(year=2015)
     end_year = AcademicYearFactory(year=2020)
     cls.ac_years_containers = GenerateAcademicYear(start_year=start_year,
                                                    end_year=end_year)
     cls.learning_container = LearningContainerFactory()
     cls.learning_unit = LearningUnitFactory(
         learning_container=cls.learning_container)
     cls.luys = {}
     for ac_year in cls.ac_years_containers.academic_years:
         cls.luys[ac_year] = LearningUnitYearFactory(
             acronym="LBIR1200",
             learning_unit=cls.learning_unit,
             academic_year=ac_year,
             learning_container_year__learning_container=cls.
             learning_container,
             learning_container_year__academic_year=ac_year)
Пример #10
0
    def test_get_components_with_classes(self):
        l_container = LearningContainerFactory()
        l_container_year = LearningContainerYearFactory(
            academic_year=self.current_academic_year,
            title="LC-98998",
            learning_container=l_container)
        l_component_year = LearningComponentYearFactory(
            learning_container_year=l_container_year)
        LearningClassYearFactory(learning_component_year=l_component_year)
        LearningClassYearFactory(learning_component_year=l_component_year)
        learning_unit_year = LearningUnitYearFactory(
            academic_year=self.current_academic_year,
            learning_container_year=l_container_year)

        components = learning_unit_business.get_same_container_year_components(
            learning_unit_year, True)
        self.assertEqual(len(components), 1)
        self.assertEqual(len(components[0]['learning_component_year'].classes),
                         2)
Пример #11
0
    def setUp(self):
        self.central_manager = PersonFactory()
        self.central_manager.user.groups.add(
            Group.objects.get(name=CENTRAL_MANAGER_GROUP))
        self.faculty_manager = PersonFactory()
        self.faculty_manager.user.groups.add(
            Group.objects.get(name=FACULTY_MANAGER_GROUP))
        self.current_academic_year = create_current_academic_year()

        self.learning_container = LearningContainerFactory()
        self.learning_unit = LearningUnitFactory(
            learning_container=self.learning_container)
        self.learning_container_year = LearningContainerYearFactory(
            learning_container=self.learning_container,
            academic_year=self.current_academic_year,
            container_type=learning_container_year_types.COURSE)
        self.form = LearningUnitYearModelForm(data=None,
                                              person=self.central_manager,
                                              subtype=FULL)
        campus = CampusFactory(organization=OrganizationFactory(
            type=organization_type.MAIN))
        self.language = LanguageFactory(code='FR')

        self.post_data = {
            'acronym_0': 'L',
            'acronym_1': 'OSIS9001',
            'academic_year': self.current_academic_year.pk,
            'specific_title': 'The hobbit',
            'specific_title_english': 'An Unexpected Journey',
            'credits': 3,
            'session': '3',
            'status': True,
            'quadrimester': 'Q1',
            'internship_subtype': PROFESSIONAL_INTERNSHIP,
            'attribution_procedure': INTERNAL_TEAM,
            'campus': campus.pk,
            'language': self.language.pk,
            'periodicity': ANNUAL,

            # Learning component year data model form
            'form-TOTAL_FORMS': '2',
            'form-INITIAL_FORMS': '0',
            'form-MAX_NUM_FORMS': '2',
            'form-0-hourly_volume_total_annual': 20,
            'form-0-hourly_volume_partial_q1': 10,
            'form-0-hourly_volume_partial_q2': 10,
            'form-1-hourly_volume_total_annual': 20,
            'form-1-hourly_volume_partial_q1': 10,
            'form-1-hourly_volume_partial_q2': 10,
        }

        self.requirement_entity = EntityContainerYearFactory(
            type=REQUIREMENT_ENTITY,
            learning_container_year=self.learning_container_year)
        self.allocation_entity = EntityContainerYearFactory(
            type=ALLOCATION_ENTITY,
            learning_container_year=self.learning_container_year)
        self.additional_requirement_entity_1 = EntityContainerYearFactory(
            type=ADDITIONAL_REQUIREMENT_ENTITY_1,
            learning_container_year=self.learning_container_year)
        self.additional_requirement_entity_2 = EntityContainerYearFactory(
            type=ADDITIONAL_REQUIREMENT_ENTITY_2,
            learning_container_year=self.learning_container_year)

        EntityVersionFactory(
            entity=self.additional_requirement_entity_1.entity,
            start_date=self.learning_container_year.academic_year.start_date,
            end_date=self.learning_container_year.academic_year.end_date)

        EntityVersionFactory(
            entity=self.additional_requirement_entity_2.entity,
            start_date=self.learning_container_year.academic_year.start_date,
            end_date=self.learning_container_year.academic_year.end_date)

        self.allocation_entity_version = EntityVersionFactory(
            entity=self.allocation_entity.entity,
            start_date=self.learning_container_year.academic_year.start_date,
            end_date=self.learning_container_year.academic_year.end_date)

        self.requirement_entity_version = EntityVersionFactory(
            entity=self.requirement_entity.entity,
            start_date=self.learning_container_year.academic_year.start_date,
            end_date=self.learning_container_year.academic_year.end_date)

        self.entity_container_years = [
            self.requirement_entity, self.allocation_entity,
            self.additional_requirement_entity_1,
            self.additional_requirement_entity_2
        ]
Пример #12
0
def get_valid_form_data(academic_year, person, learning_unit_year=None):
    entities = create_entities_hierarchy()
    PersonEntityFactory(person=person,
                        entity=entities['root_entity'],
                        with_child=True)
    requirement_entity_version = entities['child_one_entity_version']
    organization = OrganizationFactory(type=organization_type.MAIN)
    campus = CampusFactory(organization=organization)
    language = LanguageFactory(code='FR')

    if not learning_unit_year:
        learning_container = LearningContainerFactory()
        container_year = LearningContainerYearFactory(
            academic_year=academic_year, learning_container=learning_container)

        learning_unit_full = LearningUnitFactory(
            learning_container=learning_container,
            start_year=academic_year.year,
            end_year=academic_year.year,
        )

        learning_unit_year = LearningUnitYearFactory.build(
            academic_year=academic_year,
            learning_unit=learning_unit_full,
            learning_container_year=container_year,
            subtype=learning_unit_year_subtypes.FULL,
            campus=campus,
            language=language,
            periodicity=learning_unit_year_periodicity.ANNUAL)

    cm_lcy = LearningComponentYear.objects.filter(
        learning_unit_year=learning_unit_year).first()
    pp_lcy = LearningComponentYear.objects.filter(
        learning_unit_year=learning_unit_year).last()

    return {
        # Learning unit year data model form
        'acronym': learning_unit_year.acronym,
        'acronym_0': learning_unit_year.acronym[0],
        'acronym_1': learning_unit_year.acronym[1:],
        'subtype': learning_unit_year.subtype,
        'academic_year': learning_unit_year.academic_year.id,
        'specific_title': learning_unit_year.specific_title,
        'specific_title_english': learning_unit_year.specific_title_english,
        'credits': learning_unit_year.credits,
        'session': learning_unit_year.session,
        'quadrimester': learning_unit_year.quadrimester,
        'status': learning_unit_year.status,
        'internship_subtype': None,
        'attribution_procedure': learning_unit_year.attribution_procedure,
        'campus': learning_unit_year.campus.id,
        'language': learning_unit_year.language.pk,
        'periodicity': learning_unit_year.periodicity,

        # Learning unit data model form
        'faculty_remark': learning_unit_year.learning_unit.faculty_remark,
        'other_remark': learning_unit_year.learning_unit.other_remark,

        # Learning container year data model form
        'common_title':
        learning_unit_year.learning_container_year.common_title,
        'common_title_english':
        learning_unit_year.learning_container_year.common_title_english,
        'container_type':
        learning_unit_year.learning_container_year.container_type,
        'type_declaration_vacant':
        learning_unit_year.learning_container_year.type_declaration_vacant,
        'team': learning_unit_year.learning_container_year.team,
        'is_vacant': learning_unit_year.learning_container_year.is_vacant,
        'requirement_entity-entity': requirement_entity_version.id,
        'allocation_entity-entity': requirement_entity_version.id,
        'additional_requirement_entity_1-entity': '',

        # Learning component year data model form
        'component-0-id': cm_lcy and cm_lcy.pk,
        'component-1-id': pp_lcy and pp_lcy.pk,
        'component-TOTAL_FORMS': '2',
        'component-INITIAL_FORMS': '0' if not cm_lcy else '2',
        '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-1-hourly_volume_total_annual': 20,
        'component-1-hourly_volume_partial_q1': 10,
        'component-1-hourly_volume_partial_q2': 10,
    }
Пример #13
0
 def test_find_by_id_with_id(self):
     l_container = LearningContainerFactory()
     self.assertEqual(l_container, learning_container.find_by_id(l_container.id))
Пример #14
0
 def setUp(self):
     self.current_academic_year = create_current_academic_year()
     self.learning_container = LearningContainerFactory()
     self.form = LearningUnitModelForm(self.post_data)
     self.save_kwargs = {'learning_container': self.learning_container,
                         'start_year': self.current_academic_year.year}