Ejemplo n.º 1
0
    def setUpTestData(cls):
        faculty = EntityFactory()
        other_faculty = EntityFactory()
        third_faculty = EntityFactory()
        EntityVersionFactory(entity_type="FACULTY", entity=faculty)
        EntityVersionFactory(entity_type="FACULTY", entity=other_faculty)
        EntityVersionFactory(entity_type="FACULTY", entity=third_faculty)

        # Users
        cls.lambda_user = UserFactory()
        cls.adri_user = UserFactory()
        entity_version = EntityVersionFactory(acronym="ADRI")
        PartnershipEntityManagerFactory(entity=entity_version.entity,
                                        person__user=cls.adri_user)
        cls.gf_user = UserFactory()
        PartnershipEntityManagerFactory(person__user=cls.gf_user,
                                        entity=faculty)
        cls.other_gf_user = UserFactory()
        PartnershipEntityManagerFactory(person__user=cls.other_gf_user,
                                        entity=other_faculty)

        cls.ucl_management_entity = UCLManagementEntityFactory(entity=faculty)
        cls.ucl_management_entity_linked = UCLManagementEntityFactory(
            entity=third_faculty, )
        PartnershipFactory(ucl_entity=third_faculty)

        cls.url = reverse('partnerships:ucl_management_entities:delete',
                          kwargs={"pk": cls.ucl_management_entity.pk})

        cls.linked_url = reverse(
            'partnerships:ucl_management_entities:delete',
            kwargs={"pk": cls.ucl_management_entity_linked.pk},
        )
        cls.template_name = 'partnerships/ucl_management_entities/uclmanagemententity_delete.html'
    def setUpTestData(cls):
        cls.user = UserFactory()
        entity_version = EntityVersionFactory(acronym='ADRI')
        PartnershipEntityManagerFactory(
            entity=entity_version.entity,
            person__user=cls.user,
            scopes=[PartnershipType.GENERAL.name]
        )

        cls.partner = PartnerFactory()
        cls.partner_entity = PartnerEntityFactory(partner=cls.partner)

        AcademicYearFactory.produce_in_future(quantity=3)

        cls.education_field = DomainIscedFactory()
        cls.education_level = PartnershipYearEducationLevelFactory()

        cls.url = resolve_url('partnerships:create',
                              type=PartnershipType.GENERAL)

        # Ucl
        root = EntityVersionFactory(parent=None).entity
        sector = EntityVersionFactory(entity_type=SECTOR, parent=root).entity
        cls.ucl_university = EntityVersionFactory(
            parent=sector,
            entity_type=FACULTY,
        ).entity
        cls.ucl_university_labo = EntityVersionFactory(
            parent=cls.ucl_university,
        ).entity
        UCLManagementEntityFactory(entity=cls.ucl_university)

        cls.university_offer = EducationGroupYearFactory(
            administration_entity=cls.ucl_university_labo,
        )

        cls.data = {
            'partnership_type': PartnershipType.GENERAL.name,
            'comment': '',
            'partner': cls.partner.pk,
            'partner_entities': [cls.partner_entity.entity_id],
            'supervisor': PersonFactory().pk,
            'ucl_entity': cls.ucl_university.pk,
            'university_offers': [cls.university_offer.pk],
            'start_date': date.today(),
            'end_date': date.today() + timedelta(days=365),
            'year-is_sms': True,
            'year-is_smp': False,
            'year-is_sta': True,
            'year-is_stt': False,
            'year-education_fields': [cls.education_field.pk],
            'year-education_levels': [cls.education_level.pk],
            'year-entities': [],
            'year-offers': [],
            'year-funding_type': FundingTypeFactory().pk,
            'missions': PartnershipMissionFactory().pk,
            'subtype': PartnershipSubtypeFactory().pk,
        }
