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()) ]
def _get_data(learning_unit_yr, new_line, first_data, partims=True): organization = get_organization_from_learning_unit_year(learning_unit_yr) data = [ _get_acronym(learning_unit_yr, new_line, first_data), learning_unit_yr.academic_year.name, learning_unit_yr.learning_container_year.get_container_type_display() if learning_unit_yr.learning_container_year.container_type else EMPTY_VALUE, translate_status(learning_unit_yr.status), learning_unit_yr.get_subtype_display() if learning_unit_yr.subtype else EMPTY_VALUE, learning_unit_yr.get_internship_subtype_display() if learning_unit_yr.internship_subtype else EMPTY_VALUE, volume_format(learning_unit_yr.credits), learning_unit_yr.language.name if learning_unit_yr.language else EMPTY_VALUE, learning_unit_yr.get_periodicity_display() if learning_unit_yr.periodicity else EMPTY_VALUE, 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)), _('Yes') if learning_unit_yr.professional_integration else _('No'), organization.name if organization else EMPTY_VALUE, learning_unit_yr.campus if learning_unit_yr.campus else EMPTY_VALUE ] if partims: data.append(get_partims_as_str(learning_unit_yr.get_partims_related())) data.extend([ learning_unit_yr.learning_unit.faculty_remark, learning_unit_yr.learning_unit.other_remark, _('Yes') if learning_unit_yr.learning_container_year.team else _('No'), _('Yes') if learning_unit_yr.learning_container_year.is_vacant else _('No'), learning_unit_yr.learning_container_year. get_type_declaration_vacant_display(), learning_unit_yr.get_attribution_procedure_display(), ]) return data
def _get_data(learning_unit_yr, new_line, first_data, partims=True): organization = get_organization_from_learning_unit_year(learning_unit_yr) data = [ _get_acronym(learning_unit_yr, new_line, first_data), learning_unit_yr.academic_year.name, learning_unit_yr.learning_container_year.get_container_type_display() if learning_unit_yr.learning_container_year.container_type else EMPTY_VALUE, translate_status(learning_unit_yr.status), learning_unit_yr.get_subtype_display() if learning_unit_yr.subtype else EMPTY_VALUE, learning_unit_yr.get_internship_subtype_display() if learning_unit_yr.internship_subtype else EMPTY_VALUE, volume_format(learning_unit_yr.credits), learning_unit_yr.language.name if learning_unit_yr.language else EMPTY_VALUE, learning_unit_yr.get_periodicity_display() if learning_unit_yr.periodicity else EMPTY_VALUE, 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)), _('Yes') if learning_unit_yr.professional_integration else _('No'), organization.name if organization else EMPTY_VALUE, learning_unit_yr.campus if learning_unit_yr.campus else EMPTY_VALUE] if partims: data.append(get_partims_as_str(learning_unit_yr.get_partims_related())) data.extend( [ learning_unit_yr.learning_unit.faculty_remark, learning_unit_yr.learning_unit.other_remark, _('Yes') if learning_unit_yr.learning_container_year.team else _('No'), _('Yes') if learning_unit_yr.learning_container_year.is_vacant else _('No'), learning_unit_yr.learning_container_year.get_type_declaration_vacant_display(), learning_unit_yr.get_attribution_procedure_display(), ] ) return data
def learning_unit_comparison(request, learning_unit_year_id): learning_unit_yr = get_object_or_404( mdl.learning_unit_year.LearningUnitYear.objects.all().select_related( 'learning_unit', 'learning_container_year'), pk=learning_unit_year_id) context = get_learning_unit_comparison_context(learning_unit_yr) previous_academic_yr = mdl.academic_year.find_academic_year_by_year( learning_unit_yr.academic_year.year - 1) previous_lu = _get_learning_unit_year(previous_academic_yr, learning_unit_yr) previous_values = compare_learning_unit_years(learning_unit_yr, previous_lu) previous_lcy_values = compare_learning_container_years( learning_unit_yr.learning_container_year, previous_lu.learning_container_year) next_academic_yr = mdl.academic_year.find_academic_year_by_year( learning_unit_yr.academic_year.year + 1) next_lu = _get_learning_unit_year(next_academic_yr, learning_unit_yr) next_values = compare_learning_unit_years(learning_unit_yr, next_lu) next_lcy_values = compare_learning_container_years( learning_unit_yr.learning_container_year, next_lu.learning_container_year) previous_context = get_learning_unit_comparison_context(previous_lu) next_context = get_learning_unit_comparison_context(next_lu) if _has_changed(context, next_context, previous_context, 'learning_container_year_partims'): context.update({ 'partims': { 'prev': get_partims_as_str( previous_context.get('learning_container_year_partims')), 'current': get_partims_as_str( context.get('learning_container_year_partims')), 'next': get_partims_as_str( next_context.get('learning_container_year_partims')) } }) context.update({ 'previous_values': previous_values, 'previous_academic_yr': previous_academic_yr, 'next_academic_yr': next_academic_yr, 'next_values': next_values, 'fields': get_keys(list(previous_values.keys()), list(next_values.keys())), 'entity_changes': _get_changed_organization(context, previous_context, next_context), 'fields_lcy': get_keys(list(previous_lcy_values.keys()), list(next_lcy_values.keys())), 'previous_lcy_values': previous_lcy_values, 'next_lcy_values': next_lcy_values, 'components_comparison': get_components_changes(previous_context['components'], context['components'], next_context['components']) }) return layout.render(request, "learning_unit/comparison.html", context)
def learning_unit_comparison(request, learning_unit_year_id): learning_unit_yr = get_object_or_404( mdl.learning_unit_year.LearningUnitYear.objects.all().select_related( 'learning_unit', 'learning_container_year'), pk=learning_unit_year_id) context = get_learning_unit_comparison_context(learning_unit_yr) previous_academic_yr = mdl.academic_year.find_academic_year_by_year( learning_unit_yr.academic_year.year - 1) previous_lu = _get_learning_unit_year(previous_academic_yr, learning_unit_yr) if previous_lu: previous_values = compare_learning_unit_years(learning_unit_yr, previous_lu) previous_lcy_values = compare_learning_container_years( learning_unit_yr.learning_container_year, previous_lu.learning_container_year) previous_context = get_learning_unit_comparison_context(previous_lu) else: previous_values, previous_lcy_values, previous_context = {}, {}, {} next_academic_yr = mdl.academic_year.find_academic_year_by_year( learning_unit_yr.academic_year.year + 1) next_lu = _get_learning_unit_year(next_academic_yr, learning_unit_yr) if next_lu: next_values = compare_learning_unit_years(learning_unit_yr, next_lu) next_lcy_values = compare_learning_container_years( learning_unit_yr.learning_container_year, next_lu.learning_container_year) next_context = get_learning_unit_comparison_context(next_lu) else: next_values, next_lcy_values, next_context = {}, {}, {} if (previous_lu or next_lu) and \ _has_changed(context, next_context, previous_context, 'learning_container_year_partims'): context.update({ 'partims': { 'prev': get_partims_as_str( previous_context.get('learning_container_year_partims', {})), 'current': get_partims_as_str( context.get('learning_container_year_partims')), 'next': get_partims_as_str( next_context.get('learning_container_year_partims', {})), } }) context.update({ 'previous_values': previous_values, 'previous_academic_yr': previous_academic_yr, 'next_academic_yr': next_academic_yr, 'next_values': next_values, 'fields': get_keys(list(previous_values.keys()), list(next_values.keys())), 'entity_changes': _get_changed_organization(context, previous_context, next_context), 'fields_lcy': get_keys(list(previous_lcy_values.keys()), list(next_lcy_values.keys())), 'previous_lcy_values': previous_lcy_values, 'next_lcy_values': next_lcy_values, 'components_comparison': get_components_changes(previous_context.get('components', {}), context.get('components', {}), next_context.get('components', {})), 'previous_lu': previous_lu, 'next_lu': next_lu, }) _add_warnings_for_inexisting_luy(request, next_academic_yr, next_lu) _add_warnings_for_inexisting_luy(request, previous_academic_yr, previous_lu) return render(request, "learning_unit/comparison.html", context) else: display_error_messages( request, _('Comparison impossible! No learning unit to compare to')) return HttpResponseRedirect( reverse('learning_unit', args=[learning_unit_year_id]))