Example #1
0
    def test_when_person_is_faculty_manager(self):
        FacultyManagerGroupFactory()
        faculty_manager = create_person_in_group(FACULTY_MANAGER_GROUP)

        expected_state = proposal_state.ProposalState.FACULTY.name
        actual_state = compute_proposal_state(faculty_manager)
        self.assertEqual(expected_state, actual_state)
    def setUp(self):
        self.current_academic_year = create_current_academic_year()
        self.generated_ac_years = GenerateAcademicYear(
            self.current_academic_year.year + 1,
            self.current_academic_year.year + 10)

        # Creation of a LearingContainerYear and all related models - FOR 6 years
        self.learn_unit_structure = GenerateContainer(
            self.current_academic_year.year,
            self.current_academic_year.year + 6)
        # Build in Generated Container [first index = start Generate Container ]
        self.generated_container_year = self.learn_unit_structure.generated_container_years[
            0]

        # Update All full learning unit year acronym
        LearningUnitYear.objects.filter(learning_unit=self.learn_unit_structure.learning_unit_full) \
            .update(acronym=FULL_ACRONYM)
        # Update All partim learning unit year acronym
        LearningUnitYear.objects.filter(learning_unit=self.learn_unit_structure.learning_unit_partim) \
            .update(acronym=FULL_ACRONYM + SUBDIVISION_ACRONYM)

        self.learning_unit_year_full = LearningUnitYear.objects.get(
            learning_unit=self.learn_unit_structure.learning_unit_full,
            academic_year=self.current_academic_year)

        self.learning_unit_year_partim = LearningUnitYear.objects.get(
            learning_unit=self.learn_unit_structure.learning_unit_partim,
            academic_year=self.current_academic_year)

        self.person = PersonFactory()
        for entity in self.learn_unit_structure.entities:
            PersonEntityFactory(person=self.person, entity=entity)

        FacultyManagerGroupFactory()
Example #3
0
    def setUpTestData(cls):
        today = datetime.date.today()
        FacultyManagerGroupFactory()
        cls.faculty_user = factory_user.UserFactory()
        cls.faculty_person = FacultyManagerFactory('can_propose_learningunit',
                                                   'can_create_learningunit',
                                                   user=cls.faculty_user)
        cls.super_user = factory_user.SuperUserFactory()
        cls.person = factory_person.CentralManagerFactory(user=cls.super_user)
        start_year = AcademicYearFactory(year=get_current_year())
        end_year = AcademicYearFactory(year=get_current_year() + 7)
        cls.academic_years = GenerateAcademicYear(start_year,
                                                  end_year).academic_years
        cls.current_academic_year = cls.academic_years[0]
        cls.next_academic_year = cls.academic_years[1]
        generate_creation_or_end_date_proposal_calendars(cls.academic_years)

        cls.language = LanguageFactory(code='FR')
        cls.organization = organization_factory.OrganizationFactory(
            type=organization_type.MAIN)
        cls.campus = campus_factory.CampusFactory(
            organization=cls.organization, is_administration=True)
        cls.entity = EntityFactory(organization=cls.organization)
        cls.entity_version = EntityVersionFactory(
            entity=cls.entity,
            entity_type=entity_type.FACULTY,
            start_date=today.replace(year=1900),
            end_date=None)

        PersonEntityFactory(person=cls.faculty_person, entity=cls.entity)
        PersonEntityFactory(person=cls.person, entity=cls.entity)