Ejemplo n.º 3
0
    def setUpTestData(cls):
        cls.user = UserFactory()
        entity_version = EntityVersionFactory(acronym='ADRI')
        PartnershipEntityManagerFactory(
            entity=entity_version.entity,
            person__user=cls.user,
            scopes=[PartnershipType.COURSE.name]
        )

        cls.partner = PartnerFactory()
        cls.partner_entity = PartnerEntityFactory(partner=cls.partner)

        AcademicYearFactory.produce_in_future(quantity=3)

        cls.education_field = DomainIscedFactory()
        cls.education_level = PartnershipYearEducationLevelFactory()

        cls.url = reverse(
            'partnerships:create',
            kwargs={'type': PartnershipType.COURSE},
        )

        cls.start_academic_year = AcademicYearFactory(year=2150)
        cls.end_academic_year = AcademicYearFactory(year=2151)

        # Ucl
        root = EntityVersionFactory(parent=None).entity
        sector = EntityVersionFactory(entity_type=SECTOR, parent=root).entity
        cls.ucl_university = EntityVersionFactory(
            parent=sector,
            entity_type=FACULTY,
        ).entity
        cls.ucl_university_labo = EntityVersionFactory(
            parent=cls.ucl_university,
        ).entity
        UCLManagementEntityFactory(entity=cls.ucl_university)

        cls.university_offer = EducationGroupYearFactory(administration_entity=cls.ucl_university_labo)

        cls.data = {
            'partnership_type': PartnershipType.COURSE.name,
            'comment': '',
            'partner': cls.partner.pk,
            'partner_entities': [cls.partner_entity.entity_id],
            'supervisor': PersonFactory().pk,
            'ucl_entity': cls.ucl_university.pk,
            'university_offers': [cls.university_offer.pk],
            'year-education_fields': [cls.education_field.pk],
            'year-education_levels': [cls.education_level.pk],
            'year-entities': [],
            'year-offers': [],
            'year-start_academic_year': cls.start_academic_year.pk,
            'year-end_academic_year': cls.end_academic_year.pk,
            'year-funding_type': FundingTypeFactory().pk,
            'missions': PartnershipMissionFactory().pk,
            'subtype': PartnershipSubtypeFactory().pk,
        }
    def setUpTestData(cls):
        cls.user = UserFactory()
        entity_version = EntityVersionFactory(acronym='ADRI')
        PartnershipEntityManagerFactory(entity=entity_version.entity,
                                        person__user=cls.user,
                                        scopes=[PartnershipType.PROJECT.name])

        cls.partner = PartnerFactory()
        cls.partner_entity = PartnerEntityFactory(partner=cls.partner)

        AcademicYearFactory.produce_in_future(quantity=3)

        cls.education_field = DomainIscedFactory()
        cls.education_level = PartnershipYearEducationLevelFactory()

        cls.url = reverse(
            'partnerships:create',
            kwargs={'type': PartnershipType.PROJECT},
        )

        # Ucl
        root = EntityVersionFactory(parent=None).entity
        sector = EntityVersionFactory(entity_type=SECTOR, parent=root).entity
        cls.ucl_university = EntityVersionFactory(
            parent=sector,
            entity_type=FACULTY,
        ).entity
        cls.ucl_university_labo = EntityVersionFactory(
            parent=cls.ucl_university, ).entity
        UCLManagementEntityFactory(entity=cls.ucl_university)

        cls.university_offer = EducationGroupYearFactory(
            administration_entity=cls.ucl_university_labo)

        cls.data = {
            'partnership_type': PartnershipType.PROJECT.name,
            'comment': '',
            'partner': cls.partner.pk,
            'partner_entities': [cls.partner_entity.entity_id],
            'supervisor': PersonFactory().pk,
            'ucl_entity': cls.ucl_university.pk,
            'university_offers': [cls.university_offer.pk],
            'start_date': date.today(),
            'end_date': date.today() + timedelta(days=365),
            'year-education_fields': [cls.education_field.pk],
            'year-education_levels': [cls.education_level.pk],
            'missions': PartnershipMissionFactory().pk,
            'year-funding': 'fundingtype-%s' % FundingTypeFactory().pk,
            'project_title': "Project title 1",
            'id_number': "#132456",
            'ucl_status': "coordinator",
        }
        PartnershipMissionFactory()
