예제 #1
0
def _create_2_entity_version(an_entity, old_acronym, newest_acronym):
    EntityVersionFactory(entity=an_entity, acronym=old_acronym,
                         start_date=datetime.date(2015, 1, 1).isoformat(),
                         end_date=datetime.date(2016, 1, 1).isoformat())
    EntityVersionFactory(entity=an_entity, acronym=newest_acronym,
                         start_date=datetime.date(2017, 1, 1).isoformat(),
                         end_date=datetime.date(2018, 1, 1).isoformat())
    def setUp(self):

        self.maxDiff = None
        self.assistant_mandate = AssistantMandateFactory()
        self.entity1 = EntityFactory()
        self.entity_version1 = EntityVersionFactory(
            entity=self.entity1, entity_type=entity_type.SECTOR)
        self.entity2 = EntityFactory()
        self.entity_version2 = EntityVersionFactory(
            entity=self.entity2, entity_type=entity_type.FACULTY)
        self.entity3 = EntityFactory()
        self.entity_version3 = EntityVersionFactory(
            entity=self.entity3, entity_type=entity_type.INSTITUTE)
        self.entity4 = EntityFactory()
        self.entity_version4 = EntityVersionFactory(
            entity=self.entity4,
            parent=self.entity3,
            entity_type=entity_type.SCHOOL)

        self.mandate_entity1 = MandateEntityFactory(
            assistant_mandate=self.assistant_mandate, entity=self.entity1)
        self.mandate_entity2 = MandateEntityFactory(
            assistant_mandate=self.assistant_mandate, entity=self.entity2)
        self.mandate_entity3 = MandateEntityFactory(
            assistant_mandate=self.assistant_mandate, entity=self.entity3)
예제 #3
0
    def test_find_latest_requirment_entity(self):
        work_on_year = 2016

        # Change version in order to have multiple version during the year
        self.entity_versions[work_on_year].end_date = datetime.datetime(
            work_on_year, 3, 30)
        self.entity_versions[work_on_year].save()
        lastest_entity_version = EntityVersionFactory(
            entity=self.entity,
            parent=None,
            acronym="Entity V_{}_3".format(work_on_year),
            start_date=datetime.datetime(work_on_year, 8, 1),
            end_date=None)
        EntityVersionFactory(entity=self.entity,
                             parent=None,
                             acronym="Entity V_{}_2".format(work_on_year),
                             start_date=datetime.datetime(work_on_year, 4, 1),
                             end_date=datetime.datetime(work_on_year, 7, 30))

        l_container_year = LearningContainerYearFactory(
            academic_year=self.academic_years[work_on_year])
        # Create a link between entity and container
        # Requirement entity
        EntityContainerYearFactory(
            entity=self.entity,
            learning_container_year=l_container_year,
            type=entity_container_year_link_type.REQUIREMENT_ENTITY)

        # Find requirement entity
        requirement_entity_found = entity_container_year.find_requirement_entity(
            learning_container_year=l_container_year)
        self.assertEqual(lastest_entity_version, requirement_entity_found)
예제 #4
0
    def setUpTestData(cls):
        cls.person2 = PersonFactory()
        cls.manager = ManagerFactory()
        cls.person = cls.manager.person
        cls.entity_factory = EntityFactory()
        cls.entity_factory2 = EntityFactory()
        cls.entity_version = EntityVersionFactory(entity_type=entity_type.INSTITUTE,
                                                  end_date=None,
                                                  entity=cls.entity_factory)
        cls.entity_version2 = EntityVersionFactory(entity_type=entity_type.INSTITUTE,
                                                   end_date=None,
                                                   entity=cls.entity_factory2)
        cls.phd_supervisor = PersonFactory()

        cls.assistant = AcademicAssistantFactory(supervisor=cls.phd_supervisor)
        today = datetime.date.today()
        cls.current_academic_year = AcademicYearFactory(start_date=today,
                                                        end_date=today.replace(year=today.year + 1),
                                                        year=today.year)
        cls.assistant_mandate = AssistantMandateFactory(academic_year=cls.current_academic_year,
                                                        assistant=cls.assistant)
        cls.reviewer = ReviewerFactory(role=reviewer_role.RESEARCH_ASSISTANT,
                                       entity=cls.entity_version.entity)
        cls.reviewer2 = ReviewerFactory(role=reviewer_role.RESEARCH,
                                        entity=cls.entity_version.entity)
        cls.reviewer3 = ReviewerFactory(role=reviewer_role.RESEARCH,
                                        entity=cls.entity_version.entity)
        cls.review = ReviewFactory(reviewer=cls.reviewer2)
        cls.formset = formset_factory(ReviewersFormset)
        cls.current_academic_year = AcademicYearFactory(start_date=today,
                                                        end_date=today.replace(year=today.year + 1),
                                                        year=today.year)