Example #4
0
 def setUpTestData(cls):
     cls.an_user = user.UserFactory(username="******")
     cls.user_for_person = user.UserFactory(username="******")
     cls.person_without_user = PersonWithoutUserFactory()
     CentralManagerGroupFactory()
     FacultyManagerGroupFactory()
     ProgramManagerGroupFactory()
 def test_disable_fields_full_with_faculty_manager_and_central_manager(self):
     self.person.user.groups.add(FacultyManagerGroupFactory())
     self.person.user.groups.add(CentralManagerGroupFactory())
     form = FullForm(self.person, self.learning_unit_year.academic_year,
                     learning_unit_instance=self.learning_unit_year.learning_unit)
     disabled_fields = {key for key, value in form.fields.items() if value.disabled}
     self.assertEqual(disabled_fields, FULL_READ_ONLY_FIELDS.union({'internship_subtype'}))
 def setUpTestData(cls):
     cls.current_academic_year = create_current_academic_year()
     start_year = AcademicYearFactory(year=cls.current_academic_year.year +
                                      1)
     end_year = AcademicYearFactory(year=cls.current_academic_year.year +
                                    10)
     cls.generated_ac_years = GenerateAcademicYear(start_year, end_year)
     FacultyManagerGroupFactory()
 def test_disable_fields_acronym_with_faculty_manager_and_other_collective(self):
     self.person.user.groups.add(FacultyManagerGroupFactory())
     self.learning_unit_year.learning_container_year.container_type = LearningContainerYearType.OTHER_COLLECTIVE.name
     self.learning_unit_year.learning_container_year.save()
     form = FullForm(self.person, self.learning_unit_year.academic_year,
                     learning_unit_instance=self.learning_unit_year.learning_unit)
     disabled_fields = {key for key, value in form.fields.items() if value.disabled}
     self.assertTrue("acronym" not in disabled_fields)
 def test_academic_years_restriction_for_faculty_manager(self):
     self.person.user.groups.add(FacultyManagerGroupFactory())
     form = FullForm(self.person, self.learning_unit_year.academic_year,
                     start_year=self.learning_unit_year.academic_year.year,
                     postposal=True)
     actual_choices = [choice[0] for choice in form.fields["academic_year"].choices if choice[0] != '']
     expected_choices = [acy.id for acy in self.acs[3:6]]
     self.assertCountEqual(actual_choices, expected_choices)
Example #9
0
 def setUp(self):
     self.an_user = user.UserFactory(username="******")
     self.user_for_person = user.UserFactory(username="******")
     self.person_with_user = PersonFactory(user=self.user_for_person, language="fr-be", first_name="John",
                                           last_name="Doe")
     self.person_without_user = PersonWithoutUserFactory()
     CentralManagerGroupFactory()
     FacultyManagerGroupFactory()
     ProgramManagerGroupFactory()
Example #10
0
    def test_disable_fields_full_proposal_with_faculty_manager(self):
        self.person.user.groups.add(FacultyManagerGroupFactory())
        form = FullForm(
            self.person,
            self.learning_unit_year.academic_year,
            learning_unit_instance=self.learning_unit_year.learning_unit,
            proposal=True)

        for elem in PROPOSAL_READ_ONLY_FIELDS:
            self.assertEqual(form.fields[elem].disabled, True)
            self.assertEqual(form.fields['academic_year'].disabled, True)
Example #11
0
 def test_disable_fields_full_with_faculty_manager(self):
     self.person.user.groups.add(FacultyManagerGroupFactory())
     form = FullForm(
         self.person,
         self.learning_unit_year.academic_year,
         learning_unit_instance=self.learning_unit_year.learning_unit)
     disabled_fields = {
         key
         for key, value in form.fields.items() if value.disabled
     }
     self.assertTrue(FACULTY_OPEN_FIELDS not in disabled_fields)
Example #12
0
    def setUpTestData(cls):
        person_entity = PersonEntityFactory()
        cls.user = person_entity.person.user
        cls.entity = person_entity.entity
        FacultyManagerGroupFactory()
        cls.user.groups.add(Group.objects.get(name=FACULTY_MANAGER_GROUP))

        cls.user_not_faculty_manager = PersonEntityFactory(
            entity=cls.entity).person.user

        cls.user_with_no_person = UserFactory()

        cls.entity_not_linked_to = EntityFactory()
Example #13
0
    def setUp(self):
        today = datetime.date.today()
        FacultyManagerGroupFactory()
        self.faculty_user = factory_user.UserFactory()
        self.faculty_user.groups.add(Group.objects.get(name=FACULTY_MANAGER_GROUP))
        self.faculty_person = factory_person.PersonFactory(user=self.faculty_user)
        self.faculty_user.user_permissions.add(Permission.objects.get(codename='can_propose_learningunit'))
        self.faculty_user.user_permissions.add(Permission.objects.get(codename='can_create_learningunit'))
        self.super_user = factory_user.SuperUserFactory()
        self.person = factory_person.PersonFactory(user=self.super_user)
        self.academic_years = GenerateAcademicYear(get_current_year(), get_current_year() + 7).academic_years
        self.current_academic_year = self.academic_years[0]
        self.next_academic_year = self.academic_years[1]

        self.language = LanguageFactory(code='FR')
        self.organization = organization_factory.OrganizationFactory(type=organization_type.MAIN)
        self.campus = campus_factory.CampusFactory(organization=self.organization, is_administration=True)
        self.entity = EntityFactory(organization=self.organization)
        self.entity_version = EntityVersionFactory(entity=self.entity, entity_type=entity_type.FACULTY,
                                                   start_date=today.replace(year=1900),
                                                   end_date=None)

        PersonEntityFactory(person=self.faculty_person, entity=self.entity)
        PersonEntityFactory(person=self.person, entity=self.entity)