Ejemplo n.º 5
0
    def setUpTestData(cls):
        sector = EntityFactory()
        EntityVersionFactory(entity_type="SECTOR", entity=sector)
        faculty = EntityFactory()
        EntityVersionFactory(entity=faculty,
                             parent=sector,
                             entity_type=FACULTY)
        other_faculty = EntityFactory()
        EntityVersionFactory(entity_type="FACULTY", entity=faculty)
        EntityVersionFactory(entity_type="FACULTY", entity=other_faculty)

        # Users
        cls.lambda_user = UserFactory()
        cls.adri_user = UserFactory()
        entity_version = EntityVersionFactory(acronym="ADRI")
        PartnershipEntityManagerFactory(entity=entity_version.entity,
                                        person__user=cls.adri_user)
        cls.gs_user = UserFactory()
        PartnershipEntityManagerFactory(person__user=cls.gs_user,
                                        entity=sector)
        cls.gf_user = UserFactory()
        PartnershipEntityManagerFactory(person__user=cls.gf_user,
                                        entity=faculty)
        cls.other_gf_user = UserFactory()
        PartnershipEntityManagerFactory(person__user=cls.other_gf_user,
                                        entity=other_faculty)

        for i in range(GF_UME_NUMBER):
            entity = EntityFactory()
            EntityVersionFactory(entity=entity, parent=faculty)
            UCLManagementEntityFactory(entity=entity)
        for i in range(OTHER_GF_UME_NUMBER):
            UCLManagementEntityFactory(entity=EntityVersionFactory(
                entity=EntityFactory(),
                parent=other_faculty,
            ).entity, )

        cls.url = reverse('partnerships:ucl_management_entities:list')
    def setUpTestData(cls):
        faculty = EntityFactory()
        EntityVersionFactory(entity_type="FACULTY", entity=faculty)

        # Users
        cls.lambda_user = UserFactory()
        cls.adri_user = UserFactory()
        entity_version = EntityVersionFactory(acronym="ADRI")
        PartnershipEntityManagerFactory(entity=entity_version.entity,
                                        person__user=cls.adri_user)
        cls.gf_user = UserFactory()
        entity_manager = PartnershipEntityManagerFactory(
            person__user=cls.gf_user, entity=faculty)

        cls.url = reverse("partnerships:ucl_management_entities:create")

        # Data :
        cls.faculty = EntityFactory()
        EntityVersionFactory(entity=cls.faculty, entity_type=FACULTY)
        cls.entity = EntityFactory()
        cls.academic_responsible = PersonFactory()
        cls.administrative_responsible = PersonFactory()
        cls.contact_in_person = PersonFactory()
        cls.contact_out_person = PersonFactory()

        # Case for duplicate with faculty:
        UCLManagementEntityFactory(entity=cls.faculty)

        cls.data = {
            'academic_responsible': str(cls.academic_responsible.pk),
            'administrative_responsible':
            str(cls.administrative_responsible.pk),
            'contact_in_email': '*****@*****.**',
            'contact_in_person': str(cls.contact_in_person.pk),
            'contact_in_url': 'http://foo.fr/foo',
            'contact_out_email': '*****@*****.**',
            'contact_out_person': str(cls.contact_out_person.pk),
            'contact_out_url': 'http://bar.fr/bar',
            'entity': str(cls.entity.pk),
        }
        cls.template_create = 'partnerships/ucl_management_entities/uclmanagemententity_create.html'
        cls.template_list = 'partnerships/ucl_management_entities/uclmanagemententity_list.html'
Ejemplo n.º 7
0
    def setUpTestData(cls):
        cls.template_name = 'partnerships/partnership/partnership_confirm_delete.html'

        # Ucl
        sector = EntityFactory()
        EntityVersionFactory(entity=sector, entity_type=SECTOR)
        cls.ucl_university = EntityFactory()
        EntityVersionFactory(entity=cls.ucl_university,
                             parent=sector,
                             entity_type=FACULTY)
        UCLManagementEntityFactory(entity=cls.ucl_university)

        # Users
        cls.user = PartnershipViewerFactory().person.user
        cls.user_gf = PartnershipEntityManagerFactory(
            entity=cls.ucl_university, ).person.user
        cls.user_adri = PartnershipEntityManagerFactory(
            entity=EntityVersionFactory(acronym='ADRI').entity, ).person.user

        # Years
        cls.start_academic_year = AcademicYearFactory(year=2150)
        cls.from_academic_year = AcademicYearFactory(year=2151)
        cls.end_academic_year = AcademicYearFactory(year=2152)

        # Partnerships
        cls.partnership = PartnershipFactory(
            author=cls.user_gf.person,
            ucl_entity=cls.ucl_university,
        )
        cls.url = resolve_url('partnerships:delete', pk=cls.partnership.pk)

        cls.partnership_with_agreements = PartnershipFactory(
            author=cls.user_gf.person,
            ucl_entity=cls.ucl_university,
        )
        PartnershipAgreementFactory(
            partnership=cls.partnership_with_agreements)
        cls.url_with = resolve_url('partnerships:delete',
                                   pk=cls.partnership_with_agreements.pk)
