Beispiel #1
0
def _setup_learning_component_year(learning_unit_year, component_type):
    component = LearningComponentYearFactory(learning_container_year=learning_unit_year.learning_container_year,
                                             type=component_type)

    LearningUnitComponentFactory(learning_unit_year=learning_unit_year,
                                 learning_component_year=component)
    return component
 def setUp(self):
     self.academic_year = AcademicYearFactory(year=2016)
     self.learning_unit_years = [
         LearningUnitYearFactory(academic_year=self.academic_year)
         for x in range(2)
     ]
     self.learning_container_years = [
         LearningContainerYearFactory(academic_year=self.academic_year)
         for x in range(2)
     ]
     self.learning_component_years = [
         LearningComponentYearFactory(
             learning_container_year=self.learning_container_years[x])
         for x in range(2)
     ]
     self.learning_unit_components = [
         LearningUnitComponentFactory(
             learning_unit_year=self.learning_unit_years[x],
             learning_component_year=self.learning_component_years[x])
         for x in range(2)
     ]
     self.learning_class_years = [
         LearningClassYearFactory(
             learning_component_year=self.learning_component_years[x])
         for x in range(2)
     ]
 def setUp(self):
     self.luy_full = LearningUnitYearFactory(
         academic_year=self.ay,
         subtype=learning_unit_year_subtypes.FULL,
         quadrimester=None)
     self.learning_component_year_full_lecturing = LearningComponentYearFactory(
         learning_unit_year=self.luy_full)
Beispiel #4
0
    def test_learning_unit_usage_two_usages(self):
        learning_container_yr = LearningContainerYearFactory(
            academic_year=self.current_academic_year, acronym='LBIOL')

        learning_unit_yr_1 = LearningUnitYearFactory(
            academic_year=self.current_academic_year,
            acronym='LBIOLA',
            learning_container_year=learning_container_yr)
        learning_unit_yr_2 = LearningUnitYearFactory(
            academic_year=self.current_academic_year,
            acronym='LBIOLB',
            learning_container_year=learning_container_yr)

        learning_component_yr = LearningComponentYearFactory(
            learning_container_year=learning_container_yr)

        LearningUnitComponentFactory(
            learning_unit_year=learning_unit_yr_1,
            learning_component_year=learning_component_yr)
        LearningUnitComponentFactory(
            learning_unit_year=learning_unit_yr_2,
            learning_component_year=learning_component_yr)

        self.assertEqual(
            learning_unit_view._learning_unit_usage(learning_component_yr),
            'LBIOLA, LBIOLB')
Beispiel #5
0
    def test_dl_component_tooltip(self):
        lcy = LearningComponentYearFactory(
            hourly_volume_partial_q1=OTHER_VOLUME)

        context = {
            'components_initial_data': {
                'components': [
                    {
                        'learning_component_year': {
                            'id':
                            lcy.id,
                            'hourly_volume_partial_q1':
                            lcy.hourly_volume_partial_q1
                        },
                        'volumes': {
                            VOLUME_Q1: OTHER_VOLUME
                        }
                    },
                ]
            }
        }

        expected_html = "<dl><dd  data-toggle=tooltip title='{} : {}' class='{}'  id='id_volume_q1'><p style='' " \
                        "title=''>{}</p></dd></dl>". \
            format(LABEL_VALUE_BEFORE_PROPOSAL, OTHER_VOLUME, CSS_PROPOSAL_VALUE, VOLUME)
        self.assertEqual(
            dl_component_tooltip({'differences': context},
                                 VOLUME_Q1,
                                 value=VOLUME,
                                 id=lcy.id), expected_html)
