Пример #1
0
    def setUp(self):
        current_ac = create_current_academic_year()

        self.education_group1 = EducationGroupFactory()
        self.education_group2 = EducationGroupFactory()
        self.education_group_year1 = EducationGroupYearFactory(
            education_group=self.education_group1,
            academic_year=current_ac,
        )
        self.education_group_year2 = EducationGroupYearFactory(
            education_group=self.education_group2,
            academic_year=current_ac,
        )
        self.person = PersonWithPermissionsFactory("delete_educationgroup")
        PersonEntityFactory(person=self.person, entity=self.education_group_year1.management_entity)
        PersonEntityFactory(person=self.person, entity=self.education_group_year2.management_entity)

        self.url = reverse('delete_education_group', args=[self.education_group_year1.id,
                                                           self.education_group_year1.education_group.id])
        self.url2 = reverse('delete_education_group', args=[self.education_group_year2.id,
                                                            self.education_group_year2.education_group.id])
        self.client.force_login(user=self.person.user)

        self.academic_calendar = AcademicCalendarFactory(
            reference=EDUCATION_GROUP_EDITION,
            start_date=timezone.now(),
            end_date=timezone.now() + timedelta(weeks=+1),
            academic_year=current_ac,
        )
Пример #2
0
    def setUp(self):
        today = datetime.date.today()
        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)
Пример #3
0
    def setUp(self):
        self.language_fr = LanguageFactory(code="FR")
        self.language_en = LanguageFactory(code="EN")
        self.user = UserFactory()
        self.person = PersonFactory(user=self.user)
        self.person_entity = PersonEntityFactory(person=self.person)

        self.academic_year = create_current_academic_year()
        self.learning_unit_year = LearningUnitYearFactory(
            academic_year=self.academic_year,
            subtype=learning_unit_year_subtypes.FULL,
            learning_container_year__requirement_entity=self.person_entity.entity,
        )
        self.client.force_login(self.user)
        self.achievement_fr = LearningAchievementFactory(
            language=self.language_fr,
            learning_unit_year=self.learning_unit_year,
            order=0
        )
        self.achievement_en = LearningAchievementFactory(
            language=self.language_en,
            learning_unit_year=self.learning_unit_year,
            order=0,
            code_name=self.achievement_fr.code_name
        )
        self.reverse_learning_unit_yr = reverse('learning_unit', args=[self.learning_unit_year.id])
        flag, created = Flag.objects.get_or_create(name='learning_achievement_update')
        flag.users.add(self.user)
        self.request_factory = RequestFactory()
Пример #4
0
    def test_find_attached_faculty_entities_version_filtered_by_person(self):
        person = PersonFactory()
        entity_attached = EntityFactory(organization=self.organization)
        entity_version_attached = EntityVersionFactory(entity=entity_attached,
                                                       entity_type="FACULTY")

        entity_not_attached = EntityFactory(organization=self.organization)
        EntityVersionFactory(entity=entity_not_attached, entity_type="SECTOR")

        entity_ilv = EntityFactory(organization=self.organization)
        entity_version_ilv = EntityVersionFactory(entity=entity_ilv,
                                                  acronym="ILV")

        entity_parent = EntityFactory(organization=self.organization)
        entity_version_parent = EntityVersionFactory(entity=entity_parent,
                                                     entity_type='FACULTY')
        EntityVersionFactory(parent=entity_parent)

        PersonEntityFactory(person=person, entity=entity_attached)
        PersonEntityFactory(person=person, entity=entity_ilv)
        PersonEntityFactory(person=person, entity=entity_parent)

        entity_list = list(
            person.find_attached_faculty_entities_version(
                acronym_exceptions=['ILV']))
        self.assertTrue(entity_list)
        self.assertEqual(len(entity_list), 3)
        self.assertIn(entity_version_attached, entity_list)
        self.assertIn(entity_version_ilv, entity_list)
        self.assertIn(entity_version_parent, entity_list)