Ejemplo n.º 8
0
    def setUpTestData(cls):
        cls.user = UserFactory()
        entity_version = EntityVersionFactory(acronym='ADRI')
        PartnershipEntityManagerFactory(
            entity=entity_version.entity,
            person__user=cls.user,
            scopes=[PartnershipType.COURSE.name]
        )

        # Dates :
        cls.partner = PartnerFactory()
        cls.partner_entity = PartnerEntityFactory(partner=cls.partner)

        # Years
        cls.start_academic_year = AcademicYearFactory(year=2150)
        cls.from_academic_year = AcademicYearFactory(year=2151)
        cls.end_academic_year = AcademicYearFactory(year=2152)

        cls.education_field = DomainIscedFactory()
        cls.education_level = PartnershipYearEducationLevelFactory()

        # Ucl
        root = EntityVersionFactory(parent=None).entity
        sector = EntityVersionFactory(entity_type=SECTOR, parent=root).entity
        cls.ucl_university = EntityVersionFactory(
            parent=sector,
            entity_type=FACULTY,
        ).entity
        UCLManagementEntityFactory(entity=cls.ucl_university)
        cls.ucl_university_labo = EntityVersionFactory(
            parent=cls.ucl_university,
        ).entity
        UCLManagementEntityFactory(entity=cls.ucl_university_labo)

        cls.partnership = PartnershipFactory(
            partnership_type=PartnershipType.COURSE.name,
            partner=cls.partner,
            partner_entity=cls.partner_entity.entity,
            author=cls.user.person,
            years=[],
            ucl_entity=cls.ucl_university,
        )
        PartnershipYearFactory(
            partnership=cls.partnership,
            academic_year=cls.start_academic_year,
        )
        PartnershipYearFactory(
            partnership=cls.partnership,
            academic_year=cls.from_academic_year,
        )
        PartnershipYearFactory(
            partnership=cls.partnership,
            academic_year=cls.end_academic_year,
        )
        cls.url = resolve_url('partnerships:update', pk=cls.partnership.pk)

        cls.data = {
            'comment': '',
            'partner': cls.partner.pk,
            'partner_entities': [cls.partner_entity.entity_id],
            'supervisor': cls.user.person.pk,
            'ucl_entity': cls.ucl_university_labo.pk,
            'year-start_academic_year': cls.start_academic_year.pk,
            'year-end_academic_year': cls.end_academic_year.pk,
            'year-from_academic_year': cls.from_academic_year.pk,
            'year-education_fields': [cls.education_field.pk],
            'year-education_levels': [cls.education_level.pk],
            'year-entities': [],
            'year-offers': [],
            'year-funding_type': FundingTypeFactory().pk,
            'missions': [
                PartnershipMissionFactory().pk,
                PartnershipMissionFactory().pk,
            ],
            'subtype': PartnershipSubtypeFactory().pk,
        }
Ejemplo n.º 9
0
    def setUpTestData(cls):
        sector = EntityFactory()
        EntityVersionFactory(entity=sector)
        faculty = EntityFactory()
        EntityVersionFactory(entity=faculty,
                             parent=sector,
                             entity_type=FACULTY)
        other_faculty = EntityFactory()
        EntityVersionFactory(entity=other_faculty, entity_type=FACULTY)

        cls.ucl_management_entity = UCLManagementEntityFactory(entity=faculty)
        cls.other_ucl_management_entity = UCLManagementEntityFactory(
            entity=EntityVersionFactory(parent=other_faculty, ).entity, )
        cls.ucl_management_entity_linked = UCLManagementEntityFactory(
            entity=other_faculty, )
        PartnershipFactory(ucl_entity=other_faculty)

        # Users
        cls.lambda_user = UserFactory()
        cls.adri_user = UserFactory()
        entity_version = EntityVersionFactory(acronym="ADRI")
        PartnershipEntityManagerFactory(entity=entity_version.entity,
                                        person__user=cls.adri_user)
        cls.gs_user = UserFactory()
        PartnershipEntityManagerFactory(person__user=cls.gs_user,
                                        entity=sector)
        cls.gf_user = UserFactory()
        PartnershipEntityManagerFactory(person__user=cls.gf_user,
                                        entity=faculty)
        cls.other_gf_user = UserFactory()
        PartnershipEntityManagerFactory(person__user=cls.other_gf_user,
                                        entity=other_faculty)

        cls.url = reverse(
            "partnerships:ucl_management_entities:update",
            kwargs={'pk': cls.ucl_management_entity.pk},
        )
        cls.other_url = reverse(
            "partnerships:ucl_management_entities:update",
            kwargs={'pk': cls.other_ucl_management_entity.pk},
        )
        cls.linked_url = reverse(
            "partnerships:ucl_management_entities:update",
            kwargs={"pk": cls.ucl_management_entity_linked.pk},
        )

        # Data :
        cls.faculty = EntityFactory()
        EntityVersionFactory(entity=cls.faculty, entity_type=FACULTY)
        cls.entity = EntityFactory()
        cls.academic_responsible = PersonFactory()
        cls.administrative_responsible = PersonFactory()
        cls.contact_in_person = PersonFactory()
        cls.contact_out_person = PersonFactory()

        cls.data = {
            'academic_responsible': str(cls.academic_responsible.pk),
            'administrative_responsible':
            str(cls.administrative_responsible.pk),
            'contact_in_email': '*****@*****.**',
            'contact_in_person': str(cls.contact_in_person.pk),
            'contact_in_url': 'http://foo.fr/foo',
            'contact_out_email': '*****@*****.**',
            'contact_out_person': str(cls.contact_out_person.pk),
            'contact_out_url': 'http://bar.fr/bar',
            'entity': str(cls.entity.pk),
        }
    def setUpTestData(cls):

        class EducationGroupYearFactory(BaseEducationGroupYearFactory):
            management_entity = None
            administration_entity = None
            enrollment_campus = None

        cls.url = reverse('partnership_api_v1:configuration')

        AcademicYearFactory.produce_in_future(quantity=2)
        current_academic_year = PartnershipConfiguration.get_configuration().get_current_academic_year_for_api()

        # Partnerships
        cls.supervisor_partnership = PersonFactory()
        cls.supervisor_management_entity = PersonFactory()

        partnership = PartnershipFactory(
            supervisor=cls.supervisor_partnership,
            years=[]
        )
        year = PartnershipYearFactory(
            partnership=partnership,
            academic_year=current_academic_year,
        )
        year.offers.add(EducationGroupYearFactory())
        education_field = DomainIscedFactory(title_en='foo', title_fr='bar')
        year.education_fields.add(education_field)
        PartnershipAgreementFactory(
            partnership=partnership,
            start_academic_year=current_academic_year,
            end_academic_year__year=current_academic_year.year + 1,
        )

        root = EntityWithVersionFactory()
        parent = EntityVersionFactory(acronym="SSH", entity_type=SECTOR, parent=root)
        partnership = PartnershipFactory(
            partner__contact_address=True,
            years__academic_year=current_academic_year,
            ucl_entity=EntityVersionFactory(
                acronym="FIAL", entity_type=FACULTY, parent=parent.entity,
            ).entity,
        )
        PartnershipAgreementFactory(
            partnership=partnership,
            start_academic_year=current_academic_year,
            end_academic_year__year=current_academic_year.year + 1,
        )
        UCLManagementEntityFactory(
            entity=partnership.ucl_entity,
            academic_responsible=cls.supervisor_management_entity
        )
        FundingSource.objects.all().delete()
        FundingTypeFactory()

        # Some noises
        cls.noisy_partner = PartnerFactory()
        cls.noisy_partnership = PartnershipFactory()

        # Continents
        continent = Continent.objects.create(code='AA', name='aaaaa')
        CountryFactory(continent=continent)
        CountryFactory(continent=continent)
        CountryFactory()