예제 #5
0
    def setUp(self):

        organization = OrganizationFactory(type=organization_type.MAIN)
        self.entities = [
            EntityFactory(organization=organization) for x in range(2)
        ]

        self.entity_c_older_version = EntityVersionFactory(
            entity=self.entities[0],
            acronym="C ENTITY_V_" + str(0),
            entity_type=entity_type.FACULTY,
            start_date=datetime.date(now.year - 1, 1, 1),
            end_date=datetime.date(now.year - 1, 12, 31))
        self.entity_c_current_version = EntityVersionFactory(
            entity=self.entities[0],
            acronym="B ENTITY_V_" + str(0),
            entity_type=entity_type.FACULTY,
            start_date=datetime.date(now.year, 1, 1),
            end_date=None)
        self.entity_a_version = EntityVersionFactory(
            entity=self.entities[1],
            acronym="A ENTITY_V_" + str(1),
            entity_type=entity_type.FACULTY,
            start_date=datetime.date(now.year, 1, 1),
            end_date=None)
예제 #6
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
    def test_find_parent_faculty_version_no_faculty_parent(self):

        start_date = datetime.datetime(now.year - 1, now.month, 16)
        end_date = datetime.datetime(now.year, now.month, 27)

        ac_yr = AcademicYearFactory(
            year=(now.year - 1),
            start_date=datetime.datetime(now.year - 1, now.month, 15),
            end_date=datetime.datetime(now.year, now.month, 28))

        entity_parent = EntityFactory(country=self.country)
        EntityVersionFactory(entity=entity_parent,
                             acronym="ENTITY_NOT_FACULTY",
                             title="This is not an entity faculty ",
                             entity_type="SCHOOL",
                             parent=None,
                             start_date=start_date,
                             end_date=end_date)
        entity_school_child_level1 = EntityFactory(country=self.country)
        entity_school_version_level1 = EntityVersionFactory(
            entity=entity_school_child_level1,
            acronym="ENTITY_LEVEL1",
            title="This is the entity version level1 ",
            entity_type="SCHOOL",
            parent=entity_parent,
            start_date=start_date,
            end_date=end_date)
        self.assertIsNone(
            entity_version.find_parent_faculty_version(
                entity_school_version_level1, ac_yr))
예제 #8
0
    def test_get_entity_calendar_with_parent_entity_calendar(self):
        an_entity_parent = EntityFactory()
        EntityVersionFactory(entity=an_entity_parent,
                             start_date=self.current_academic_year.start_date,
                             end_date=self.current_academic_year.end_date)
        an_entity_child = EntityFactory()
        an_child_entity_version = EntityVersionFactory(
            entity=an_entity_child,
            start_date=self.current_academic_year.start_date,
            end_date=self.current_academic_year.end_date,
            parent=an_entity_parent)

        an_academic_calendar = AcademicCalendarFactory(
            academic_year=self.current_academic_year,
            start_date=self.current_academic_year.start_date,
            end_date=self.current_academic_year.end_date,
            reference=academic_calendar_type.SUMMARY_COURSE_SUBMISSION)
        an_parent_entity_calendar = EntityCalendarFactory(
            entity=an_entity_parent,
            academic_calendar=an_academic_calendar,
            start_date=an_academic_calendar.start_date,
            end_date=an_academic_calendar.end_date)
        self.assertEqual(
            get_entity_calendar(an_child_entity_version,
                                self.current_academic_year),
            an_parent_entity_calendar)
