Ejemplo n.º 1
0
def _get_data_part2(learning_unit_yr, with_attributions):
    volumes = _get_volumes(learning_unit_yr)
    lu_data_part2 = []
    if with_attributions:
        lu_data_part2.append(" \n".join([
            _get_attribution_line(value)
            for value in learning_unit_yr.attribution_charge_news.values()
        ]))
    volume_lecturing = volumes.get(learning_component_year_type.LECTURING)
    volumes_practical = volumes.get(
        learning_component_year_type.PRACTICAL_EXERCISES)
    lu_data_part2.extend([
        xls_build.translate(learning_unit_yr.periodicity),
        xls_build.translate(learning_unit_yr.status),
        _get_significant_volume(volume_lecturing.get('VOLUME_TOTAL')),
        _get_significant_volume(volume_lecturing.get('VOLUME_Q1')),
        _get_significant_volume(volume_lecturing.get('VOLUME_Q2')),
        _get_significant_volume(volume_lecturing.get('PLANNED_CLASSES')),
        _get_significant_volume(volumes_practical.get('VOLUME_TOTAL')),
        _get_significant_volume(volumes_practical.get('VOLUME_Q1')),
        _get_significant_volume(volumes_practical.get('VOLUME_Q2')),
        _get_significant_volume(volumes_practical.get('PLANNED_CLASSES')),
        xls_build.translate(learning_unit_yr.quadrimester),
        xls_build.translate(learning_unit_yr.session),
        learning_unit_yr.language if learning_unit_yr.language else "",
        _get_absolute_credits(learning_unit_yr),
    ])
    return lu_data_part2
Ejemplo n.º 2
0
def _extract_xls_data_from_learning_unit(learning_unit_yr):
    return [learning_unit_yr.academic_year.name, learning_unit_yr.acronym, learning_unit_yr.specific_title,
            xls_build.translate(learning_unit_yr.learning_container_year.container_type),
            xls_build.translate(learning_unit_yr.subtype),
            _get_entity_acronym(learning_unit_yr.entities.get('REQUIREMENT_ENTITY')),
            _get_entity_acronym(learning_unit_yr.entities.get('ALLOCATION_ENTITY')),
            learning_unit_yr.credits, xls_build.translate(learning_unit_yr.status)]
Ejemplo n.º 3
0
def _get_data(learning_unit_yr, new_line, first_data):
    organization = get_organization_from_learning_unit_year(learning_unit_yr)
    return [
        _get_acronym(learning_unit_yr, new_line, first_data),
        learning_unit_yr.academic_year.name,
        xls_build.translate(learning_unit_yr.learning_container_year.container_type),
        _translate_status(learning_unit_yr.status),
        xls_build.translate(learning_unit_yr.subtype),
        _get_translation(learning_unit_yr.internship_subtype),
        learning_unit_yr.credits,
        learning_unit_yr.language.name if learning_unit_yr.language else EMPTY_VALUE,
        _get_translation(learning_unit_yr.periodicity),
        _get_translation(learning_unit_yr.quadrimester),
        _get_translation(learning_unit_yr.session),
        learning_unit_yr.learning_container_year.common_title,
        learning_unit_yr.specific_title,
        learning_unit_yr.learning_container_year.common_title_english,
        learning_unit_yr.specific_title_english,
        _get_entity_to_display(learning_unit_yr.entities.get(entity_types.REQUIREMENT_ENTITY)),
        _get_entity_to_display(learning_unit_yr.entities.get(entity_types.ALLOCATION_ENTITY)),
        _get_entity_to_display(learning_unit_yr.entities.get(entity_types.ADDITIONAL_REQUIREMENT_ENTITY_1)),
        _get_entity_to_display(learning_unit_yr.entities.get(entity_types.ADDITIONAL_REQUIREMENT_ENTITY_2)),
        xls_build.translate(learning_unit_yr.professional_integration),
        organization.name if organization else EMPTY_VALUE,
        learning_unit_yr.campus if learning_unit_yr.campus else EMPTY_VALUE,
        get_partims_as_str(learning_unit_yr.get_partims_related())
    ]
