def overview(request, global_id=None): tutor = mdl_base.tutor.find_by_user(request.user) if not global_id else \ mdl_base.tutor.find_by_person_global_id(global_id) # Applications for next year application_year = tutor_application.get_application_year() applications = tutor_application.get_application_list( global_id=tutor.person.global_id) # Attributions for next year attributions = attribution.get_attribution_list( global_id=tutor.person.global_id, academic_year=application_year) volume_total_attributions = attribution.get_volumes_total(attributions) # Attribution which will be expire this academic year current_academic_year = mdl_base.academic_year.current_academic_year() attributions_about_to_expired = attribution.get_attribution_list_about_to_expire( global_id=tutor.person.global_id, academic_year=current_academic_year) for attrib in attributions: attrib['teachers'] = attribution.get_teachers(attrib['acronym'], application_year.year) for an_attribution in attributions: attribution.update_learning_unit_volume(an_attribution, application_year) if attributions_about_to_expired: for an_attribution in attributions_about_to_expired: attribution.update_learning_unit_volume(an_attribution, application_year) return layout.render( request, "attribution_overview.html", { 'a_tutor': tutor, 'attributions': attributions, 'current_academic_year': current_academic_year, 'attributions_about_to_expire': attributions_about_to_expired, 'application_year': application_year, 'applications': applications, 'tot_lecturing': volume_total_attributions.get( learning_component_year_type.LECTURING), 'tot_practical': volume_total_attributions.get( learning_component_year_type.PRACTICAL_EXERCISES), 'application_academic_calendar': mdl_base.academic_calendar.get_by_reference_and_academic_year( academic_calendar_type.TEACHING_CHARGE_APPLICATION, current_academic_year), 'catalog_url': settings.ATTRIBUTION_CONFIG.get('CATALOG_URL') })
def test_computes_volumes_total(self): attribution_list = attribution.get_attribution_list( self.person.global_id, self.current_academic_year) volumes_total = attribution.get_volumes_total(attribution_list) self.assertTrue(volumes_total) self.assertEqual( volumes_total.get(learning_component_year_type.LECTURING), Decimal(53.5)) self.assertEqual( volumes_total.get( learning_component_year_type.PRACTICAL_EXERCISES), Decimal(21.5))