Пример #5
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)
Пример #6
0
 def test_find_entities_by_person_with_multiple_person_entity_no_duplicate(self):
     person = PersonFactory()
     PersonEntityFactory(person=person, entity=self.sst_entity, with_child=True)
     PersonEntityFactory(person=person, entity=self.agro_entity, with_child=False)
     entities = person_entity.find_entities_by_person(person)
     self.assertIsInstance(entities, list)
     self.assertEqual(len(entities), 3)
Пример #7
0
    def setUp(self):
        current_ac = create_current_academic_year()
        next_ac = AcademicYearFactory(year=current_ac.year + 1)

        self.education_group = EducationGroupFactory()
        self.education_group_year = EducationGroupYearFactory(
            education_group=self.education_group, academic_year=next_ac)
        self.education_group_year2 = EducationGroupYearFactory(
            education_group=self.education_group, academic_year=next_ac)
        self.person = PersonFactory()
        PersonEntityFactory(person=self.person,
                            entity=self.education_group_year.management_entity)
        PersonEntityFactory(
            person=self.person,
            entity=self.education_group_year2.management_entity)

        self.url = reverse('delete_education_group',
                           args=[
                               self.education_group_year.id,
                               self.education_group_year.education_group.id
                           ])

        self.person.user.user_permissions.add(
            Permission.objects.get(codename="delete_educationgroup"))
        self.client.force_login(user=self.person.user)

        self.academic_calendar = AcademicCalendarFactory(
            reference=EDUCATION_GROUP_EDITION,
            start_date=timezone.now(),
            end_date=timezone.now() + timedelta(weeks=+1),
            academic_year=current_ac,
        )
Пример #8
0
 def setUp(self):
     self.luy = LearningUnitYearFakerFactory(learning_container_year__academic_year=self.current_academic_year,
                                        learning_container_year__container_type=COURSE,
                                        subtype=FULL)
     self.entity_container_year = EntityContainerYearFactory(
         learning_container_year=self.luy.learning_container_year,
         type=entity_container_year_link_type.REQUIREMENT_ENTITY)
     self.person_entity = PersonEntityFactory(person=self.person, entity=self.entity_container_year.entity)
Пример #9
0
 def setUp(self):
     requirement_entity = EntityFactory()
     self.luy = LearningUnitYearFakerFactory(
         learning_container_year__academic_year=self.current_academic_year,
         learning_container_year__container_type=COURSE,
         subtype=FULL,
         learning_container_year__requirement_entity=requirement_entity)
     self.person_entity = PersonEntityFactory(person=self.person,
                                              entity=requirement_entity)
Пример #10
0
 def test_find_entities_by_person_with_multiple_person_entity(self):
     person = PersonFactory()
     PersonEntityFactory(person=person,
                         entity=self.sst_entity,
                         with_child=True)
     PersonEntityFactory(person=person,
                         entity=self.ssh_entity,
                         with_child=False)
     entities = person.linked_entities
     self.assertIsInstance(entities, set)
     self.assertEqual(len(entities), 4)
Пример #11
0
 def test_filter_by_attached_entities(self):
     person = PersonFactory()
     PersonEntityFactory(person=person, entity=self.sst_entity, with_child=True)
     PersonEntityFactory(person=person, entity=self.agro_entity, with_child=False)
     person_2 = PersonFactory()
     PersonEntityFactory(person=person_2, entity=self.ssh_entity, with_child=True)
     queryset = PersonEntity.objects.all()
     list_filtered = list(person_entity_filter.filter_by_attached_entities(person, queryset))
     self.assertEqual(len(list_filtered), 2)
     list_filtered = list(person_entity_filter.filter_by_attached_entities(person_2, queryset))
     self.assertEqual(len(list_filtered), 1)