Ejemplo n.º 11
0
    def setUpTestData(cls):
        cls.url = reverse('partnership_api_v1:partnerships')

        AcademicYearFactory.produce_in_future(quantity=3)
        config = PartnershipConfiguration.get_configuration()
        current_academic_year = config.get_current_academic_year_for_api()
        cls.current_academic_year = current_academic_year

        # Continents
        cls.continent = Continent.objects.create(code='AA', name='aaaaa')
        cls.country = CountryFactory(
            name="Albania",
            iso_code='AL',
            continent=cls.continent,
        )
        CountryFactory(continent=cls.continent)
        CountryFactory()

        # Partnerships
        root = EntityVersionFactory(parent=None, acronym="UCL").entity
        sector = EntityVersionFactory(parent=root, acronym="SSH").entity
        entity = EntityVersionFactory(parent=sector, acronym="FIAL").entity
        cls.supervisor_partnership = PersonFactory()
        cls.supervisor_management_entity = PersonFactory()
        cls.funding_type = FundingTypeFactory()
        cls.funding_program = cls.funding_type.program
        cls.funding_source = cls.funding_program.source
        cls.subtype = PartnershipSubtypeFactory()

        cls.partnership = PartnershipFactory(
            ucl_entity=entity,
            supervisor=cls.supervisor_partnership,
            years=[],
            partner__contact_address__country=cls.country,
            partner__contact_address__city="Tirana",
            subtype=cls.subtype,
        )
        cls.partner = cls.partnership.partner_entities.first(
        ).organization.partner
        year = PartnershipYearFactory(
            partnership=cls.partnership,
            academic_year=current_academic_year,
            is_smp=True,
            eligible=False,
            funding_source=cls.funding_source,
            funding_program=cls.funding_program,
            funding_type=cls.funding_type,
        )
        cls.education_field = DomainIscedFactory()
        year.education_fields.add(cls.education_field)
        PartnershipAgreementFactory(
            partnership=cls.partnership,
            start_academic_year=current_academic_year,
            end_academic_year__year=current_academic_year.year + 1,
            status=AgreementStatus.VALIDATED.name,
            media__is_visible_in_portal=False,
        )
        cls.management_entity = UCLManagementEntityFactory(
            entity=cls.partnership.ucl_entity, )

        partnership_without_funding = PartnershipFactory(
            ucl_entity=EntityVersionFactory(parent=sector,
                                            acronym="DRT").entity,
            years=[],
        )
        PartnershipYearFactory(
            partnership=partnership_without_funding,
            academic_year=current_academic_year,
        )
        PartnershipAgreementFactory(
            partnership=partnership_without_funding,
            start_academic_year=current_academic_year,
            end_academic_year__year=current_academic_year.year + 1,
            status=AgreementStatus.VALIDATED.name,
        )
        UCLManagementEntityFactory(
            entity=partnership_without_funding.ucl_entity,
            contact_in_person=None,
            contact_out_person=None,
        )

        cls.partnership_2 = PartnershipFactory(
            supervisor=None,
            years__academic_year=current_academic_year,
            partner__contact_address__country__name="Zambia",
            partner__contact_address__country__iso_code="ZM",
            partner__contact_address__city="Lusaka",
            partner__contact_address__location=Point(-15.4166, 28.2822),
        )
        cls.partner_2 = cls.partnership_2.partner_entities.first(
        ).organization.partner
        PartnershipAgreementFactory(
            partnership=cls.partnership_2,
            start_academic_year=current_academic_year,
            end_academic_year__year=current_academic_year.year + 1,
            status=AgreementStatus.VALIDATED.name,
        )
        cls.management_entity = UCLManagementEntityFactory(
            entity=cls.partnership_2.ucl_entity,
            academic_responsible=cls.supervisor_management_entity,
            contact_out_person=None,
            contact_in_person=None,
        )
        cls.financing = FinancingFactory(academic_year=current_academic_year)
        cls.financing.countries.add(cls.partner_2.contact_address.country)

        # Other types
        cls.partnership_project = PartnershipFactory(
            partnership_type=PartnershipType.PROJECT.name,
            start_date=date(current_academic_year.year, 1, 1),
            end_date=date(current_academic_year.year, 10, 1),
            partner__contact_address__country__iso_code="ZM",
            partner__contact_address__city="Ndola",
        )
        PartnershipYearFactory(
            partnership=cls.partnership_project,
            academic_year=current_academic_year,
            funding_source=FundingSourceFactory(),
        )

        # Multilateral
        cls.partnership_course = PartnershipFactory(
            partnership_type=PartnershipType.COURSE.name,
            start_date=date(current_academic_year.year, 1, 1),
            end_date=date(current_academic_year.year + 1, 10, 1),
        )
        entity = EntityWithVersionFactory(organization__type=ACADEMIC_PARTNER)
        cls.partnership_course.partner_entities.add(entity)
        PartnerFactory(organization=entity.organization)

        cls.partnership_general = PartnershipFactory(
            partnership_type=PartnershipType.GENERAL.name,
            start_date=date(current_academic_year.year - 1, 1, 1),
            end_date=date(current_academic_year.year + 3, 10, 1),
            partner__contact_address__country__iso_code="ZM",
            partner__contact_address__city="Kabwe",
            partner__contact_address__location=Point(-14.4415250, 28.4441831),
            years=[
                PartnershipYearFactory(academic_year=current_academic_year)
            ],
        )
        PartnershipAgreementFactory(
            partnership=cls.partnership_general,
            start_date=date(current_academic_year.year - 10, 10, 1),
            end_date=date(current_academic_year.year + 7, 10, 1),
            status=AgreementStatus.VALIDATED.name,
        )

        # Some noises - Agreement not validated or not in status validated
        PartnerFactory()
        cls.partnership_without_agreement = PartnershipFactory()
        cls.partnership_not_public = PartnershipFactory(is_public=False)

        cls.partnership_with_agreement_not_validated = PartnershipFactory(
            supervisor=None,
            years__academic_year=current_academic_year,
        )
        PartnershipAgreementFactory(
            partnership=cls.partnership_with_agreement_not_validated,
            start_academic_year=current_academic_year,
            end_academic_year__year=current_academic_year.year + 1,
            status=AgreementStatus.WAITING.name,
        )