예제 #9
0
    def setUpTestData(cls):
        cls.country = CountryFactory()
        cls.organization = OrganizationFactory(type=organization_type.MAIN)
        cls.entities = [
            EntityFactory(country=cls.country, organization=cls.organization)
            for x in range(3)
        ]
        cls.parent = EntityFactory(country=cls.country,
                                   organization=cls.organization)
        cls.start_date = datetime.date(2015, 1, 1)
        cls.end_date = datetime.date(2015, 12, 31)
        cls.date_in_2015 = factory.fuzzy.FuzzyDate(datetime.date(2015, 1, 1),
                                                   datetime.date(2015, 12,
                                                                 30)).fuzz()
        cls.date_in_2017 = factory.fuzzy.FuzzyDate(datetime.date(2017, 1, 1),
                                                   datetime.date(2017, 12,
                                                                 30)).fuzz()

        cls.entity_versions = [
            EntityVersionFactory(entity=cls.entities[x],
                                 acronym="ENTITY_V_" + str(x),
                                 title="This is the entity version " + str(x),
                                 entity_type="FACULTY",
                                 parent=cls.parent,
                                 start_date=cls.start_date,
                                 end_date=cls.end_date) for x in range(3)
        ]
        cls.parent_entity_version = EntityVersionFactory(
            entity=cls.parent,
            acronym="ENTITY_PARENT",
            title="This is the entity parent version",
            entity_type="SECTOR",
            start_date=cls.start_date,
            end_date=cls.end_date)
예제 #10
0
 def test_find_descendants_with_multiple_parent(self):
     parent_2 = EntityFactory(country=self.country)
     EntityVersionFactory(entity=parent_2,
                          parent=None,
                          acronym="ROOT_ENTITY_2",
                          start_date=self.start_date,
                          end_date=self.end_date)
     ### Create one child entity with parent ROOT_ENTITY_2
     child = EntityFactory(country=self.country)
     EntityVersionFactory(entity=child,
                          parent=parent_2,
                          acronym="CHILD_OF_ROOT_2",
                          start_date=self.start_date,
                          end_date=self.end_date)
     ### Create one child entity with parent CHILD_OF_ROOT_2
     child_2 = EntityFactory(country=self.country)
     EntityVersionFactory(entity=child_2,
                          parent=child,
                          acronym="CHILD_OF_CHILD",
                          start_date=self.start_date,
                          end_date=self.end_date)
     entities_with_descendants = EntityVersion.objects.get_tree(
         [self.parent, parent_2], date=self.date_in_2015)
     self.assertEqual(len(entities_with_descendants),
                      8)  # 5 for parent + 3 for parent_2
예제 #11
0
    def setUpTestData(cls):
        cls.start_date = timezone.make_aware(datetime.datetime(2015, 1, 1))
        cls.end_date = timezone.make_aware(datetime.datetime(2015, 12, 31))
        cls.date_in_2015 = factory.fuzzy.FuzzyDate(
            timezone.make_aware(datetime.datetime(2015, 1, 1)),
            timezone.make_aware(datetime.datetime(2015, 12, 30))).fuzz()
        cls.date_in_2017 = factory.fuzzy.FuzzyDate(
            timezone.make_aware(datetime.datetime(2017, 1, 1)),
            timezone.make_aware(datetime.datetime(2017, 12, 30))).fuzz()
        cls.country = CountryFactory()
        cls.parent = EntityFactory(country=cls.country)
        EntityVersionFactory(entity=cls.parent,
                             parent=None,
                             acronym="ROOT_ENTITY",
                             start_date=cls.start_date,
                             end_date=cls.end_date)
        cls.children = [EntityFactory(country=cls.country) for x in range(4)]
        cls.types_dict = dict(entity_type.ENTITY_TYPES)
        types = [
            cls.types_dict['SECTOR'], cls.types_dict['FACULTY'],
            cls.types_dict['SCHOOL'], cls.types_dict['FACULTY']
        ]

        for x in range(4):
            EntityVersionFactory(entity=cls.children[x],
                                 parent=cls.parent,
                                 acronym="ENTITY_V_" + str(x),
                                 start_date=cls.start_date,
                                 end_date=cls.end_date,
                                 entity_type=types[x])
        cls.an_entity = EntityFactory(external_id="1234567")
    def setUpTestData(cls):
        cls.settings = SettingsFactory()
        today = datetime.date.today()
        cls.current_academic_year = AcademicYearFactory(start_date=today,
                                                        end_date=today.replace(year=today.year + 1),
                                                        year=today.year)
        cls.current_academic_year.save()
        cls.phd_supervisor = PersonFactory()
        cls.assistant = AcademicAssistantFactory(supervisor=cls.phd_supervisor)

        cls.assistant_mandate2 = AssistantMandateFactory(
            academic_year=cls.current_academic_year,
            assistant=cls.assistant,
            state=assistant_mandate_state.RESEARCH
        )
        cls.entity_version = EntityVersionFactory(entity_type=entity_type.INSTITUTE)
        cls.entity_version2 = EntityVersionFactory(entity_type=entity_type.FACULTY)
        cls.entity_version3 = EntityVersionFactory(entity_type=entity_type.SECTOR)
        cls.reviewer = ReviewerFactory(
            role=reviewer_role.RESEARCH,
            entity=cls.entity_version.entity
        )
        cls.reviewer2 = ReviewerFactory(
            role=reviewer_role.SUPERVISION,
            entity=cls.entity_version2.entity
        )
        cls.reviewer3 = ReviewerFactory(
            role=reviewer_role.VICE_RECTOR,
            entity=cls.entity_version3.entity
        )
        MandateEntityFactory(
            assistant_mandate=cls.assistant_mandate2,
            entity=cls.entity_version.entity
        )