Пример #12
0
    def setUpTestData(cls):
        person_entity = PersonEntityFactory()
        cls.user = person_entity.person.user
        cls.entity = person_entity.entity

        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()
Пример #13
0
    def test_is_eligible_for_cancel_of_proposal_wrong_state(self):
        generated_container = GenerateContainer(
            start_year=self.academic_yr.year, end_year=self.academic_yr.year)
        generated_container_first_year = generated_container.generated_container_years[
            0]
        an_requirement_entity = generated_container_first_year.requirement_entity_container_year.entity

        luy = generated_container_first_year.learning_unit_year_full
        a_person = self.create_person_with_permission_and_group(
            FACULTY_MANAGER_GROUP, 'can_propose_learningunit')

        a_proposal = ProposalLearningUnitFactory(
            learning_unit_year=luy,
            type=proposal_type.ProposalType.MODIFICATION.name,
            state=proposal_state.ProposalState.CENTRAL.name,
            initial_data={
                "entities": {
                    entity_container_year_link_type.REQUIREMENT_ENTITY:
                    an_requirement_entity.id,
                }
            })

        PersonEntityFactory(person=a_person, entity=an_requirement_entity)
        self.assertFalse(
            perms.is_eligible_for_cancel_of_proposal(a_proposal, a_person))
Пример #14
0
    def test_show_and_edit_coorganization(self):
        user = UserFactory()
        person = PersonFactory(user=user)
        user.user_permissions.add(
            Permission.objects.get(codename="can_access_education_group"))
        person.user.user_permissions.add(
            Permission.objects.get(codename='change_educationgroup'))
        training_not_2m = EducationGroupYearFactory(
            education_group_type__category=TRAINING,
            education_group_type__name=TrainingType.CAPAES.name)
        PersonEntityFactory(person=person,
                            entity=training_not_2m.management_entity)
        url = reverse("education_group_read",
                      args=[training_not_2m.pk, training_not_2m.pk])
        self.client.force_login(user)

        response = self.client.get(url)
        self.assertTrue(response.context['show_coorganization'])
        self.assertFalse(response.context['can_change_coorganization'])

        user.groups.add(Group.objects.get(name=CENTRAL_MANAGER_GROUP))

        response = self.client.get(url)
        self.assertTrue(response.context['show_coorganization'])
        self.assertTrue(response.context['can_change_coorganization'])
Пример #15
0
    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)
Пример #16
0
    def setUp(self):
        current_ac = create_current_academic_year()
        self.education_group_year = TrainingFactory(academic_year=current_ac)
        self.person = FacultyManagerFactory("delete_educationgroup",
                                            "change_educationgroup",
                                            "add_educationgroup")
        PersonEntityFactory(person=self.person,
                            entity=self.education_group_year.management_entity)

        # Create an academic calendar in order to check permission [Faculty can modify when period is opened]
        self.academic_calendar = AcademicCalendarFactory(
            reference=EDUCATION_GROUP_EDITION,
            start_date=timezone.now(),
            end_date=timezone.now() + timedelta(weeks=+1),
            academic_year=current_ac,
        )

        self.client.force_login(user=self.person.user)
        self.url = reverse(
            'delete_education_group',
            args=[self.education_group_year.id, self.education_group_year.id])
        self.context = {
            "person": self.person,
            "root": self.education_group_year,
            "education_group_year": self.education_group_year,
            "request": RequestFactory().get("")
        }
Пример #17
0
    def setUp(self):
        self.academic_year = create_current_academic_year()
        self.learning_unit_year = LearningUnitYearFactory(
            academic_year=self.academic_year,
            subtype=learning_unit_year_subtypes.FULL)

        self.language_fr = LanguageFactory(code="FR")
        self.language_en = LanguageFactory(code="EN")
        self.user = UserFactory()
        self.user.user_permissions.add(
            Permission.objects.get(codename="can_access_learningunit"))
        self.user.user_permissions.add(
            Permission.objects.get(codename="can_create_learningunit"))

        self.person = PersonFactory(user=self.user)
        self.a_superuser = SuperUserFactory()
        self.client.force_login(self.a_superuser)
        self.superperson = PersonFactory(user=self.a_superuser)

        self.person_entity = PersonEntityFactory(person=self.superperson)
        EntityContainerYearFactory(
            learning_container_year=self.learning_unit_year.
            learning_container_year,
            entity=self.person_entity.entity,
            type=entity_container_year_link_type.REQUIREMENT_ENTITY)