Ejemplo n.º 4
0
def extract_xls_data_from_learning_unit(learning_unit_yr):
    return [
        learning_unit_yr.academic_year.name, learning_unit_yr.acronym, learning_unit_yr.complete_title,
        xls_build.translate(learning_unit_yr.learning_container_year.container_type)
        # FIXME Condition to remove when the LearningUnitYear.learning_container_year_id will be null=false
        if learning_unit_yr.learning_container_year else "",
        xls_build.translate(learning_unit_yr.subtype),
        learning_unit_yr.entity_allocation,
        learning_unit_yr.entity_requirement,
        learning_unit_yr.credits, xls_build.translate(learning_unit_yr.status)
    ]
Ejemplo n.º 5
0
def extract_xls_data_from_learning_unit(learning_unit_yr):
    return [
        learning_unit_yr.academic_year.name, learning_unit_yr.acronym, learning_unit_yr.complete_title,
        xls_build.translate(learning_unit_yr.learning_container_year.container_type)
        # FIXME Condition to remove when the LearningUnitYear.learning_continer_year_id will be null=false
        if learning_unit_yr.learning_container_year else "",
        xls_build.translate(learning_unit_yr.subtype),
        get_entity_acronym(learning_unit_yr.entities.get('REQUIREMENT_ENTITY')),
        get_entity_acronym(learning_unit_yr.entities.get('ALLOCATION_ENTITY')),
        learning_unit_yr.credits, xls_build.translate(learning_unit_yr.status)
    ]
Ejemplo n.º 6
0
def extract_xls_data_from_learning_unit(learning_unit_yr):
    return [
        learning_unit_yr.academic_year.name, learning_unit_yr.acronym, learning_unit_yr.complete_title,
        xls_build.translate(learning_unit_yr.learning_container_year.container_type)
        # FIXME Condition to remove when the LearningUnitYear.learning_continer_year_id will be null=false
        if learning_unit_yr.learning_container_year else "",
        xls_build.translate(learning_unit_yr.subtype),
        learning_unit_yr.entity_allocation,
        learning_unit_yr.entity_requirement,
        learning_unit_yr.credits, xls_build.translate(learning_unit_yr.status)
    ]
Ejemplo n.º 7
0
def extract_xls_data_from_learning_unit(learning_unit_yr):
    return [
        learning_unit_yr.academic_year.name, learning_unit_yr.acronym, learning_unit_yr.complete_title,
        xls_build.translate(learning_unit_yr.learning_container_year.container_type)
        # FIXME Condition to remove when the LearningUnitYear.learning_continer_year_id will be null=false
        if learning_unit_yr.learning_container_year else "",
        xls_build.translate(learning_unit_yr.subtype),
        get_entity_acronym(learning_unit_yr.entities.get('REQUIREMENT_ENTITY')),
        get_entity_acronym(learning_unit_yr.entities.get('ALLOCATION_ENTITY')),
        learning_unit_yr.credits, xls_build.translate(learning_unit_yr.status)
    ]
Ejemplo n.º 8
0
 def get_xls_data(self, an_attribution, learning_unit_yr):
     return [
         learning_unit_yr.academic_year.name, learning_unit_yr.acronym,
         learning_unit_yr.complete_title,
         xls_build.translate(
             learning_unit_yr.learning_container_year.container_type),
         xls_build.translate(learning_unit_yr.subtype), ACRONYM_REQUIREMENT,
         ACRONYM_ALLOCATION, learning_unit_yr.credits,
         xls_build.translate(learning_unit_yr.status),
         an_attribution.get('person'),
         xls_build.translate((an_attribution.get('function'))),
         an_attribution.get('substitute'),
         an_attribution.get('LECTURING'),
         an_attribution.get('PRACTICAL_EXERCISES'),
         an_attribution.get('start_year'),
         an_attribution.get('duration')
     ]
