Ejemplo n.º 1
0
    def setUp(self):

        academic_year = AcademicYearFactory()
        self.education_group_type_training = EducationGroupTypeFactory(
            category=education_group_categories.TRAINING)
        self.education_group_type_minitraining = EducationGroupTypeFactory(
            category=education_group_categories.MINI_TRAINING)
        self.education_group_type_group = EducationGroupTypeFactory(
            category=education_group_categories.GROUP)

        self.education_group_year_1 = EducationGroupYearFactory(
            academic_year=academic_year,
            education_group_type=self.education_group_type_training)
        self.education_group_year_2 = EducationGroupYearFactory(
            academic_year=academic_year,
            education_group_type=self.education_group_type_minitraining)

        self.education_group_year_3 = EducationGroupYearFactory(
            academic_year=academic_year,
            education_group_type=self.education_group_type_training)
        self.education_group_year_4 = EducationGroupYearFactory(
            academic_year=academic_year,
            education_group_type=self.education_group_type_group)
        self.education_group_year_5 = EducationGroupYearFactory(
            academic_year=academic_year,
            education_group_type=self.education_group_type_group)

        self.offer_year_2 = OfferYearFactory(academic_year=academic_year)
        self.offer_year_domain = OfferYearDomainFactory(
            offer_year=self.offer_year_2,
            education_group_year=self.education_group_year_2)
        self.offer_year_entity_admin = OfferYearEntityFactory(
            offer_year=self.offer_year_2,
            education_group_year=self.education_group_year_2,
            type=offer_year_entity_type.ENTITY_ADMINISTRATION)
        self.entity_version_admin = EntityVersionFactory(
            entity=self.offer_year_entity_admin.entity, parent=None)

        self.offer_year_3 = OfferYearFactory(academic_year=academic_year)
        self.offer_year_entity_management = OfferYearEntityFactory(
            offer_year=self.offer_year_3,
            education_group_year=self.education_group_year_3,
            type=offer_year_entity_type.ENTITY_MANAGEMENT)
        self.entity_version_management = EntityVersionFactory(
            entity=self.offer_year_entity_management.entity, parent=None)

        self.group_element_year_4 = GroupElementYearFactory(
            parent=self.education_group_year_3,
            child_branch=self.education_group_year_1)
        self.group_element_year_5 = GroupElementYearFactory(
            parent=self.education_group_year_3,
            child_branch=self.education_group_year_1)
Ejemplo n.º 2
0
def generate_learning_unit_year_with_associated_education_group(
        academic_year, same_faculty=True, same_entity=True):
    luy = LearningUnitYearFactory(
        academic_year=academic_year,
        learning_container_year__academic_year=academic_year)

    entity_container_year = EntityContainerYearFactory(
        learning_container_year=luy.learning_container_year,
        type=entity_container_year_link_type.REQUIREMENT_ENTITY)

    entity_version = EntityVersionFactory(entity=entity_container_year.entity,
                                          entity_type=entity_type.SCHOOL)
    parent_entity = EntityVersionFactory(entity=entity_version.parent,
                                         parent=None,
                                         entity_type=entity_type.FACULTY)

    if not same_entity:
        entity_version = parent_entity
    if not same_faculty:
        entity_version = EntityVersionFactory(entity_type=entity_type.FACULTY)

    offer_year_entity = OfferYearEntityFactory(
        entity=entity_version.entity,
        education_group_year__academic_year=academic_year)

    GroupElementYearFactory(
        child_branch=offer_year_entity.education_group_year, parent=None)
    GroupElementYearFactory(child_branch=None,
                            child_leaf=luy,
                            parent=offer_year_entity.education_group_year)

    return luy
Ejemplo n.º 3
0
 def _create_data_for_entity_address(self, entity_type):
     past_date = datetime.datetime(year=2015, month=1, day=1)
     country = CountryFactory()
     entity = EntityFactory(country=country)
     EntityVersionFactory(entity=entity,
                          start_date=past_date,
                          end_date=None)
     OfferYearEntityFactory(offer_year=self.offer_year,
                            entity=entity,
                            type=entity_type)
     return entity