Пример #18
0
    def setUpTestData(cls):
        super().setUpTestData()

        cls.current_academic_year = AcademicYearFactory(current=True)
        cls.generated_ac_years = AcademicYearFactory.produce(
            base_year=cls.current_academic_year.year,
            number_past=0,
            number_future=7)
        cls.entity_version = MainEntityVersionFactory(
            entity_type=entity_type.SECTOR)
        cls.central_manager = CentralManagerFactory()
        PersonEntityFactory(person=cls.central_manager,
                            entity=cls.entity_version.entity)
        cls.training = TrainingFactory(
            management_entity=cls.entity_version.entity,
            administration_entity=cls.entity_version.entity,
            academic_year=cls.current_academic_year)
        cls.form_data = model_to_dict_fk(cls.training,
                                         exclude=('secondary_domains', ))
        cls.form_data.update({
            'primary_language':
            cls.form_data['primary_language_id'],
            'administration_entity':
            cls.entity_version.pk,
            'management_entity':
            cls.entity_version.pk
        })
Пример #19
0
    def setUp(self):
        self.user = UserFactory()
        self.user.user_permissions.add(
            Permission.objects.get(codename="can_access_learningunit"))
        self.user.user_permissions.add(
            Permission.objects.get(codename="can_edit_learningunit"))
        self.person = CentralManagerFactory(user=self.user)
        self.client.force_login(self.user)

        person_entity = PersonEntityFactory(
            person=self.person,
            entity=EntityVersionFactory().entity,
        )

        self.academic_year = create_current_academic_year()

        luy = LearningUnitYearFullFactory(
            academic_year=self.academic_year,
            internship_subtype=None,
            acronym="EFAC0000",
            learning_container_year__container_type=EXTERNAL,
            learning_container_year__requirement_entity=person_entity.entity,
        )
        self.external = ExternalLearningUnitYearFactory(learning_unit_year=luy)

        self.data = get_valid_external_learning_unit_form_data(
            self.academic_year, self.person, self.external.learning_unit_year)

        self.url = reverse(update_learning_unit,
                           args=[self.external.learning_unit_year.pk])
Пример #20
0
    def setUpTestData(cls):
        now = datetime.datetime.now()

        cls.academic_year = create_current_academic_year()
        cls.previous_academic_year = GenerateAcademicYear(
            cls.academic_year.year - 1,
            cls.academic_year.year - 1).academic_years[0]
        AcademicCalendarFactory(
            academic_year=cls.previous_academic_year,
            start_date=now - datetime.timedelta(days=5),
            end_date=now + datetime.timedelta(days=15),
            reference=academic_calendar_type.SUMMARY_COURSE_SUBMISSION)

        cls.requirement_entity_version = EntityVersionFactory(
            entity__organization__type=organization_type.MAIN,
            start_date=now,
            end_date=datetime.datetime(now.year + 1, 9, 15),
            entity_type=entity_type.INSTITUTE)
        cls.learning_unit_year = LearningUnitYearFactory(
            acronym="LBIR1100",
            academic_year=cls.academic_year,
            learning_container_year__academic_year=cls.academic_year,
            learning_container_year__acronym="LBIR1100",
            learning_container_year__requirement_entity=cls.
            requirement_entity_version.entity)
        cls.url = reverse('learning_units_summary')
        cls.faculty_person = FacultyManagerFactory(
            'can_access_learningunit', 'can_edit_learningunit_pedagogy')
        PersonEntityFactory(person=cls.faculty_person,
                            entity=cls.requirement_entity_version.entity)
