def search_vacant_attribution(request): tutor = mdl_base.tutor.find_by_user(request.user) attributions_vacant = None form = VacantAttributionFilterForm(data=request.GET) if form.is_valid(): application_academic_year = tutor_application.get_application_year() attributions_vacant = attribution.get_attribution_vacant_list( acronym_filter=form.cleaned_data['learning_container_acronym'], academic_year=application_academic_year) attributions_vacant = tutor_application.mark_attribution_already_applied( attributions_vacant, tutor.person.global_id, application_academic_year) if attributions_vacant: for an_attribution in attributions_vacant: attribution.update_learning_unit_volume( an_attribution, application_academic_year) for attrib in attributions_vacant: attrib['teachers'] = attribution.get_teachers( attrib['acronym'], application_academic_year.year) return layout.render( request, "attribution_vacant_list.html", { 'a_tutor': tutor, 'attributions_vacant': attributions_vacant, 'search_form': form })
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 _get_attributions_vacant(form, tutor): application_academic_year = tutor_application.get_application_year() attributions_vacant = attribution.get_attribution_vacant_list( acronym_filter=form.cleaned_data['learning_container_acronym'], academic_year=application_academic_year, faculty=form.cleaned_data['faculty'], ) attributions_vacant = tutor_application.mark_attribution_already_applied( attributions_vacant, tutor.person.global_id, application_academic_year ) if attributions_vacant: for an_attribution in attributions_vacant: attribution.update_learning_unit_volume(an_attribution, application_academic_year) for attrib in attributions_vacant: attrib['teachers'] = attribution.get_teachers(attrib['acronym'], application_academic_year.year) return attributions_vacant
def test_update_learning_unit_volume_no_components(self): """When no components found on database, the key 'lecturing_vol' / 'practical_exercises_vol' is set to 0.0""" l_container = LearningContainerYearFactory( acronym='LAGRO1530', academic_year=self.current_academic_year) LearningUnitYearFactory(acronym='LAGRO1530', academic_year=self.current_academic_year, learning_container_year=l_container) an_attribution = { 'year': 2017, 'acronym': 'LAGRO1530', 'title': 'Chimie complexe', 'weight': '5.00', 'LECTURING': '22.5', 'PRACTICAL_EXERCISES': '5.0', 'function': 'HOLDER', 'start_year': 2015, 'end_year': 2020 } attribution.update_learning_unit_volume(an_attribution, self.current_academic_year) self.assertEqual(an_attribution['lecturing_vol'], Decimal(0.0)) self.assertEqual(an_attribution['practical_exercises_vol'], Decimal(0.0))