Beispiel #6
0
    def create_learning_unit_years_and_dependencies(self):
        l1 = LearningUnitFactory()

        learning_unit_years = []
        for year in range(4):
            ac_year = AcademicYearFactory(year=2000 + year)
            l_containeryear = LearningContainerYearFactory(
                academic_year=ac_year)
            EntityContainerYearFactory(
                learning_container_year=l_containeryear,
                entity=self.entity_version.entity,
                type=entity_container_year_link_type.REQUIREMENT_ENTITY)
            learning_unit_year = LearningUnitYearFactory(
                learning_unit=l1,
                academic_year=ac_year,
                learning_container_year=l_containeryear)
            learning_unit_years.append(learning_unit_year)

        learning_unit_years[1].subtype = learning_unit_year_subtypes.FULL
        learning_unit_years[1].save()
        lcomponent = LearningComponentYearFactory()
        LearningClassYearFactory(learning_component_year=lcomponent)
        LearningClassYearFactory(learning_component_year=lcomponent)
        LearningUnitComponentFactory(learning_unit_year=learning_unit_years[1],
                                     learning_component_year=lcomponent)
        return learning_unit_years
def _create_learning_unit_year_with_components(academic_year, l_container,
                                               acronym, subtype):
    l_unit_year = LearningUnitYearFactory(academic_year=academic_year,
                                          learning_container_year=l_container,
                                          acronym=acronym,
                                          subtype=subtype)

    # Create component - CM - TP
    LearningComponentYearFactory(learning_unit_year=l_unit_year,
                                 type=learning_component_year_type.LECTURING,
                                 acronym="PM")
    LearningComponentYearFactory(
        learning_unit_year=l_unit_year,
        type=learning_component_year_type.PRACTICAL_EXERCISES,
        acronym="PP")
    return l_unit_year
Beispiel #8
0
    def create_learning_unit_years_and_dependencies(self):
        academic_year = create_editable_academic_year()
        acronym = "LDROI1004"
        l1 = LearningUnitFactory(start_year=academic_year.year)

        learning_unit_years = []
        for year in range(4):
            ac_year = AcademicYearFactory(year=academic_year.year + year)
            l_containeryear = LearningContainerYearFactory(
                academic_year=ac_year,
                requirement_entity=self.entity_version.entity,
            )
            learning_unit_year = LearningUnitYearFactory(
                acronym=acronym,
                learning_unit=l1,
                academic_year=ac_year,
                learning_container_year=l_containeryear)
            learning_unit_years.append(learning_unit_year)

        learning_unit_years[1].subtype = learning_unit_year_subtypes.FULL
        learning_unit_years[1].save()
        lcomponent = LearningComponentYearFactory()
        LearningClassYearFactory(learning_component_year=lcomponent)
        LearningClassYearFactory(learning_component_year=lcomponent)
        return learning_unit_years
Beispiel #9
0
    def setUp(self):
        today = datetime.date.today()
        self.current_academic_year = AcademicYearFactory(
            start_date=today,
            end_date=today.replace(year=today.year + 1),
            year=today.year)
        self.learning_container_yr = LearningContainerYearFactory(
            academic_year=self.current_academic_year)
        self.organization = OrganizationFactory(type=organization_type.MAIN)
        self.country = CountryFactory()
        self.entity = EntityFactory(country=self.country,
                                    organization=self.organization)
        self.entity_container_yr = EntityContainerYearFactory(
            learning_container_year=self.learning_container_yr,
            type=entity_container_year_link_type.REQUIREMENT_ENTITY,
            entity=self.entity)
        self.learning_component_yr = LearningComponentYearFactory(
            learning_unit_year__learning_container_year=self.
            learning_container_yr,
            hourly_volume_partial_q1=-1,
            planned_classes=1)
        self.entity_component_yr = EntityComponentYearFactory(
            learning_component_year=self.learning_component_yr,
            entity_container_year=self.entity_container_yr,
            repartition_volume=None)

        self.entity_components_yr = [
            self.entity_component_yr,
        ]
 def setUp(self):
     self.person = PersonFactory(first_name="John", last_name="Doe")
     self.tutor = TutorFactory(person=self.person)
     self.attribution_new = AttributionNewFactory(tutor=self.tutor, function=function.PROFESSOR)
     self.attribution_new_without_attribution_charge = AttributionNewFactory(tutor=self.tutor,
                                                                             function=function.PROFESSOR)
     self.learning_component_year_lecturing = LearningComponentYearFactory(type=component_type.LECTURING)
     self.learning_component_year_practical = LearningComponentYearFactory(type=component_type.PRACTICAL_EXERCISES)
     self.attribution_charge_new_lecturing = \
         AttributionChargeNewFactory(attribution=self.attribution_new,
                                     learning_component_year=self.learning_component_year_lecturing,
                                     allocation_charge=10)
     self.attribution_charge_new_practical = \
         AttributionChargeNewFactory(attribution=self.attribution_new,
                                     learning_component_year=self.learning_component_year_practical,
                                     allocation_charge=20)