Ejemplo n.º 12
0
    def setUpTestData(cls):
        class EntityVersionFactory(BaseEntityVersionFactory):
            entity__organization__type = MAIN
            entity__country = None

        cls.user = PartnershipEntityManagerFactory().person.user
        cls.user_adri = UserFactory()
        cls.user_gs = UserFactory()
        cls.user_gf = UserFactory()
        cls.user_other_gf = UserFactory()
        cls.other_gs = UserFactory()

        cls.url = reverse('partnerships:autocomplete:ucl_entity')

        # Ucl
        root = EntityVersionFactory(parent=None).entity
        cls.sector = EntityVersionFactory(
            entity_type=SECTOR,
            acronym='A',
            parent=root,
        ).entity
        cls.ucl_university = EntityVersionFactory(
            parent=cls.sector,
            entity_type=FACULTY,
            acronym='AA',
        ).entity
        UCLManagementEntityFactory(entity=cls.ucl_university)
        cls.ucl_university_labo = EntityVersionFactory(
            parent=cls.ucl_university,
            entity_type=SCHOOL,
            acronym='AA1',
        ).entity
        UCLManagementEntityFactory(entity=cls.ucl_university_labo)

        cls.ucl_university_2 = EntityVersionFactory(
            parent=cls.sector,
            entity_type=FACULTY,
            acronym='AB',
        ).entity
        UCLManagementEntityFactory(entity=cls.ucl_university_2)
        cls.ucl_university_labo_2 = EntityVersionFactory(
            parent=cls.ucl_university_2,
            entity_type=SCHOOL,
            acronym='AB1',
        ).entity
        UCLManagementEntityFactory(entity=cls.ucl_university_labo_2)

        sector_b = EntityVersionFactory(
            entity_type=SECTOR,
            acronym='B',
            parent=root,
        ).entity
        cls.ucl_university_3 = EntityVersionFactory(
            parent=sector_b,
            entity_type=FACULTY,
            acronym='BA',
        ).entity
        UCLManagementEntityFactory(entity=cls.ucl_university_3)
        cls.ucl_university_labo_3 = EntityVersionFactory(
            parent=cls.ucl_university_3,
            entity_type=SCHOOL,
            acronym='BA1',
        ).entity
        UCLManagementEntityFactory(entity=cls.ucl_university_labo_3)

        cls.data = {'forward': json.dumps({'partnership_type': 'MOBILITY'})}

        PartnershipEntityManagerFactory(person__user=cls.user_gs,
                                        entity=cls.sector)
        PartnershipEntityManagerFactory(person__user=cls.user_gf,
                                        entity=cls.ucl_university)
        PartnershipEntityManagerFactory(person__user=cls.user_other_gf,
                                        entity=cls.ucl_university_2)
        PartnershipEntityManagerFactory(person__user=cls.other_gs,
                                        entity=sector_b)
        PartnershipEntityManagerFactory(
            entity=EntityVersionFactory(parent=root, acronym='ADRI').entity,
            person__user=cls.user_adri,
        )
    def setUpTestData(cls):
        cls.user = UserFactory()
        cls.user_adri = UserFactory()
        cls.user_gs = UserFactory()
        cls.user_gf = UserFactory()
        cls.user_other_gf = UserFactory()
        cls.user_2_types = UserFactory()

        root = EntityVersionFactory(parent=None).entity
        entity_version = EntityVersionFactory(acronym='ADRI', parent=root)
        PartnershipEntityManagerFactory(
            entity=entity_version.entity,
            person__user=cls.user_adri,
        )
        PartnershipEntityManagerFactory(entity=entity_version.entity,
                                        person__user=cls.user_2_types,
                                        scopes=[
                                            PartnershipType.MOBILITY.name,
                                            PartnershipType.GENERAL.name
                                        ])

        cls.partner = PartnerFactory()
        cls.partner_entity = PartnerEntityFactory(partner=cls.partner)
        cls.partner_entity_2 = PartnerEntityFactory(partner=cls.partner)

        cls.start_academic_year = AcademicYearFactory(year=2150)
        cls.end_academic_year = AcademicYearFactory(year=2151)
        AcademicYearFactory.produce_in_future(quantity=3)

        cls.education_field = DomainIscedFactory()
        cls.education_level = PartnershipYearEducationLevelFactory()

        cls.url = reverse('partnerships:create')
        cls.mobility_url = reverse(
            'partnerships:create',
            kwargs={'type': PartnershipType.MOBILITY},
        )

        # Ucl
        sector = EntityVersionFactory(
            parent=root,
            entity_type=SECTOR,
        ).entity
        cls.ucl_university = EntityVersionFactory(
            parent=sector,
            entity_type=FACULTY,
        ).entity
        cls.ucl_university_labo = EntityVersionFactory(
            parent=cls.ucl_university, ).entity
        UCLManagementEntityFactory(entity=cls.ucl_university)
        UCLManagementEntityFactory()

        cls.ucl_university_not_choice = EntityVersionFactory(
            entity_type=FACULTY, ).entity
        cls.ucl_university_labo_not_choice = EntityVersionFactory(
            parent=cls.ucl_university_not_choice, ).entity
        cls.university_offer = EducationGroupYearFactory(
            administration_entity=cls.ucl_university_labo)

        PartnershipEntityManagerFactory(person__user=cls.user_gs,
                                        entity=sector)
        PartnershipEntityManagerFactory(person__user=cls.user_gf,
                                        entity=cls.ucl_university)
        PartnershipEntityManagerFactory(person__user=cls.user_other_gf,
                                        entity=cls.ucl_university)
        PartnershipEntityManagerFactory(person__user=cls.user_2_types,
                                        entity=cls.ucl_university)

        cls.data = {
            'partnership_type': PartnershipType.MOBILITY.name,
            'comment': '',
            'partner': cls.partner.pk,
            'partner_entities': [cls.partner_entity.entity_id],
            'supervisor': '',
            'ucl_entity': cls.ucl_university.pk,
            'university_offers': [cls.university_offer.pk],
            'year-is_sms': True,
            'year-is_smp': False,
            'year-is_sta': True,
            'year-is_stt': False,
            'year-education_fields': [cls.education_field.pk],
            'year-education_levels': [cls.education_level.pk],
            'year-entities': [],
            'year-offers': [],
            'year-start_academic_year': cls.start_academic_year.pk,
            'year-end_academic_year': cls.end_academic_year.pk,
            'missions': [PartnershipMissionFactory().pk],
        }