Example #14
0
    def setUp(self):
        self.person = PersonFactory()
        an_organization = OrganizationFactory(type=organization_type.MAIN)
        current_academic_year = create_current_academic_year()

        today = datetime.date.today()
        an_entity = EntityFactory(organization=an_organization)
        self.entity_version = EntityVersionFactory(
            entity=an_entity,
            entity_type=entity_type.FACULTY,
            start_date=today.replace(year=1900),
            end_date=None)
        self.an_entity_school = EntityFactory(organization=an_organization)
        self.entity_version_school = EntityVersionFactory(
            entity=self.an_entity_school,
            entity_type=entity_type.SCHOOL,
            start_date=today.replace(year=1900),
            end_date=None)

        learning_container_year = LearningContainerYearFactory(
            academic_year=current_academic_year,
            container_type=learning_container_year_types.COURSE,
            requirement_entity=self.entity_version.entity,
        )
        self.learning_unit_year = LearningUnitYearFakerFactory(
            credits=Decimal(5),
            subtype=learning_unit_year_subtypes.FULL,
            academic_year=current_academic_year,
            learning_container_year=learning_container_year,
            campus=CampusFactory(organization=an_organization,
                                 is_administration=True),
            periodicity=learning_unit_year_periodicity.ANNUAL,
            internship_subtype=None)
        self.person_entity = PersonEntityFactory(person=self.person,
                                                 entity=an_entity)
        self.language = LanguageFactory(code="EN")
        self.campus = CampusFactory(
            name="OSIS Campus",
            organization=OrganizationFactory(type=organization_type.MAIN),
            is_administration=True)

        self.form_data = {
            "academic_year": self.learning_unit_year.academic_year.id,
            "acronym_0": "L",
            "acronym_1": "OSIS1245",
            "common_title": "New common title",
            "common_title_english": "New common title english",
            "specific_title": "New title",
            "specific_title_english": "New title english",
            "container_type":
            self.learning_unit_year.learning_container_year.container_type,
            "internship_subtype": "",
            "credits": self.learning_unit_year.credits,
            "periodicity": learning_unit_year_periodicity.BIENNIAL_ODD,
            "status": False,
            "language": self.language.pk,
            "quadrimester": quadrimesters.Q1,
            "campus": self.campus.id,
            "entity": self.entity_version.id,
            "folder_id": "1",
            "state": proposal_state.ProposalState.CENTRAL.name,
            'requirement_entity': self.entity_version.id,
            'allocation_entity': self.entity_version.id,
            'additional_entity_1': self.entity_version.id,
            'additional_entity_2': self.entity_version.id,

            # 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': Decimal(20),
            'component-0-hourly_volume_partial_q1': Decimal(10),
            'component-0-hourly_volume_partial_q2': Decimal(10),
            'component-1-hourly_volume_total_annual': Decimal(20),
            'component-1-hourly_volume_partial_q1': Decimal(10),
            'component-1-hourly_volume_partial_q2': Decimal(10),
            'component-0-planned_classes': 1,
            'component-1-planned_classes': 1,
        }
        FacultyManagerGroupFactory()
        CentralManagerGroupFactory()