Beispiel #11
0
 def test_update_volumes_data(self):
     volumes = {
         learning_component_year_type.LECTURING: VOLUMES_INITIALIZED,
         learning_component_year_type.PRACTICAL_EXERCISES:
         VOLUMES_INITIALIZED
     }
     lecturing_data = {
         'PLANNED_CLASSES': 1,
         'VOLUME_Q1': 10,
         'VOLUME_TOTAL': 50,
         'VOLUME_Q2': 40
     }
     compo = {
         'learning_component_year':
         LearningComponentYearFactory(
             learning_container_year=self.learning_container_luy1,
             type=learning_component_year_type.LECTURING),
         'volumes':
         lecturing_data
     }
     volumes_updated = _update_volumes_data(compo, volumes)
     self.assertCountEqual(
         volumes_updated.get(learning_component_year_type.LECTURING),
         lecturing_data)
     self.assertCountEqual(
         volumes_updated.get(
             learning_component_year_type.PRACTICAL_EXERCISES),
         VOLUMES_INITIALIZED)
 def setUpTestData(cls):
     cls.language_fr = LanguageFactory(code="FR")
     cls.language_en = LanguageFactory(code="EN")
     cls.user = UserFactory()
     flag, created = Flag.objects.get_or_create(name='learning_achievement_update')
     flag.users.add(cls.user)
     cls.person = PersonWithPermissionsFactory("can_access_learningunit", "can_create_learningunit", user=cls.user)
     cls.person_entity = PersonEntityFactory(person=cls.person)
     EntityVersionFactory(entity=cls.person_entity.entity)
     cls.academic_years = AcademicYearFactory.produce_in_future(quantity=5)
     cls.max_la_number = 2*len(cls.academic_years)
     cls.learning_unit = LearningUnitFactory(start_year=cls.academic_years[0], end_year=cls.academic_years[-1])
     cls.learning_container = LearningContainerFactory()
     cls.learning_unit_years = [LearningUnitYearFactory(
         academic_year=academic_year,
         subtype=learning_unit_year_subtypes.FULL,
         learning_container_year=LearningContainerYearFactory(
             academic_year=academic_year,
             learning_container=cls.learning_container,
             requirement_entity=cls.person_entity.entity
         ),
         learning_unit=cls.learning_unit,
         acronym="TEST0000"
     ) for academic_year in cls.academic_years]
     cls.learning_component_years = [LearningComponentYearFactory(
         learning_unit_year=luy,
     ) for luy in cls.learning_unit_years]
Beispiel #13
0
    def test_volume_edition_as_faculty_manager(self):
        component = LearningComponentYearFactory()
        form = VolumeEditionForm(
            data={
                'volume_q1': 12,
                'volume_q2': 12,
                'volume_total': 24
            },
            component=component,
            learning_unit_year=self.learning_unit_year_full,
            is_faculty_manager=True,
            initial={
                'volume_q1': 0,
                'volume_q2': 12
            })

        form.is_valid()
        self.assertEqual(
            form.errors['volume_q2'][1],
            gettext('One of the partial volumes must have a value to 0.'))
        self.assertEqual(
            form.errors['volume_q1'][1],
            gettext('One of the partial volumes must have a value to 0.'))

        form = VolumeEditionForm(
            data={
                'volume_q1': 0,
                'volume_q2': 12,
                'volume_total': 24
            },
            component=component,
            learning_unit_year=self.learning_unit_year_full,
            is_faculty_manager=True,
            initial={
                'volume_q1': 12,
                'volume_q2': 12
            })

        form.is_valid()
        self.assertEqual(form.errors['volume_q1'][1],
                         gettext('The volume can not be set to 0.'))

        form = VolumeEditionForm(
            data={
                'volume_q1': 12,
                'volume_q2': 0,
                'volume_total': 24
            },
            component=component,
            learning_unit_year=self.learning_unit_year_full,
            is_faculty_manager=True,
            initial={
                'volume_q1': 12,
                'volume_q2': 12
            })

        form.is_valid()
        self.assertEqual(form.errors['volume_q2'][1],
                         gettext('The volume can not be set to 0.'))