Ejemplo n.º 4
0
 def _create_data_for_entity_address(cls, entity_type):
     past_date = datetime.datetime(year=2015, month=1, day=1)
     education_group_year = EducationGroupYearFactory(academic_year=cls.academic_year)
     country = CountryFactory()
     entity = EntityFactory(country=country)
     EntityVersionFactory(entity=entity,
                          start_date=past_date,
                          end_date=None)
     OfferYearEntityFactory(offer_year=cls.offer_year,
                            entity=entity,
                            type=entity_type,
                            education_group_year=education_group_year)
     return entity
Ejemplo n.º 5
0
 def setUp(self):
     # Get or Create Permission to edit administrative data
     content_type = ContentType.objects.get_for_model(Person)
     permission, created = Permission.objects.get_or_create(
         codename="can_edit_education_group_administrative_data",
         content_type=content_type)
     self.user = UserFactory()
     self.person = PersonFactory(user=self.user)
     self.user.user_permissions.add(permission)
     # Create structure
     self._create_basic_entity_structure()
     # Create education group with 'CHIM' as entity management
     self.education_group_year = EducationGroupYearFactory()
     OfferYearEntityFactory(education_group_year=self.education_group_year,
                            type=offer_year_entity_type.ENTITY_MANAGEMENT,
                            entity=self.chim_entity)
Ejemplo n.º 6
0
    def setUpTestData(cls):
        today = datetime.date.today()
        cls.academic_year = AcademicYearFactory(
            start_date=today,
            end_date=today.replace(year=today.year + 1),
            year=today.year)
        cls.previous_academic_year = AcademicYearFactory(
            start_date=today.replace(year=today.year - 1),
            end_date=today - datetime.timedelta(days=1),
            year=today.year - 1)

        cls.type_training = EducationGroupTypeFactory(
            category=education_group_categories.TRAINING)
        cls.type_minitraining = EducationGroupTypeFactory(
            category=education_group_categories.MINI_TRAINING)
        cls.type_group = EducationGroupTypeFactory(
            category=education_group_categories.GROUP)

        cls.education_group_edph2 = EducationGroupYearFactory(
            acronym='EDPH2',
            academic_year=cls.academic_year,
            partial_acronym='EDPH2_SCS',
            education_group_type=cls.type_group)
        cls.education_group_arke2a = EducationGroupYearFactory(
            acronym='ARKE2A',
            academic_year=cls.academic_year,
            education_group_type=cls.type_training)
        cls.education_group_hist2a = EducationGroupYearFactory(
            acronym='HIST2A',
            academic_year=cls.academic_year,
            education_group_type=cls.type_group)
        cls.education_group_arke2a_previous_year = EducationGroupYearFactory(
            acronym='ARKE2A',
            academic_year=cls.previous_academic_year,
            education_group_type=cls.type_training)

        oph_entity = EntityFactory()
        envi_entity = EntityFactory()
        cls.oph_entity_v = EntityVersionFactory(entity=oph_entity,
                                                parent=envi_entity,
                                                end_date=None)
        cls.envi_entity_v = EntityVersionFactory(entity=envi_entity,
                                                 end_date=None)

        cls.offer_year_entity_edph2 = OfferYearEntityFactory(
            education_group_year=cls.education_group_edph2,
            entity=envi_entity,
            type=offer_year_entity_type.ENTITY_MANAGEMENT)
        cls.offer_year_entity_hist2a = OfferYearEntityFactory(
            education_group_year=cls.education_group_hist2a,
            entity=oph_entity,
            type=offer_year_entity_type.ENTITY_MANAGEMENT)
        cls.offer_year_entity_arke2a = OfferYearEntityFactory(
            education_group_year=cls.education_group_arke2a,
            type=offer_year_entity_type.ENTITY_MANAGEMENT,
            entity=oph_entity)
        cls.offer_year_entity_arke2a_previous_year = \
            OfferYearEntityFactory(education_group_year=cls.education_group_arke2a_previous_year,
                                   entity=oph_entity,
                                   type=offer_year_entity_type.ENTITY_MANAGEMENT)

        cls.user = UserFactory()
        cls.user.user_permissions.add(
            Permission.objects.get(codename="can_access_education_group"))
        cls.url = reverse("education_groups")