예제 #13
0
 def setUpTestData(cls):
     cls.entity1 = EntityFactory()
     cls.entity_version1 = EntityVersionFactory(
         entity=cls.entity1, entity_type=entity_type.SECTOR)
     cls.entity2 = EntityFactory()
     cls.entity_version2 = EntityVersionFactory(
         entity=cls.entity2, entity_type=entity_type.FACULTY)
     cls.entity3 = EntityFactory()
     cls.entity_version3 = EntityVersionFactory(
         entity=cls.entity3, entity_type=entity_type.FACULTY)
     cls.entity4 = EntityFactory()
     cls.entity_version4 = EntityVersionFactory(
         entity=cls.entity4,
         parent=cls.entity3,
         entity_type=entity_type.SCHOOL)
     cls.reviewer1 = ReviewerFactory(role=reviewer_role.VICE_RECTOR,
                                     entity=cls.entity1)
     cls.reviewer2 = ReviewerFactory(role=reviewer_role.SUPERVISION,
                                     entity=cls.entity2)
     cls.reviewer3 = ReviewerFactory(role=reviewer_role.SUPERVISION,
                                     entity=cls.entity3)
     cls.reviewer4 = ReviewerFactory(role=reviewer_role.SUPERVISION_DAF,
                                     entity=cls.entity3)
     cls.reviewer5 = ReviewerFactory(
         role=reviewer_role.SUPERVISION_DAF_ASSISTANT, entity=cls.entity4)
     cls.reviewer6 = ReviewerFactory(
         role=reviewer_role.VICE_RECTOR_ASSISTANT, entity=cls.entity1)
예제 #14
0
    def setUp(self, **kwargs):
        self.education_group_type = kwargs.pop('education_group_type')

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

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

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

        # Create user and attached it to management entity
        person = PersonFactory()
        PersonEntityFactory(
            person=person,
            entity=self.parent_education_group_year.management_entity)
        self.user = person.user
    def setUpTestData(cls):
        cls.settings = SettingsFactory()

        cls.current_academic_year = AcademicYearFactory(current=True)
        cls.assistant_mandate = AssistantMandateFactory(
            academic_year=cls.current_academic_year,
            state=assistant_mandate_state.PHD_SUPERVISOR)
        cls.review = ReviewFactory(reviewer=None,
                                   mandate=cls.assistant_mandate,
                                   status=review_status.IN_PROGRESS)

        cls.institute = EntityVersionFactory(entity_type=entity_type.INSTITUTE,
                                             end_date=None)
        cls.institute_child = EntityVersionFactory(parent=cls.institute.entity,
                                                   end_date=None)
        cls.school = EntityVersionFactory(entity_type=entity_type.SCHOOL,
                                          end_date=None)
        cls.sector = EntityVersionFactory(entity_type=entity_type.SECTOR)
        cls.faculty = EntityVersionFactory(entity_type=entity_type.FACULTY)

        cls.mandate_entity = MandateEntityFactory(
            assistant_mandate=cls.assistant_mandate,
            entity=cls.institute.entity)
        cls.research_reviewer = ReviewerFactory(role=reviewer_role.RESEARCH,
                                                entity=cls.institute.entity)
        cls.research_assistant_reviewer = ReviewerFactory(
            role=reviewer_role.RESEARCH_ASSISTANT,
            entity=cls.institute_child.entity)
        cls.vice_sector_reviewer = ReviewerFactory(
            role=reviewer_role.VICE_RECTOR, entity=cls.school.entity)
        cls.supervision_reviewer = ReviewerFactory(
            role=reviewer_role.SUPERVISION, entity=cls.faculty.entity)

        cls.delegate = PersonFactory()
        cls.delegate2 = PersonFactory()