Beispiel #14
0
    def setUpTestData(cls):
        cls.academic_year = AcademicYearFactory()
        cls.person = PersonFactory()
        cls.education_group_year_1 = EducationGroupYearFactory(
            title_english="", academic_year=cls.academic_year)
        cls.education_group_year_2 = EducationGroupYearFactory(
            title_english="", academic_year=cls.academic_year)
        cls.education_group_year_3 = EducationGroupYearFactory(
            title_english="", academic_year=cls.academic_year)
        cls.learning_unit_year_1 = LearningUnitYearFactory(
            specific_title_english="")
        cls.learning_unit_year_2 = LearningUnitYearFactory(
            specific_title_english="")
        cls.learning_component_year_1 = LearningComponentYearFactory(
            learning_unit_year=cls.learning_unit_year_1,
            hourly_volume_partial_q1=10,
            hourly_volume_partial_q2=10)
        cls.learning_component_year_2 = LearningComponentYearFactory(
            learning_unit_year=cls.learning_unit_year_1,
            hourly_volume_partial_q1=10,
            hourly_volume_partial_q2=10)
        cls.group_element_year_1 = GroupElementYearFactory(
            parent=cls.education_group_year_1,
            child_branch=cls.education_group_year_2)
        cls.group_element_year_2 = GroupElementYearFactory(
            parent=cls.education_group_year_2,
            child_branch=None,
            child_leaf=cls.learning_unit_year_1)
        cls.group_element_year_3 = GroupElementYearFactory(
            parent=cls.education_group_year_1,
            child_branch=cls.education_group_year_3)
        cls.group_element_year_4 = GroupElementYearFactory(
            parent=cls.education_group_year_3,
            child_branch=None,
            child_leaf=cls.learning_unit_year_2)
        cls.user = UserFactory()
        cls.person = PersonFactory(user=cls.user)
        cls.user.user_permissions.add(
            Permission.objects.get(codename="can_access_education_group"))

        AcademicYearFactory(current=True)
        cls.url = reverse("education_group_utilization",
                          args=[
                              cls.education_group_year_2.id,
                              cls.education_group_year_2.id,
                          ])
Beispiel #15
0
    def test_update_or_create_entity_container_year_with_components_type_requirement(self):
        """In this test, we ensure that when we create an entity_container type requirement,
           we have an entity_component created"""
        an_entity = EntityFactory()
        a_learning_container_year = LearningContainerYearFactory(academic_year=self.academic_year)
        LearningComponentYearFactory(acronym="PM", learning_container_year=a_learning_container_year)
        LearningComponentYearFactory(acronym="PP", learning_container_year=a_learning_container_year)
        link_type = random.choice(REQUIREMENT_ENTITIES)

        business_edition.update_or_create_entity_container_year_with_components(
            an_entity, a_learning_container_year, link_type
        )
        self.assertEqual(EntityContainerYear.objects.filter(
            learning_container_year=a_learning_container_year).count(), 1)
        self.assertEqual(EntityComponentYear.objects.filter(
            entity_container_year__learning_container_year=a_learning_container_year
        ).count(), 2)