Example #15
0
    def setUp(self):
        self.current_academic_year = create_current_academic_year()
        FacultyManagerGroupFactory()
        self.start_date_ay_1 = self.current_academic_year.start_date.replace(
            year=self.current_academic_year.year + 1)
        self.end_date_ay_1 = self.current_academic_year.end_date.replace(
            year=self.current_academic_year.year + 2)
        self.previous_academic_year = AcademicYearFactory(
            year=self.current_academic_year.year - 1)
        academic_year_1 = AcademicYearFactory.build(
            start_date=self.start_date_ay_1,
            end_date=self.end_date_ay_1,
            year=self.current_academic_year.year + 1)
        academic_year_1.save()

        self.start_date_ay_2 = self.current_academic_year.start_date.replace(
            year=self.current_academic_year.year + 2)
        self.end_date_ay_2 = self.current_academic_year.end_date.replace(
            year=self.current_academic_year.year + 3)
        academic_year_2 = AcademicYearFactory.build(
            start_date=self.start_date_ay_2,
            end_date=self.end_date_ay_2,
            year=self.current_academic_year.year + 2)
        academic_year_2.save()

        self.education_group_year = GroupFactory()

        EntityVersionFactory(
            entity=self.education_group_year.management_entity,
            start_date=self.education_group_year.academic_year.start_date)

        EntityVersionFactory(
            entity=self.education_group_year.administration_entity,
            start_date=self.education_group_year.academic_year.start_date)

        AuthorizedRelationshipFactory(
            parent_type=self.education_group_year.education_group_type,
            child_type=self.education_group_year.education_group_type)

        self.url = reverse(update_education_group,
                           kwargs={
                               "root_id":
                               self.education_group_year.pk,
                               "education_group_year_id":
                               self.education_group_year.pk
                           })
        self.person = CentralManagerFactory()
        PersonEntityFactory(person=self.person,
                            entity=self.education_group_year.management_entity)
        self.client.force_login(self.person.user)
        permission = Permission.objects.get(codename='change_educationgroup')
        self.person.user.user_permissions.add(permission)
        self.perm_patcher = mock.patch(
            "base.business.education_groups.perms._is_eligible_certificate_aims",
            return_value=True)
        self.mocked_perm = self.perm_patcher.start()

        self.an_training_education_group_type = EducationGroupTypeFactory(
            category=education_group_categories.TRAINING)

        self.previous_training_education_group_year = TrainingFactory(
            academic_year=self.previous_academic_year,
            education_group_type=self.an_training_education_group_type,
            education_group__start_year=1968)

        EntityVersionFactory(
            entity=self.previous_training_education_group_year.
            management_entity,
            start_date=self.previous_training_education_group_year.
            academic_year.start_date)

        EntityVersionFactory(
            entity=self.previous_training_education_group_year.
            administration_entity,
            start_date=self.previous_training_education_group_year.
            academic_year.start_date)

        self.training_education_group_year = TrainingFactory(
            academic_year=self.current_academic_year,
            education_group_type=self.an_training_education_group_type,
            education_group__start_year=1968)

        self.training_education_group_year_1 = TrainingFactory(
            academic_year=academic_year_1,
            education_group_type=self.an_training_education_group_type,
            education_group=self.training_education_group_year.education_group)

        self.training_education_group_year_2 = TrainingFactory(
            academic_year=academic_year_2,
            education_group_type=self.an_training_education_group_type,
            education_group=self.training_education_group_year.education_group)

        AuthorizedRelationshipFactory(
            parent_type=self.an_training_education_group_type,
            child_type=self.an_training_education_group_type,
        )

        EntityVersionFactory(
            entity=self.training_education_group_year.management_entity,
            start_date=self.education_group_year.academic_year.start_date)

        EntityVersionFactory(
            entity=self.training_education_group_year.administration_entity,
            start_date=self.education_group_year.academic_year.start_date)

        self.training_url = reverse(update_education_group,
                                    args=[
                                        self.training_education_group_year.pk,
                                        self.training_education_group_year.pk
                                    ])
        PersonEntityFactory(
            person=self.person,
            entity=self.training_education_group_year.management_entity)

        self.domains = [DomainFactory() for x in range(10)]

        self.a_mini_training_education_group_type = EducationGroupTypeFactory(
            category=education_group_categories.MINI_TRAINING)

        self.mini_training_education_group_year = MiniTrainingFactory(
            academic_year=self.current_academic_year,
            education_group_type=self.a_mini_training_education_group_type)

        self.mini_training_url = reverse(
            update_education_group,
            args=[
                self.mini_training_education_group_year.pk,
                self.mini_training_education_group_year.pk
            ])
        PersonEntityFactory(
            person=self.person,
            entity=self.mini_training_education_group_year.management_entity)

        EntityVersionFactory(
            entity=self.mini_training_education_group_year.management_entity,
            start_date=self.education_group_year.academic_year.start_date)