예제 #16
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)
예제 #17
0
    def setUp(self):
        self.country = CountryFactory()
        self.organization = OrganizationFactory(
            name="Université catholique de Louvain",
            acronym="UCL",
            type=organization_type.MAIN)
        self.entities = [
            EntityFactory(country=self.country, organization=self.organization)
            for x in range(3)
        ]
        self.parent = EntityFactory(country=self.country,
                                    organization=self.organization)
        self.start_date = datetime.date(2015, 1, 1)
        self.end_date = datetime.date(2015, 12, 31)
        self.date_in_2015 = factory.fuzzy.FuzzyDate(
            datetime.date(2015, 1, 1), datetime.date(2015, 12, 30)).fuzz()
        self.date_in_2017 = factory.fuzzy.FuzzyDate(
            datetime.date(2017, 1, 1), datetime.date(2017, 12, 30)).fuzz()

        self.entity_versions = [
            EntityVersionFactory(entity=self.entities[x],
                                 acronym="ENTITY_V_" + str(x),
                                 title="This is the entity version " + str(x),
                                 entity_type="FACULTY",
                                 parent=self.parent,
                                 start_date=self.start_date,
                                 end_date=self.end_date) for x in range(3)
        ]
        self.parent_entity_version = EntityVersionFactory(
            entity=self.parent,
            acronym="ENTITY_PARENT",
            title="This is the entity parent version",
            entity_type="SECTOR",
            start_date=self.start_date,
            end_date=self.end_date)
예제 #18
0
    def setUp(self):

        self.education_group_year = TrainingFactory(
            academic_year=create_current_academic_year())
        self.education_group_type = EducationGroupTypeFactory(
            category=education_group_categories.TRAINING)

        EntityVersionFactory(
            entity=self.education_group_year.administration_entity)
        EntityVersionFactory(
            entity=self.education_group_year.management_entity)
        self.list_acs = GenerateAcademicYear(get_current_year(),
                                             get_current_year() +
                                             40).academic_years

        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': MainEntityVersionFactory().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": "",
        }
    def test_find_parent_faculty_version(self):
        ac_yr = AcademicYearFactory()
        start_date = ac_yr.start_date
        end_date = ac_yr.end_date
        entity_faculty = EntityFactory(country=self.country)
        entity_faculty_version = EntityVersionFactory(
            entity=entity_faculty,
            acronym="ENTITY_FACULTY",
            title="This is the entity faculty ",
            entity_type="FACULTY",
            parent=None,
            start_date=start_date,
            end_date=end_date)
        entity_school_child_level1 = EntityFactory(country=self.country)
        EntityVersionFactory(entity=entity_school_child_level1,
                             acronym="ENTITY_LEVEL1",
                             title="This is the entity version level1 ",
                             entity_type="SCHOOL",
                             parent=entity_faculty,
                             start_date=start_date,
                             end_date=end_date)
        entity_school_child_level2 = EntityFactory(country=self.country)
        entity_school_version_level2 = EntityVersionFactory(
            entity=entity_school_child_level2,
            acronym="ENTITY_LEVEL2",
            title="This is the entity version level 2",
            entity_type="SCHOOL",
            parent=entity_school_child_level1,
            start_date=start_date,
            end_date=end_date)

        self.assertEqual(
            entity_version.find_parent_faculty_version(
                entity_school_version_level2, ac_yr), entity_faculty_version)