Beispiel #16
0
 def setUpTestData(cls):
     cls.academic_year = AcademicYearFactory()
     cls.person = PersonFactory()
     cls.education_group_year_1 = EducationGroupYearFactory(
         title_english="", academic_year=cls.academic_year)
     cls.education_group_year_2 = EducationGroupYearFactory(
         title_english="", academic_year=cls.academic_year)
     cls.education_group_year_3 = EducationGroupYearFactory(
         title_english="", academic_year=cls.academic_year)
     cls.learning_unit_year_1 = LearningUnitYearFactory(
         specific_title_english="")
     cls.learning_unit_year_2 = LearningUnitYearFactory(
         specific_title_english="")
     cls.learning_component_year_1 = LearningComponentYearFactory(
         learning_unit_year=cls.learning_unit_year_1,
         hourly_volume_partial_q1=10,
         hourly_volume_partial_q2=10)
     cls.learning_component_year_2 = LearningComponentYearFactory(
         learning_unit_year=cls.learning_unit_year_1,
         hourly_volume_partial_q1=10,
         hourly_volume_partial_q2=10)
     cls.group_element_year_1 = GroupElementYearFactory(
         parent=cls.education_group_year_1,
         child_branch=cls.education_group_year_2,
         comment="commentaire",
         comment_english="english")
     cls.group_element_year_2 = GroupElementYearFactory(
         parent=cls.education_group_year_2,
         child_branch=None,
         child_leaf=cls.learning_unit_year_1,
         comment="commentaire",
         comment_english="english")
     cls.group_element_year_3 = GroupElementYearFactory(
         parent=cls.education_group_year_1,
         child_branch=cls.education_group_year_3,
         comment="commentaire",
         comment_english="english")
     cls.group_element_year_4 = GroupElementYearFactory(
         parent=cls.education_group_year_3,
         child_branch=None,
         child_leaf=cls.learning_unit_year_2,
         comment="commentaire",
         comment_english="english")
     cls.a_superuser = SuperUserFactory()
def _link_components_and_learning_unit_year_to_container(l_container, acronym,
                                                         volume_lecturing=None,
                                                         volume_practical_exercices=None,
                                                         subtype=learning_unit_year_subtypes.FULL):
    a_learning_unit_year = LearningUnitYearFactory(acronym=acronym, academic_year=l_container.academic_year,
                                                   specific_title=l_container.common_title, subtype=subtype,
                                                   learning_container_year=l_container)
    if volume_lecturing:
        LearningComponentYearFactory(
            learning_unit_year=a_learning_unit_year,
            type=learning_component_year_type.LECTURING,
            volume_declared_vacant=volume_lecturing
        )
    if volume_practical_exercices:
        LearningComponentYearFactory(
            learning_unit_year=a_learning_unit_year,
            type=learning_component_year_type.PRACTICAL_EXERCISES,
            volume_declared_vacant=volume_practical_exercices
        )
    return l_container
Beispiel #18
0
 def setUpTestData(cls):
     cls.academic_year = AcademicYearFactory(current=True)
     cls.l_unit_1 = LearningUnitYearFactory(
         acronym="LBIR1212",
         academic_year=cls.academic_year,
         subtype=learning_unit_year_subtypes.FULL)
     component = LearningComponentYearFactory(
         learning_unit_year=cls.l_unit_1)
     cls.attribution_charge_news = [
         AttributionChargeNewFactory(learning_component_year=component)
         for _ in range(5)
     ]
 def setUp(self):
     self.component_with_repartition = LearningComponentYearFactory(
         hourly_volume_total_annual=15.0,
         planned_classes=3,
         repartition_volume_requirement_entity=20.0,
         repartition_volume_additional_entity_1=10.0,
         repartition_volume_additional_entity_2=15.0,
         learning_unit_year__learning_container_year__requirement_entity=
         EntityVersionFactory().entity,
         learning_unit_year__learning_container_year__additional_entity_1=
         EntityVersionFactory().entity,
         learning_unit_year__learning_container_year__additional_entity_2=
         EntityVersionFactory().entity,
     )
     self.component_without_repartition = LearningComponentYearFactory(
         hourly_volume_total_annual=15.0,
         planned_classes=3,
         repartition_volume_requirement_entity=None,
         repartition_volume_additional_entity_1=None,
         repartition_volume_additional_entity_2=None,
     )
 def setUp(self):
     self.academic_year = AcademicYearFactory(year=timezone.now().year)
     self.l_unit_1 = LearningUnitYearFactory(
         acronym="LBIR1212",
         academic_year=self.academic_year,
         subtype=learning_unit_year_subtypes.FULL)
     component = LearningComponentYearFactory(
         learning_unit_year=self.l_unit_1)
     self.attribution_charge_news = [
         AttributionChargeNewFactory(learning_component_year=component)
         for _ in range(5)
     ]