Ejemplo n.º 9
0
 def _get_xls_data(self):
     return [
         self.l_unit_yr_1.entities.get('REQUIREMENT_ENTITY').acronym,
         self.proposal_1.learning_unit_year.acronym,
         self.proposal_1.learning_unit_year.complete_title,
         xls_build.translate(self.proposal_1.learning_unit_year.
                             learning_container_year.container_type),
         xls_build.translate(self.proposal_1.type),
         xls_build.translate(self.proposal_1.state), self.proposal_1.folder,
         xls_build.translate(
             self.proposal_1.learning_unit_year.learning_container_year.
             type_declaration_vacant),
         xls_build.translate(
             self.proposal_1.learning_unit_year.periodicity),
         self.proposal_1.learning_unit_year.credits,
         self.l_unit_yr_1.entities.get('ALLOCATION_ENTITY').acronym,
         self.proposal_1.date.strftime('%d-%m-%Y')
     ]
Ejemplo n.º 10
0
def extract_xls_data_from_proposal(proposal):
    return [
        get_entity_acronym(
            proposal.learning_unit_year.entities.get('REQUIREMENT_ENTITY')),
        proposal.learning_unit_year.acronym,
        proposal.learning_unit_year.complete_title,
        xls_build.translate(proposal.learning_unit_year.
                            learning_container_year.container_type),
        xls_build.translate(proposal.type),
        xls_build.translate(proposal.state), proposal.folder,
        xls_build.translate(proposal.learning_unit_year.
                            learning_container_year.type_declaration_vacant),
        xls_build.translate(proposal.learning_unit_year.periodicity),
        proposal.learning_unit_year.credits,
        get_entity_acronym(
            proposal.learning_unit_year.entities.get('ALLOCATION_ENTITY')),
        proposal.date.strftime('%d-%m-%Y')
    ]
Ejemplo n.º 11
0
 def get_xls_data(self, an_attribution, learning_unit_yr):
     return [learning_unit_yr.academic_year.name,
             learning_unit_yr.acronym,
             learning_unit_yr.complete_title,
             xls_build.translate(learning_unit_yr.learning_container_year.container_type),
             xls_build.translate(learning_unit_yr.subtype),
             ACRONYM_REQUIREMENT,
             ACRONYM_ALLOCATION,
             learning_unit_yr.credits,
             xls_build.translate(learning_unit_yr.status),
             an_attribution.get('person'),
             xls_build.translate((an_attribution.get('function'))),
             an_attribution.get('substitute'),
             an_attribution.get('LECTURING'),
             an_attribution.get('PRACTICAL_EXERCISES'),
             an_attribution.get('start_year'),
             an_attribution.get('duration')
             ]
Ejemplo n.º 12
0
 def test_prepare_xls_content_with_data(self):
     learning_unit_years = _get_learning_unit_yrs_on_2_different_years(
         self.previous_academic_year.year, [self.learning_unit_year_1])
     data_dict = prepare_xls_content(learning_unit_years)
     data = data_dict.get(DATA)
     self.assertEqual(len(data), 2)
     learning_unit_yr = self.previous_learning_unit_year
     self.assertEqual(data[0][0], learning_unit_yr.acronym)
     self.assertEqual(data[0][1], learning_unit_yr.academic_year.name)
     self.assertEqual(
         data[0][2],
         xls_build.translate(
             learning_unit_yr.learning_container_year.container_type))
     self.assertEqual(data[0][3],
                      _translate_status(learning_unit_yr.status))
     self.assertEqual(data[0][4],
                      xls_build.translate(learning_unit_yr.subtype))
     self.assertEqual(
         data[0][5],
         str(_(learning_unit_yr.internship_subtype))
         if learning_unit_yr.internship_subtype else '')
     self.assertEqual(data[0][6], learning_unit_yr.credits)
     self.assertEqual(
         data[0][7], learning_unit_yr.language.name
         if learning_unit_yr.language else '')
     self.assertEqual(
         data[0][8],
         str(_(learning_unit_yr.periodicity))
         if learning_unit_yr.periodicity else '')
     self.assertEqual(
         data[0][9],
         str(_(learning_unit_yr.quadrimester))
         if learning_unit_yr.quadrimester else '')
     self.assertEqual(
         data[0][10],
         str(_(learning_unit_yr.session))
         if learning_unit_yr.session else '')
     self.assertEqual(data[0][11],
                      learning_unit_yr.learning_container_year.common_title)
     self.assertEqual(data[0][12], learning_unit_yr.specific_title)
     self.assertEqual(
         data[0][13],
         learning_unit_yr.learning_container_year.common_title_english)
     self.assertEqual(data[0][14], learning_unit_yr.specific_title_english)