Ejemplo n.º 14
0
    def setUpTestData(cls):
        cls.user = UserFactory()
        cls.user_adri = UserFactory()
        entity_version = EntityVersionFactory(acronym='ADRI')
        PartnershipEntityManagerFactory(entity=entity_version.entity, person__user=cls.user_adri)
        cls.user_gs = UserFactory()
        cls.user_gf = UserFactory()
        cls.user_other_gf = UserFactory()
        cls.user_project = UserFactory()
        PartnershipEntityManagerFactory(
            entity=entity_version.entity,
            person__user=cls.user_project,
            scopes=[PartnershipType.PROJECT.name]
        )

        # Dates :
        cls.partner = PartnerFactory()
        cls.partner_entity = PartnerEntityFactory(partner=cls.partner)

        # Years
        cls.academic_year_2149 = AcademicYearFactory(year=2149)
        cls.start_academic_year = AcademicYearFactory(year=2150)
        cls.from_academic_year = AcademicYearFactory(year=2151)
        cls.end_academic_year = AcademicYearFactory(year=2152)
        cls.academic_year_2153 = AcademicYearFactory(year=2153)

        # Initialize config
        PartnershipConfiguration.objects.update(
            partnership_creation_update_min_year_id=cls.academic_year_2149.pk
        )

        cls.education_field = DomainIscedFactory()
        cls.education_level = PartnershipYearEducationLevelFactory()

        # Ucl
        root = EntityVersionFactory(parent=None).entity
        sector = EntityVersionFactory(
            entity_type=SECTOR,
            parent=root,
        ).entity
        cls.ucl_university = EntityVersionFactory(
            parent=sector,
            entity_type=FACULTY,
        ).entity
        UCLManagementEntityFactory(entity=cls.ucl_university)
        cls.ucl_university_labo = EntityVersionFactory(
            parent=cls.ucl_university,
        ).entity
        UCLManagementEntityFactory(entity=cls.ucl_university_labo)
        cls.ucl_university_not_choice = EntityVersionFactory(
            entity_type=FACULTY,
        ).entity
        cls.ucl_university_labo_not_choice = EntityVersionFactory(
            parent=cls.ucl_university_not_choice,
        ).entity
        cls.university_offer = EducationGroupYearFactory(administration_entity=cls.ucl_university_labo)

        PartnershipEntityManagerFactory(person__user=cls.user_gs, entity=sector)
        PartnershipEntityManagerFactory(person__user=cls.user_gf, entity=cls.ucl_university)
        PartnershipEntityManagerFactory(person__user=cls.user_other_gf, entity=cls.ucl_university)

        mission = PartnershipMission.objects.filter(
            types__contains=[PartnershipType.MOBILITY.name],
        ).first()
        cls.partner_gf = PartnerFactory(author=cls.user_gf.person)
        cls.partnership = PartnershipFactory(
            partner=cls.partner,
            partner_entity=cls.partner_entity.entity,
            author=cls.user_gf.person,
            years=[],
            ucl_entity=cls.ucl_university,
            missions=[mission],
        )
        PartnershipYearFactory(
            partnership=cls.partnership,
            academic_year=cls.start_academic_year,
        )
        PartnershipYearFactory(
            partnership=cls.partnership,
            academic_year=cls.from_academic_year,
        )
        PartnershipYearFactory(
            partnership=cls.partnership,
            academic_year=cls.end_academic_year,
        )
        cls.url = resolve_url('partnerships:update', pk=cls.partnership.pk)

        cls.other_partnership = PartnershipFactory(
            partnership_type=PartnershipType.PROJECT.name,
        )
        cls.other_url = resolve_url('partnerships:update', pk=cls.other_partnership.pk)

        cls.data = {
            'partnership_type': PartnershipType.MOBILITY.name,
            'comment': '',
            'partner': cls.partner.pk,
            'partner_entities': [cls.partner_entity.entity_id],
            'supervisor': '',
            'ucl_entity': cls.ucl_university_labo.pk,
            'year-is_sms': True,
            'year-is_smp': False,
            'year-is_smst': True,
            'year-is_sta': True,
            'year-is_stt': False,
            'year-education_fields': [cls.education_field.pk],
            'year-education_levels': [cls.education_level.pk],
            'year-entities': [],
            'year-offers': [],
            'year-start_academic_year': cls.start_academic_year.pk,
            'year-from_academic_year': cls.from_academic_year.pk,
            'year-end_academic_year': cls.end_academic_year.pk,
        }