Beispiel #21
0
class LearningUnitComponentFactory(DjangoModelFactory):
    class Meta:
        model = "base.LearningUnitComponent"

    external_id = factory.fuzzy.FuzzyText(length=10, chars=string.digits)

    learning_unit_year = factory.SubFactory(LearningUnitYearFakerFactory)
    learning_component_year = factory.LazyAttribute(
        lambda obj: LearningComponentYearFactory(learning_container_year=obj.learning_unit_year.learning_container_year,
                                                 type=obj.type)
    )
    type = factory.Iterator(component_type.COMPONENT_TYPES, getter=operator.itemgetter(0))
Beispiel #22
0
def _create_learning_unit_year_with_components(academic_year, l_container,
                                               acronym, subtype):
    l_unit_year = LearningUnitYearFactory(academic_year=academic_year,
                                          learning_container_year=l_container,
                                          acronym=acronym,
                                          subtype=subtype)

    # Create component - CM - TP
    l_component_cm = LearningComponentYearFactory(
        learning_container_year=l_container,
        type=learning_component_year_type.LECTURING,
        acronym="PM")
    l_component_tp = LearningComponentYearFactory(
        learning_container_year=l_container,
        type=learning_component_year_type.PRACTICAL_EXERCISES,
        acronym="PP")

    # Create Link between UE and component
    LearningUnitComponentFactory(learning_unit_year=l_unit_year,
                                 learning_component_year=l_component_cm)
    LearningUnitComponentFactory(learning_unit_year=l_unit_year,
                                 learning_component_year=l_component_tp)
Beispiel #23
0
    def test_update_or_create_entity_container_year_with_components_type_allocation(
            self):
        """In this test, we ensure that when we create an entity_container type allocation,
           we have NO entity_component created"""
        an_entity = EntityFactory()
        a_learning_container_year = LearningContainerYearFactory(
            academic_year=self.academic_year)
        LearningComponentYearFactory(
            acronym="PM", learning_container_year=a_learning_container_year)
        LearningComponentYearFactory(
            acronym="PP", learning_container_year=a_learning_container_year)
        link_type = entity_container_year_link_type.ALLOCATION_ENTITY

        business_edition.update_or_create_entity_container_year_with_components(
            an_entity, a_learning_container_year, link_type)
        self.assertEqual(
            EntityContainerYear.objects.filter(
                learning_container_year=a_learning_container_year).count(), 1)
        self.assertEqual(
            EntityComponentYear.objects.filter(
                entity_container_year__learning_container_year=
                a_learning_container_year).count(), 0)
Beispiel #24
0
def _create_learning_container_with_components(
        acronym,
        academic_year,
        volume_lecturing=None,
        volume_practical_exercices=None):
    l_container = LearningContainerYearFactory(acronym=acronym,
                                               academic_year=academic_year)
    a_learning_unit_year = LearningUnitYearFactory(
        acronym=acronym,
        academic_year=academic_year,
        specific_title=l_container.common_title,
        learning_container_year=l_container)
    if volume_lecturing:
        LearningComponentYearFactory(
            learning_unit_year=a_learning_unit_year,
            type=learning_component_year_type.LECTURING,
            volume_declared_vacant=volume_lecturing)

    if volume_practical_exercices:
        LearningComponentYearFactory(
            learning_unit_year=a_learning_unit_year,
            type=learning_component_year_type.PRACTICAL_EXERCISES,
            volume_declared_vacant=volume_practical_exercices)
Beispiel #25
0
def _create_learning_unit_year_with_components(l_container, create_lecturing_component=True, create_pratical_component=True):
    a_learning_unit_year = LearningUnitYearFactory(learning_container_year=l_container,
                                                   acronym=l_container.acronym,
                                                   academic_year=l_container.academic_year,
                                                   status=True)

    if create_lecturing_component:
        a_component = LearningComponentYearFactory(
            learning_container_year=l_container,
            type=learning_component_year_type.LECTURING,
            planned_classes=1
        )
        LearningUnitComponentFactory(learning_unit_year=a_learning_unit_year, learning_component_year=a_component)

    if create_pratical_component:
        a_component = LearningComponentYearFactory(
            learning_container_year=l_container,
            type=learning_component_year_type.PRACTICAL_EXERCISES,
            planned_classes=1
        )
        LearningUnitComponentFactory(learning_unit_year=a_learning_unit_year, learning_component_year=a_component)

    return a_learning_unit_year