Ejemplo n.º 13
0
def _get_data_part1(learning_unit_yr):
    proposal = mdl_base.proposal_learning_unit.find_by_learning_unit_year(
        learning_unit_yr)
    lu_data_part1 = [
        learning_unit_yr.acronym,
        learning_unit_yr.academic_year.name,
        learning_unit_yr.complete_title,
        xls_build.translate(
            learning_unit_yr.learning_container_year.container_type)
        # FIXME Condition to remove when the LearningUnitYear.learning_continer_year_id will be null=false
        if learning_unit_yr.learning_container_year else "",
        xls_build.translate(learning_unit_yr.subtype),
        _get_entity_faculty_acronym(
            learning_unit_yr.entities.get('REQUIREMENT_ENTITY'),
            learning_unit_yr.academic_year),
        xls_build.translate(proposal.type) if proposal else '',
        xls_build.translate(proposal.state) if proposal else '',
        learning_unit_yr.credits,
        get_entity_acronym(learning_unit_yr.entities.get('ALLOCATION_ENTITY')),
        learning_unit_yr.complete_title_english,
    ]
    return lu_data_part1
Ejemplo n.º 14
0
def prepare_xls_content(found_learning_units):
    res = []
    for learning_unit_yr in found_learning_units:
        for key, value in learning_unit_yr.attribution_charge_news.items():
            line_by_attribution = extract_xls_data_from_learning_unit(learning_unit_yr)
            line_by_attribution.append(value.get('person'))
            line_by_attribution.append(xls_build.translate(value.get('function')))
            line_by_attribution.append(value.get('substitute'))
            line_by_attribution.append(value.get('LECTURING'))
            line_by_attribution.append(value.get('PRACTICAL_EXERCISES'))
            line_by_attribution.append(value.get('start_year'))
            line_by_attribution.append(value.get('duration'))
            res.append(line_by_attribution)
    return res
Ejemplo n.º 15
0
    def test_get_data_part2(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,
            periodicity=learning_unit_year_periodicity.ANNUAL,
            status=True,
            language=None,
        )

        component_lecturing = 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)
        component_practical = LearningComponentYearFactory(
            learning_container_year=learning_container_luy,
            type=learning_component_year_type.PRACTICAL_EXERCISES,
            hourly_volume_total_annual=15,
            hourly_volume_partial_q1=10,
            hourly_volume_partial_q2=5,
            planned_classes=1)
        LearningUnitComponentFactory(
            learning_unit_year=luy,
            learning_component_year=component_lecturing)
        LearningUnitComponentFactory(
            learning_unit_year=luy,
            learning_component_year=component_practical)
        a_tutor = TutorFactory()

        an_attribution = AttributionNewFactory(tutor=a_tutor, start_year=2017)

        attribution_charge_new_lecturing = AttributionChargeNewFactory(
            learning_component_year=component_lecturing,
            attribution=an_attribution,
            allocation_charge=15.0)
        attribution_charge_new_practical = AttributionChargeNewFactory(
            learning_component_year=component_practical,
            attribution=an_attribution,
            allocation_charge=5.0)

        luy.attribution_charge_news = attribution_charge_new.find_attribution_charge_new_by_learning_unit_year(
            luy)
        expected_common = [
            xls_build.translate(luy.periodicity),
            xls_build.translate(luy.status),
            component_lecturing.hourly_volume_total_annual,
            component_lecturing.hourly_volume_partial_q1,
            component_lecturing.hourly_volume_partial_q2,
            component_lecturing.planned_classes,
            component_practical.hourly_volume_total_annual,
            component_practical.hourly_volume_partial_q1,
            component_practical.hourly_volume_partial_q2,
            component_practical.planned_classes,
            xls_build.translate(luy.quadrimester),
            xls_build.translate(luy.session), "", ''
        ]
        self.assertEqual(_get_data_part2(luy, False), expected_common)
        self.assertEqual(
            _get_data_part2(luy, True),
            expected_attribution_data(attribution_charge_new_lecturing,
                                      attribution_charge_new_practical,
                                      expected_common, luy))