예제 #20
0
    def create_new_entity(self):
        country = CountryFactory()
        # Root entity
        self.root_entity = EntityFactory(country=country)
        self.root_entity_version = EntityVersionFactory(
            entity=self.root_entity,
            acronym="ROOT_V",
            parent=None,
            end_date=None)

        # Child 1 entity to root
        self.child_one_entity = EntityFactory(country=country)
        self.child_one_entity_version = EntityVersionFactory(
            acronym="CHILD_1_V",
            parent=self.root_entity,
            end_date=None,
            entity=self.child_one_entity)

        # Child 2 entity to root
        self.child_two_entity = EntityFactory(country=country)
        self.child_two_entity_version = EntityVersionFactory(
            acronym="CHILD_2_V",
            parent=self.root_entity,
            end_date=None,
            entity=self.child_two_entity)
    def setUp(self):
        self.country = CountryFactory()
        self.entities = [EntityFactory(country=self.country) for x in range(3)]
        self.parent = EntityFactory(country=self.country)
        self.start_date = datetime.date(2015, 1, 1)
        self.end_date = datetime.date(2015, 12, 31)
        self.date_in_2015 = factory.fuzzy.FuzzyDate(
            datetime.date(2015, 1, 1), datetime.date(2015, 12, 30)).fuzz()
        self.date_in_2017 = factory.fuzzy.FuzzyDate(
            datetime.date(2017, 1, 1), datetime.date(2017, 12, 30)).fuzz()

        self.entity_versions = [
            EntityVersionFactory(entity=self.entities[x],
                                 acronym="ENTITY_V_" + str(x),
                                 title="This is the entity version " + str(x),
                                 entity_type="FACULTY",
                                 parent=self.parent,
                                 start_date=self.start_date,
                                 end_date=self.end_date) for x in range(3)
        ]
        self.parent_entity_version = EntityVersionFactory(
            entity=self.parent,
            acronym="ENTITY_PARENT",
            title="This is the entity parent version",
            entity_type="SECTOR",
            start_date=self.start_date,
            end_date=self.end_date)
예제 #22
0
    def setUpTestData(cls):
        cls.user = PersonFactory().user
        cls.current_academic_year = AcademicYearFactory(current=True)
        cls.academic_calendar = OpenAcademicCalendarFactory(
            academic_year=cls.current_academic_year,
            data_year=cls.current_academic_year,
            reference=academic_calendar_type.SUMMARY_COURSE_SUBMISSION)
        cls.entity = EntityFactory()
        cls.parent = EntityFactory()
        cls.start_date = datetime.date.today() - datetime.timedelta(weeks=48)
        cls.end_date = datetime.date.today() + datetime.timedelta(weeks=48)

        cls.entity_version = EntityVersionFactory(
            entity=cls.entity,
            acronym="ENTITY_CHILDREN",
            title="This is the entity version ",
            entity_type="FACULTY",
            parent=cls.parent,
            start_date=cls.start_date,
            end_date=cls.end_date)
        cls.parent_entity_version = EntityVersionFactory(
            entity=cls.parent,
            acronym="ENTITY_PARENT",
            title="This is the entity parent version",
            entity_type="SECTOR",
            start_date=cls.start_date,
            end_date=cls.end_date)
예제 #23
0
 def setUp(self):
     self.entity1 = EntityFactory()
     self.entity_version1 = EntityVersionFactory(
         entity=self.entity1, entity_type=entity_type.SECTOR)
     self.entity2 = EntityFactory()
     self.entity_version2 = EntityVersionFactory(
         entity=self.entity2, entity_type=entity_type.FACULTY)
     self.entity3 = EntityFactory()
     self.entity_version3 = EntityVersionFactory(
         entity=self.entity3, entity_type=entity_type.FACULTY)
     self.entity4 = EntityFactory()
     self.entity_version4 = EntityVersionFactory(
         entity=self.entity4,
         parent=self.entity3,
         entity_type=entity_type.SCHOOL)
     self.reviewer1 = ReviewerFactory(role=reviewer_role.VICE_RECTOR,
                                      entity=self.entity1)
     self.reviewer2 = ReviewerFactory(role=reviewer_role.SUPERVISION,
                                      entity=self.entity2)
     self.reviewer3 = ReviewerFactory(role=reviewer_role.SUPERVISION,
                                      entity=self.entity3)
     self.reviewer4 = ReviewerFactory(role=reviewer_role.SUPERVISION_DAF,
                                      entity=self.entity3)
     self.reviewer5 = ReviewerFactory(
         role=reviewer_role.SUPERVISION_DAF_ASSISTANT, entity=self.entity4)
    def setUpTestData(cls):
        # User creation
        cls.user = UserFactory()
        cls.user_adri = UserFactory()
        entity_version = EntityVersionFactory(acronym='ADRI')
        PartnershipEntityManagerFactory(entity=entity_version.entity,
                                        person__user=cls.user_adri)
        cls.user_gf = UserFactory()
        entity_manager = PartnershipEntityManagerFactory(
            person__user=cls.user_gf)
        EntityVersionFactory(entity=entity_manager.entity)
        cls.user_other_gf = UserFactory()
        PartnershipEntityManagerFactory(person__user=cls.user_other_gf,
                                        entity=entity_manager.entity)

        # Partnership creation
        contact = ContactFactory()
        cls.partnership = PartnershipFactory(contacts=[contact])
        cls.url = resolve_url(
            'partnerships:contacts:delete',
            partnership_pk=cls.partnership.pk,
            pk=contact.pk,
        )

        contact = ContactFactory()
        cls.partnership_gf = PartnershipFactory(
            author=cls.user_gf.person,
            ucl_entity=entity_manager.entity,
            contacts=[contact],
        )
        cls.gf_url = resolve_url(
            'partnerships:contacts:delete',
            partnership_pk=cls.partnership_gf.pk,
            pk=contact.pk,
        )