Ejemplo n.º 7
0
    def _prepare_context_education_groups_search(self):
        # Create a structure [Entity / Entity version]
        country = CountryFactory()
        structure = StructureFactory()
        ssh_entity = EntityFactory(country=country)
        ssh_entity_v = EntityVersionFactory(acronym="SSH",
                                            end_date=None,
                                            entity=ssh_entity)

        agro_entity = EntityFactory(country=country)
        envi_entity = EntityFactory(country=country)
        ages_entity = EntityFactory(country=country)
        agro_entity_v = EntityVersionFactory(entity=agro_entity,
                                             parent=ssh_entity_v.entity,
                                             acronym="AGRO",
                                             end_date=None)
        envi_entity_v = EntityVersionFactory(entity=envi_entity,
                                             parent=agro_entity_v.entity,
                                             acronym="ENVI",
                                             end_date=None)
        ages_entity_v = EntityVersionFactory(entity=ages_entity,
                                             parent=agro_entity_v.entity,
                                             acronym="AGES",
                                             end_date=None)

        # Create EG and put entity charge [AGRO]
        agro_education_group = EducationGroupFactory()
        agro_education_group_type = EducationGroupTypeFactory(
            category=TRAINING)

        agro_education_group_year = EducationGroupYearFactory(
            acronym='EDPH2',
            academic_year=self.academic_year,
            education_group=agro_education_group,
            education_group_type=agro_education_group_type)

        agro_offer = OfferFactory()
        agro_offer_year = OfferYearFactory(offer=agro_offer,
                                           entity_management=structure,
                                           entity_administration_fac=structure)

        OfferYearEntityFactory(offer_year=agro_offer_year,
                               entity=agro_entity,
                               education_group_year=agro_education_group_year,
                               type=offer_year_entity_type.ENTITY_MANAGEMENT)

        # Create EG and put entity charge [ENVI]
        envi_education_group = EducationGroupFactory()
        envi_education_group_type = EducationGroupTypeFactory(
            category=TRAINING)

        envi_education_group_year = EducationGroupYearFactory(
            academic_year=self.academic_year,
            education_group=envi_education_group,
            education_group_type=envi_education_group_type)

        envi_offer = OfferFactory()
        envi_offer_year = OfferYearFactory(offer=envi_offer,
                                           entity_management=structure,
                                           entity_administration_fac=structure)

        OfferYearEntityFactory(offer_year=envi_offer_year,
                               entity=envi_entity,
                               education_group_year=envi_education_group_year,
                               type=offer_year_entity_type.ENTITY_MANAGEMENT)

        # Create EG and put entity charge [AGES]
        ages_education_group = EducationGroupFactory()
        ages_education_group_type = EducationGroupTypeFactory(
            category=TRAINING)

        ages_education_group_year = EducationGroupYearFactory(
            academic_year=self.academic_year,
            education_group=ages_education_group,
            education_group_type=ages_education_group_type)

        ages_offer = OfferFactory()
        ages_offer_year = OfferYearFactory(offer=ages_offer,
                                           entity_management=structure,
                                           entity_administration_fac=structure)

        OfferYearEntityFactory(offer_year=ages_offer_year,
                               entity=ages_entity,
                               education_group_year=ages_education_group_year,
                               type=offer_year_entity_type.ENTITY_MANAGEMENT)