Пример #21
0
    def test_post(self):
        new_entity_version = MainEntityVersionFactory()
        PersonEntityFactory(person=self.person, entity=new_entity_version.entity)

        data = {
            'title': 'Cours au choix',
            'title_english': 'deaze',
            'education_group_type': self.education_group_year.education_group_type.id,
            'credits': 42,
            'acronym': 'CRSCHOIXDVLD',
            'partial_acronym': 'LDVLD101R',
            'management_entity': new_entity_version.pk,
            'main_teaching_campus': "",
            'academic_year': self.education_group_year.academic_year.pk,
            "constraint_type": "",
        }
        response = self.client.post(self.url, data=data)

        self.assertEqual(response.status_code, 302)
        self.education_group_year.refresh_from_db()
        self.assertEqual(self.education_group_year.title, 'Cours au choix')
        self.assertEqual(self.education_group_year.title_english, 'deaze')
        self.assertEqual(self.education_group_year.credits, 42)
        self.assertEqual(self.education_group_year.acronym, 'CRSCHOIXDVLD')
        self.assertEqual(self.education_group_year.partial_acronym, 'LDVLD101R')
        self.assertEqual(self.education_group_year.management_entity, new_entity_version.entity)
Пример #22
0
    def setUp(self):
        self.user = UserFactory()
        self.user.user_permissions.add(
            Permission.objects.get(codename="can_access_learningunit"))
        self.user.user_permissions.add(
            Permission.objects.get(codename="can_edit_learningunit"))
        self.person = CentralManagerFactory(user=self.user)
        self.client.force_login(self.user)

        self.academic_year = create_current_academic_year()

        luy = LearningUnitYearFullFactory(academic_year=self.academic_year)
        self.external = ExternalLearningUnitYearFactory(learning_unit_year=luy)

        luy.learning_container_year.container_type = EXTERNAL
        luy.learning_container_year.save()

        EntityVersionFactory(entity=self.external.requesting_entity)
        PersonEntityFactory(person=self.person,
                            entity=self.external.requesting_entity)

        self.data = get_valid_external_learning_unit_form_data(
            self.academic_year, self.person, self.external.learning_unit_year)

        self.url = reverse(update_learning_unit,
                           args=[self.external.learning_unit_year.pk])
Пример #23
0
 def setUp(self):
     self.data = {
         'title': 'Métamorphose',
         'title_english': 'Transfiguration',
         'education_group_type': self.education_group_type.pk,
         'credits': 42,
         'acronym': 'CRSCHOIXDVLD',
         'partial_acronym': 'LDVLD101R',
         'management_entity': self.management_entity_version.pk,
         'administration_entity': MainEntityVersionFactory().pk,
         'main_teaching_campus': "",
         'academic_year': create_current_academic_year().pk,
         'active': ACTIVE,
         'schedule_type': DAILY,
         "internship": internship_presence.NO,
         "primary_language": LanguageFactory().pk,
         "start_year": 2010,
         "constraint_type": "",
         "diploma_printing_title": 'Diploma title'
     }
     self.administration_entity_version = MainEntityVersionFactory()
     self.education_group_year = TrainingFactory(
         academic_year=create_current_academic_year(),
         education_group_type__name=education_group_types.TrainingType.
         BACHELOR,
         management_entity=self.management_entity_version.entity,
         administration_entity=self.administration_entity_version.entity,
     )
     PersonEntityFactory(person=self.person,
                         entity=self.education_group_year.management_entity)
