Example #1
0
def _get_learning_unit_yrs_on_2_different_years(academic_yr_comparison,
                                                learning_unit_years):
    learning_unit_years = LearningUnitYear.objects.filter(
        learning_unit__in=(_get_learning_units(learning_unit_years)),
        academic_year__year__in=(
            learning_unit_years[0].academic_year.year,
            academic_yr_comparison)).select_related(
                'academic_year', 'learning_container_year',
                'learning_container_year__academic_year').prefetch_related(
                    get_learning_component_prefetch()).prefetch_related(
                        build_entity_container_prefetch(
                            entity_types.ALLOCATION_ENTITY),
                        build_entity_container_prefetch(
                            entity_types.REQUIREMENT_ENTITY),
                        build_entity_container_prefetch(
                            entity_types.ADDITIONAL_REQUIREMENT_ENTITY_1),
                        build_entity_container_prefetch(
                            entity_types.ADDITIONAL_REQUIREMENT_ENTITY_2),
                    ).order_by('learning_unit', 'academic_year__year')
    [
        append_latest_entities(learning_unit)
        for learning_unit in learning_unit_years
    ]
    [append_components(learning_unit) for learning_unit in learning_unit_years]
    return learning_unit_years
Example #2
0
def _get_learning_unit_yr_with_component(learning_unit_years):
    learning_unit_years = LearningUnitYear.objects.filter(
        learning_unit_year_id__in=[luy.id for luy in learning_unit_years]
    ).select_related(
        'academic_year', 'learning_container_year',
        'learning_container_year__academic_year').prefetch_related(
            get_learning_component_prefetch()).prefetch_related(
                build_entity_container_prefetch([
                    entity_types.ALLOCATION_ENTITY,
                    entity_types.REQUIREMENT_ENTITY,
                    entity_types.ADDITIONAL_REQUIREMENT_ENTITY_1,
                    entity_types.ADDITIONAL_REQUIREMENT_ENTITY_2
                ])).order_by('learning_unit', 'academic_year__year')
    [
        append_latest_entities(learning_unit)
        for learning_unit in learning_unit_years
    ]
    [append_components(learning_unit) for learning_unit in learning_unit_years]
    return learning_unit_years
Example #3
0
def _get_learning_unit_yr_with_component(learning_unit_years):
    learning_unit_years = LearningUnitYear.objects.filter(
        learning_unit_year_id__in=[luy.id for luy in learning_unit_years]
        ).select_related(
        'academic_year',
        'learning_container_year',
        'learning_container_year__academic_year'
    ).prefetch_related(
        get_learning_component_prefetch()
    ).prefetch_related(
        build_entity_container_prefetch([
            entity_types.ALLOCATION_ENTITY,
            entity_types.REQUIREMENT_ENTITY,
            entity_types.ADDITIONAL_REQUIREMENT_ENTITY_1,
            entity_types.ADDITIONAL_REQUIREMENT_ENTITY_2
        ])
    ).order_by('learning_unit', 'academic_year__year')
    [append_latest_entities(learning_unit) for learning_unit in learning_unit_years]
    [append_components(learning_unit) for learning_unit in learning_unit_years]
    return learning_unit_years
Example #4
0
def _get_learning_unit_yrs_on_2_different_years(academic_yr_comparison, learning_unit_years):
    learning_unit_years = LearningUnitYear.objects.filter(
        learning_unit__in=(_get_learning_units(learning_unit_years)),
        academic_year__year__in=(
            learning_unit_years[0].academic_year.year,
            academic_yr_comparison)
    ).select_related(
        'academic_year',
        'learning_container_year',
        'learning_container_year__academic_year'
    ).prefetch_related(
        get_learning_component_prefetch()
    ).prefetch_related(
        build_entity_container_prefetch([
            entity_types.ALLOCATION_ENTITY,
            entity_types.REQUIREMENT_ENTITY,
            entity_types.ADDITIONAL_REQUIREMENT_ENTITY_1,
            entity_types.ADDITIONAL_REQUIREMENT_ENTITY_2
        ])
    ).order_by('learning_unit', 'academic_year__year')
    [append_latest_entities(learning_unit) for learning_unit in learning_unit_years]
    [append_components(learning_unit) for learning_unit in learning_unit_years]
    return learning_unit_years