예제 #25
0
    def setUp(self):
        self.user = UserFactory()

        generatorContainer = GenerateContainer(datetime.date.today().year,
                                               datetime.date.today().year)
        self.partim = generatorContainer.generated_container_years[
            0].learning_unit_year_partim
        self.learning_unit_year_1 = generatorContainer.generated_container_years[
            0].learning_unit_year_full
        self.entity_1 = generatorContainer.entities[0]
        self.entity_version_1 = EntityVersionFactory(entity=self.entity_1,
                                                     acronym="AGRO")
        self.entity_2 = generatorContainer.entities[0]
        self.entity_version_2 = EntityVersionFactory(entity=self.entity_2,
                                                     acronym="DRT")

        self.learning_unit_year_1.entities = {
            REQUIREMENT_ENTITY: self.entity_version_1,
            ALLOCATION_ENTITY: self.entity_version_1,
            ADDITIONAL_REQUIREMENT_ENTITY_1: self.entity_version_2
        }

        self.academic_year = self.learning_unit_year_1.academic_year
        self.proposal = ProposalLearningUnitFactory(
            learning_unit_year=self.learning_unit_year_1,
            initial_data={"learning_unit": {
                "faculty_remark": "First remark"
            }})
예제 #26
0
def create_entities_hierarchy(organization_type=MAIN):
    country = CountryFactory()
    start_date = date.today().replace(year=1900)
    organization = OrganizationFactory(type=organization_type)
    root_entity = EntityFactory(country=country, organization=organization)
    root_entity_version = EntityVersionFactory(entity=root_entity,
                                               acronym="ROOT_V",
                                               entity_type=SECTOR,
                                               parent=None,
                                               end_date=None,
                                               start_date=start_date)

    child_one_entity = EntityFactory(country=country, organization=organization)
    child_one_entity_version = EntityVersionFactory(acronym="CHILD_1_V",
                                                    parent=root_entity,
                                                    entity_type=FACULTY,
                                                    end_date=None,
                                                    entity=child_one_entity,
                                                    start_date=start_date)

    child_two_entity = EntityFactory(country=country, organization=organization)
    child_two_entity_version = EntityVersionFactory(acronym="CHILD_2_V",
                                                    parent=root_entity,
                                                    entity_type=FACULTY,
                                                    end_date=None,
                                                    entity=child_two_entity,
                                                    start_date=start_date)

    return locals()