Пример #24
0
    def test_raise_permission_denied_if_person_is_faculty_manager_and_period_closed(self):
        CloseAcademicCalendarFactory(reference=EDUCATION_GROUP_EDITION, academic_year=self.previous_acy)
        person_entity = PersonEntityFactory(entity=self.group_element_year.parent.management_entity,
                                            person=FacultyManagerFactory())

        with self.assertRaises(PermissionDenied):
            can_update_group_element_year(person_entity.person.user, self.group_element_year)
    def setUp(self):
        self.academic_years = GenerateAcademicYear(
            start_year=get_current_year(), end_year=get_current_year() + 10)
        self.generate_container = GenerateContainer(
            start_year=get_current_year(), end_year=get_current_year() + 10)
        self.generated_container_year = self.generate_container.generated_container_years[
            0]

        self.container_year = self.generated_container_year.learning_container_year
        self.learning_unit_year = self.generated_container_year.learning_unit_year_full
        self.learning_unit_year_partim = self.generated_container_year.learning_unit_year_partim

        self.person = PersonFactory()

        edit_learning_unit_permission = Permission.objects.get(
            codename="can_edit_learningunit")
        self.person.user.user_permissions.add(edit_learning_unit_permission)

        self.url = reverse('learning_unit_volumes_management',
                           kwargs={
                               'learning_unit_year_id':
                               self.learning_unit_year.id,
                               'form_type': 'full'
                           })

        self.client.force_login(self.person.user)
        self.user = self.person.user

        PersonEntityFactory(entity=self.generate_container.entities[0],
                            person=self.person)
Пример #26
0
    def setUpTestData(cls, **kwargs):
        cls.education_group_type = kwargs.pop('education_group_type')

        cls.campus = CampusFactory(organization__type=organization_type.MAIN)
        cls.academic_year = AcademicYearFactory()
        new_entity_version = MainEntityVersionFactory()

        cls.form_data = {
            "acronym": "ACRO4569",
            "partial_acronym": "PACR8974",
            "education_group_type": cls.education_group_type.id,
            "title": "Test data",
            "main_teaching_campus": cls.campus.id,
            "academic_year": cls.academic_year.id,
            "management_entity": new_entity_version.pk,
            "remark": "This is a test!!"
        }

        cls.parent_education_group_year = EducationGroupYearFactory(
            academic_year=cls.academic_year)
        # Append version to management/administration entity
        cls.entity_version = EntityVersionFactory(
            entity=cls.parent_education_group_year.management_entity)
        if cls.education_group_type.category == TRAINING:
            EntityVersionFactory(
                entity=cls.parent_education_group_year.administration_entity)

        # Create user and attached it to management entity
        person = PersonFactory()
        PersonEntityFactory(
            person=person,
            entity=cls.parent_education_group_year.management_entity)
        cls.user = person.user
Пример #27
0
    def test_cannot_delete_learning_unit_year_with_administrative_manager_role(
            self):
        manager = AdministrativeManagerFactory()
        entity_version = EntityVersionFactory(entity_type=entity_type.FACULTY,
                                              acronym="SST",
                                              start_date=datetime.date(
                                                  year=1990, month=1, day=1),
                                              end_date=None)
        PersonEntityFactory(person=manager,
                            entity=entity_version.entity,
                            with_child=True)

        # Cannot remove FULL COURSE
        self.assertFalse(
            base.business.learning_units.perms.
            is_eligible_to_delete_learning_unit_year(self.luy1, manager))

        # Can remove PARTIM COURSE
        self.luy1.subtype = learning_unit_year_subtypes.PARTIM
        self.luy1.save()
        self.assertFalse(
            base.business.learning_units.perms.
            is_eligible_to_delete_learning_unit_year(self.luy1, manager))
        self.luy1.subtype = learning_unit_year_subtypes.FULL
        self.luy1.save()