Beispiel #26
0
    def test_compare_learning_component_year(self):
        acronym_used_twice = 'PM1'
        acronym_used_once = 'PM2'

        l_comp_yr_current = LearningComponentYearFactory(
            acronym=acronym_used_twice, planned_classes=1)
        LearningClassYearFactory(learning_component_year=l_comp_yr_current)
        l_comp_yr_previous = LearningComponentYearFactory(
            acronym=acronym_used_twice, planned_classes=1)
        l_comp_yr_next = LearningComponentYearFactory(
            acronym=acronym_used_once, planned_classes=1)

        data = compare_learning_component_year(l_comp_yr_current,
                                               l_comp_yr_previous,
                                               l_comp_yr_next)
        self.assertEqual(data.get('acronym'), [
            l_comp_yr_previous.acronym, l_comp_yr_current.acronym,
            l_comp_yr_next.acronym
        ])
        self.assertEqual(data.get('real_classes'), [
            l_comp_yr_previous.real_classes, l_comp_yr_current.real_classes,
            l_comp_yr_next.real_classes
        ])
Beispiel #27
0
    def test_delete_all_learning_units_year_case_error_have_attributionnew_with_charge(
            self):
        learning_unit_years = self.learning_unit_year_list
        ly1 = learning_unit_years[1]
        attrib_new_1 = AttributionNewFactory(
            learning_container_year=ly1.learning_container_year)
        learning_component_year_1 = LearningComponentYearFactory(
            learning_unit_year=ly1)
        AttributionChargeNewFactory(
            attribution=attrib_new_1,
            learning_component_year=learning_component_year_1)

        request_factory = RequestFactory()

        request = request_factory.post(
            reverse(delete_all_learning_units_year, args=[ly1.id]))
        request.user = self.user

        setattr(request, 'session', 'session')
        setattr(request, '_messages', FallbackStorage(request))

        response = delete_all_learning_units_year(request, ly1.id)

        # Get message from context
        msg = [m.message for m in get_messages(request)]
        msg_level = [m.level for m in get_messages(request)]
        self.assertEqual(len(msg), 1)
        self.assertIn(messages.ERROR, msg_level)

        # Check error message
        subtype = _('The partim') if ly1.is_partim() else _(
            'The learning unit')
        self.assertIn(
            _("%(subtype)s %(acronym)s is assigned to %(tutor)s for the year %(year)s"
              ) % {
                  'subtype': subtype,
                  'acronym': ly1.acronym,
                  'tutor': attrib_new_1.tutor,
                  'year': ly1.academic_year
              }, msg)

        # Check that record is not deleted
        self.assertTrue(LearningUnitYear.objects.filter(pk=ly1.pk).exists())

        # Check redirection to identification
        self.assertEqual(response.status_code, 302)
        self.assertEqual(
            response.url,
            reverse('learning_unit', kwargs={'learning_unit_year_id': ly1.pk}))
Beispiel #28
0
    def test_get_volumes(self):
        learning_container_luy = LearningContainerYearFactory(
            academic_year=self.current_academic_year)
        luy = LearningUnitYearFactory(
            academic_year=self.current_academic_year,
            learning_container_year=learning_container_luy)

        LearningComponentYearFactory(
            learning_container_year=learning_container_luy,
            type=learning_component_year_type.LECTURING,
            hourly_volume_total_annual=15,
            hourly_volume_partial_q1=10,
            hourly_volume_partial_q2=5,
            planned_classes=1)
        LearningComponentYearFactory(
            learning_container_year=learning_container_luy,
            type=learning_component_year_type.PRACTICAL_EXERCISES,
            hourly_volume_total_annual=20,
            hourly_volume_partial_q1=10,
            hourly_volume_partial_q2=10,
            planned_classes=1)
        volumes = _get_volumes(luy)
        self.assertEqual(
            volumes.get('LECTURING'), {
                'VOLUME_TOTAL': 15,
                'PLANNED_CLASSES': 1,
                'VOLUME_Q1': 10,
                'VOLUME_Q2': 5
            })
        self.assertEqual(
            volumes.get('PRACTICAL_EXERCISES'), {
                'VOLUME_TOTAL': 20,
                'PLANNED_CLASSES': 1,
                'VOLUME_Q1': 10,
                'VOLUME_Q2': 10
            })