예제 #27
0
    def setUp(self):

        self.mandate = AssistantMandateFactory(
            state=assistant_mandate_state.DONE)
        self.entity_version1 = EntityVersionFactory(
            entity_type=entity_type.INSTITUTE, end_date=None)
        self.mandate_entity1 = MandateEntityFactory(
            assistant_mandate=self.mandate, entity=self.entity_version1.entity)
        self.entity_version2 = EntityVersionFactory(
            entity_type=entity_type.FACULTY, end_date=None)
        self.mandate_entity2 = MandateEntityFactory(
            assistant_mandate=self.mandate, entity=self.entity_version2.entity)
        self.entity_version3 = EntityVersionFactory(
            entity_type=entity_type.SECTOR, end_date=None)
        self.mandate_entity3 = MandateEntityFactory(
            assistant_mandate=self.mandate, entity=self.entity_version3.entity)
        self.reviewer1 = reviewer.ReviewerFactory(
            role=reviewer_role.RESEARCH, entity=self.entity_version1.entity)
        self.review1 = review.ReviewFactory(reviewer=self.reviewer1,
                                            status=review_status.DONE,
                                            mandate=self.mandate)
        self.reviewer2 = reviewer.ReviewerFactory(
            role=reviewer_role.SUPERVISION, entity=self.entity_version2.entity)
        self.review2 = review.ReviewFactory(reviewer=self.reviewer2,
                                            status=review_status.DONE,
                                            mandate=self.mandate)
        self.reviewer3 = reviewer.ReviewerFactory(
            role=reviewer_role.VICE_RECTOR_ASSISTANT,
            entity=self.entity_version3.entity)
        self.review2 = review.ReviewFactory(reviewer=self.reviewer3,
                                            status=review_status.DONE,
                                            mandate=self.mandate)
        self.client = Client()
        self.client.force_login(self.reviewer1.person.user)
예제 #28
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'
예제 #29
0
    def test_with_all_entities_set(self):
        today = datetime.date.today()
        entity_1 = EntityFactory(organization=OrganizationFactory(type=organization_type.MAIN))
        additional_entity_version_1 = EntityVersionFactory(entity_type=entity_type.SCHOOL,
                                                           start_date=today.replace(year=1900),
                                                           end_date=today.replace(year=today.year + 1),
                                                           entity=entity_1)
        entity_2 = EntityFactory(organization=OrganizationFactory(type=organization_type.MAIN))
        additional_entity_version_2 = EntityVersionFactory(entity_type=entity_type.SCHOOL,
                                                           start_date=today.replace(year=1900),
                                                           end_date=today.replace(year=today.year + 1),
                                                           entity=entity_2)
        self.form_data["allocation_entity"] = self.entity_version.id
        self.form_data["additional_entity_1"] = additional_entity_version_1.id
        self.form_data["additional_entity_2"] = additional_entity_version_2.id

        form = ProposalBaseForm(self.form_data, self.person, self.learning_unit_year)
        self.assertTrue(form.is_valid(), form.errors)
        form.save()

        self.learning_unit_year.learning_container_year.refresh_from_db()
        entities_by_type = self.learning_unit_year.learning_container_year.get_map_entity_by_type()

        expected_entities = {
            entity_container_year_link_type.REQUIREMENT_ENTITY: self.entity_version.entity,
            entity_container_year_link_type.ALLOCATION_ENTITY: self.entity_version.entity,
            entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_1: additional_entity_version_1.entity,
            entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_2: additional_entity_version_2.entity
        }
        self.assertDictEqual(entities_by_type, expected_entities)
예제 #30
0
    def test_with_all_entities_set(self):
        today = datetime.date.today()
        entity_1 = EntityFactory(organization=OrganizationFactory(type=organization_type.MAIN))
        additional_entity_version_1 = EntityVersionFactory(entity_type=entity_type.SCHOOL, start_date=today,
                                                           end_date=today.replace(year=today.year + 1),
                                                           entity=entity_1)
        entity_2 = EntityFactory(organization=OrganizationFactory(type=organization_type.MAIN))
        additional_entity_version_2 = EntityVersionFactory(entity_type=entity_type.SCHOOL, start_date=today,
                                                           end_date=today.replace(year=today.year + 1),
                                                           entity=entity_2)
        self.form_data["allocation_entity"] = self.entity_version.id
        self.form_data["additional_entity_1"] = additional_entity_version_1.id
        self.form_data["additional_entity_2"] = additional_entity_version_2.id

        form = LearningUnitProposalModificationForm(self.form_data)
        form.save(self.learning_unit_year, self.person, PROPOSAL_TYPE, PROPOSAL_STATE)

        entities_by_type = \
            entity_container_year.find_entities_grouped_by_linktype(self.learning_unit_year.learning_container_year)

        expected_entities = {
            entity_container_year_link_type.REQUIREMENT_ENTITY: self.entity_version.entity,
            entity_container_year_link_type.ALLOCATION_ENTITY: self.entity_version.entity,
            entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_1: additional_entity_version_1.entity,
            entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_2: additional_entity_version_2.entity
        }
        self.assertDictEqual(entities_by_type, expected_entities)