Пример #28
0
    def setUpTestData(cls):
        cls.current_academic_year = create_current_academic_year()
        cls.next_academic_year = AcademicYearFactory(year=cls.current_academic_year.year + 1)

        cls.person = CentralManagerFactory()
        cls.person.user.user_permissions.add(Permission.objects.get(codename="change_educationgroup"))
        cls.person.user.user_permissions.add(Permission.objects.get(codename="can_access_education_group"))

        cls.education_group = EducationGroupFactory(end_year=cls.next_academic_year)
        cls.education_group_year = TrainingFactory(academic_year=cls.current_academic_year,
                                                   education_group=cls.education_group)

        cls.next_education_group_year = TrainingFactory(
            academic_year=cls.next_academic_year,
            education_group=cls.education_group,
            management_entity=cls.education_group_year.management_entity
        )

        PersonEntityFactory(person=cls.person, entity=cls.education_group_year.management_entity)

        cls.group_element_year = GroupElementYearFactory(
            parent=cls.education_group_year,
            child_branch__academic_year=cls.education_group_year.academic_year
        )
        cls.url = reverse(
            "postpone_education_group",
            kwargs={
                "root_id": cls.next_education_group_year.pk,
                "education_group_year_id": cls.next_education_group_year.pk,
            }
        )

        cls.redirect_url = reverse("education_group_read",
                                   args=[cls.next_education_group_year.pk, cls.next_education_group_year.pk])
Пример #29
0
    def test_cannot_delete_learning_unit_year_with_administrative_manager_role(self):
        manager = AdministrativeManagerFactory()
        entity_version = EntityVersionFactory(entity_type=entity_type.FACULTY, acronym="SST",
                                              start_date=datetime.date(year=1990, month=1, day=1),
                                              end_date=None)
        PersonEntityFactory(person=manager, entity=entity_version.entity, with_child=True)

        # Creation UE
        learning_unit = LearningUnitFactory()
        l_containeryear = LearningContainerYearFactory(academic_year=self.academic_year,
                                                       container_type=learning_container_year_types.COURSE,
                                                       requirement_entity=entity_version.entity)
        learning_unit_year = LearningUnitYearFactory(learning_unit=learning_unit,
                                                     academic_year=self.academic_year,
                                                     learning_container_year=l_containeryear,
                                                     subtype=learning_unit_year_subtypes.FULL)

        # Cannot remove FULL COURSE
        self.assertFalse(
            base.business.learning_units.perms.is_eligible_to_delete_learning_unit_year(
                learning_unit_year,
                manager
            )
        )

        # Can remove PARTIM COURSE
        learning_unit_year.subtype = learning_unit_year_subtypes.PARTIM
        learning_unit_year.save()
        self.assertFalse(
            base.business.learning_units.perms.is_eligible_to_delete_learning_unit_year(
                learning_unit_year,
                manager
            )
        )
Пример #30
0
    def setUpTestData(cls):
        cls.current_academic_year = create_current_academic_year()

        cls.proposal = ProposalLearningUnitFactory(
            state=proposal_state.ProposalState.ACCEPTED.name,
            learning_unit_year__subtype=learning_unit_year_subtypes.FULL,
            learning_unit_year__academic_year=cls.current_academic_year,
            learning_unit_year__learning_container_year__academic_year=cls.
            current_academic_year)
        cls.learning_unit_year = cls.proposal.learning_unit_year

        cls.person = PersonFactory()
        cls.person.user.user_permissions.add(
            Permission.objects.get(codename="can_access_learningunit"))
        cls.person.user.user_permissions.add(
            Permission.objects.get(
                codename="can_consolidate_learningunit_proposal"))

        person_entity = PersonEntityFactory(
            person=cls.person,
            entity=EntityContainerYearFactory(
                learning_container_year=cls.learning_unit_year.
                learning_container_year,
                type=entity_container_year_link_type.REQUIREMENT_ENTITY).entity
        )
        EntityVersionFactory(entity=person_entity.entity)
        cls.url = reverse("learning_unit_consolidate_proposal")
        cls.post_data = {"learning_unit_year_id": cls.learning_unit_year.id}