Beispiel #29
0
 def setUp(self):
     self.academic_year = AcademicYearFactory()
     self.education_group_year_1 = EducationGroupYearFactory(credits=10, academic_year=self.academic_year)
     self.education_group_year_2 = EducationGroupYearFactory(credits=20, academic_year=self.academic_year)
     self.learning_unit_year_1 = LearningUnitYearFactory()
     self.learning_unit_year_2 = LearningUnitYearFactory(periodicity=BIENNIAL_ODD)
     self.learning_unit_year_3 = LearningUnitYearFactory(status=False)
     self.learning_unit_year_4 = LearningUnitYearFactory(periodicity=BIENNIAL_EVEN)
     self.group_element_year_1 = GroupElementYearFactory(parent=self.education_group_year_1,
                                                         child_branch=self.education_group_year_2,
                                                         is_mandatory=True)
     self.group_element_year_2 = GroupElementYearFactory(parent=self.education_group_year_2,
                                                         child_branch=None,
                                                         child_leaf=self.learning_unit_year_1,
                                                         is_mandatory=True)
     self.group_element_year_3 = GroupElementYearFactory(parent=self.education_group_year_2,
                                                         child_branch=None,
                                                         child_leaf=self.learning_unit_year_2,
                                                         is_mandatory=True)
     self.group_element_year_4 = GroupElementYearFactory(parent=self.education_group_year_2,
                                                         child_branch=None,
                                                         child_leaf=self.learning_unit_year_3,
                                                         is_mandatory=True)
     self.learning_component_year_1 = LearningComponentYearFactory(
         learning_unit_year=self.learning_unit_year_1,
         type=LECTURING
     )
     self.learning_component_year_2 = LearningComponentYearFactory(
         learning_unit_year=self.learning_unit_year_1,
         type=PRACTICAL_EXERCISES
     )
     self.learning_component_year_3 = LearningComponentYearFactory(
         learning_unit_year=self.learning_unit_year_2,
         type=LECTURING
     )
     self.learning_component_year_4 = LearningComponentYearFactory(
         learning_unit_year=self.learning_unit_year_2,
         type=PRACTICAL_EXERCISES
     )
     self.learning_component_year_5 = LearningComponentYearFactory(
         learning_unit_year=self.learning_unit_year_3,
         type=LECTURING
     )
     self.learning_component_year_6 = LearningComponentYearFactory(
         learning_unit_year=self.learning_unit_year_3,
         type=PRACTICAL_EXERCISES
     )
     self.learning_component_year_7 = LearningComponentYearFactory(
         learning_unit_year=self.learning_unit_year_4,
         type=LECTURING
     )
    def setUp(self):
        current_academic_year = create_current_academic_year()
        an_organization = OrganizationFactory(type=organization_type.MAIN)
        learning_container_year = LearningContainerYearFactory(
            academic_year=current_academic_year,
            container_type=learning_container_year_types.COURSE,
        )
        self.learning_unit_year = LearningUnitYearFakerFactory(
            credits=5,
            subtype=learning_unit_year_subtypes.FULL,
            academic_year=current_academic_year,
            learning_container_year=learning_container_year,
            campus=CampusFactory(organization=an_organization,
                                 is_administration=True))

        self.entity_container_year = EntityContainerYearFactory(
            learning_container_year=self.learning_unit_year.
            learning_container_year,
            type=entity_container_year_link_type.REQUIREMENT_ENTITY)

        today = datetime.date.today()

        an_entity = EntityFactory(organization=an_organization)
        self.entity_version = EntityVersionFactory(
            entity=an_entity,
            entity_type=entity_type.SCHOOL,
            start_date=today,
            end_date=today.replace(year=today.year + 1))
        self.learning_component_year_lecturing = LearningComponentYearFactory(
            type=learning_component_year_type.LECTURING,
            acronym="TP",
            learning_container_year=learning_container_year)
        self.learning_component_year_practical = LearningComponentYearFactory(
            type=learning_component_year_type.PRACTICAL_EXERCISES,
            acronym="PP",
            learning_container_year=learning_container_year)