コード例 #1
0
ファイル: learning_unit.py プロジェクト: neamatKhan/osis
def learning_unit_identification(request, learning_unit_year_id):
    person = get_object_or_404(Person, user=request.user)
    context = get_common_context_learning_unit_year(learning_unit_year_id)
    learning_unit_year = context['learning_unit_year']
    context[
        'learning_container_year_partims'] = learning_unit_year.get_partims_related(
        )
    context['organization'] = get_organization_from_learning_unit_year(
        learning_unit_year)
    context['campus'] = get_campus_from_learning_unit_year(learning_unit_year)
    context['experimental_phase'] = True
    context['show_subtype'] = show_subtype(learning_unit_year)
    context.update(get_all_attributions(learning_unit_year))
    context['components'] = get_components_identification(learning_unit_year)
    context[
        'can_propose'] = learning_unit_proposal.is_eligible_for_modification_proposal(
            learning_unit_year, person)
    context['proposal'] = proposal_learning_unit.find_by_learning_unit_year(
        learning_unit_year)
    context['proposal_folder_entity_version'] = \
        entity_version.get_by_entity_and_date(context['proposal'].folder.entity, None) if context['proposal'] else None
    context[
        'can_delete'] = learning_unit_deletion.can_delete_learning_unit_year(
            person, learning_unit_year)

    return layout.render(request, "learning_unit/identification.html", context)
コード例 #2
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())
    ]
コード例 #3
0
ファイル: xls_comparison.py プロジェクト: aelwhishi/osis
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
コード例 #4
0
ファイル: xls_comparison.py プロジェクト: uclouvain/osis
def _get_data_from_initial_data(initial_data):
    learning_unit_yr = get_by_id(initial_data.get('learning_unit_year')['id'])
    requirement_entity = find_by_id(initial_data.get('entities')['REQUIREMENT_ENTITY'])
    allocation_entity = find_by_id(initial_data.get('entities')['ALLOCATION_ENTITY'])
    add1_requirement_entity = find_by_id(initial_data.get('entities')['ADDITIONAL_REQUIREMENT_ENTITY_1'])
    add2_requirement_entity = find_by_id(initial_data.get('entities')['ADDITIONAL_REQUIREMENT_ENTITY_2'])
    campus = find_campus_by_id(initial_data.get('learning_unit_year')['campus'])

    organization = get_organization_from_learning_unit_year(learning_unit_yr)
    language = find_language_by_id(initial_data.get('learning_unit_year')['language'])
    lu_initial = initial_data.get('learning_unit', None)
    luy_initial = initial_data.get('learning_unit_year', None)
    lcy_initial = initial_data.get('learning_container_year', None)

    data = [
        str(_('Initial data')),
        luy_initial['acronym'],
        learning_unit_yr.academic_year.name,
        dict(LearningContainerYearType.choices())[lcy_initial['container_type']] if
        lcy_initial['container_type'] else '-',
        translate_status(luy_initial['status']),
        learning_unit_yr.get_subtype_display(),
        get_translation(luy_initial['internship_subtype']),
        volume_format(luy_initial['credits']),
        language.name if language else EMPTY_VALUE,
        dict(PERIODICITY_TYPES)[luy_initial['periodicity']] if luy_initial['periodicity'] else BLANK_VALUE,
        get_translation(luy_initial['quadrimester']),
        get_translation(luy_initial['session']),
        get_representing_string(lcy_initial['common_title']),
        get_representing_string(luy_initial['specific_title']),
        get_representing_string(lcy_initial['common_title_english']),
        get_representing_string(luy_initial['specific_title_english']),
        requirement_entity.most_recent_acronym if requirement_entity else BLANK_VALUE,
        allocation_entity.most_recent_acronym if allocation_entity else BLANK_VALUE,
        add1_requirement_entity.most_recent_acronym if add1_requirement_entity else BLANK_VALUE,
        add2_requirement_entity.most_recent_acronym if add2_requirement_entity else BLANK_VALUE,
        _('Yes') if luy_initial['professional_integration'] else _('No'),
        organization.name if organization else BLANK_VALUE,
        campus if campus else BLANK_VALUE,
        get_representing_string(lu_initial['faculty_remark']),
        get_representing_string(lu_initial['other_remark']),
        _('Yes') if lcy_initial.get('team') else _('No'),
        _('Yes') if lcy_initial.get('is_vacant') else _('No'),
        dict(vacant_declaration_type.DECLARATION_TYPE)[lcy_initial.get('type_declaration_vacant')] if lcy_initial.get(
            'type_declaration_vacant') else BLANK_VALUE,
        dict(attribution_procedure.ATTRIBUTION_PROCEDURES)[luy_initial.get('attribution_procedure')] if luy_initial.get(
            'attribution_procedure') else BLANK_VALUE,
    ]
    return _get_data_from_components_initial_data(data, initial_data)
コード例 #5
0
ファイル: common.py プロジェクト: kelvinninja1/osis
def get_learning_unit_identification_context(learning_unit_year_id, person):
    context = get_common_context_learning_unit_year(learning_unit_year_id,
                                                    person)

    learning_unit_year = context['learning_unit_year']
    context['warnings'] = learning_unit_year.warnings
    proposal = proposal_learning_unit.find_by_learning_unit(
        learning_unit_year.learning_unit)

    context["can_create_partim"] = is_eligible_to_create_partim(
        learning_unit_year, person)
    context[
        'learning_container_year_partims'] = learning_unit_year.get_partims_related(
        )
    context['organization'] = get_organization_from_learning_unit_year(
        learning_unit_year)
    context['campus'] = learning_unit_year.campus
    context['experimental_phase'] = True
    context.update(get_all_attributions(learning_unit_year))
    components = get_components_identification(learning_unit_year)
    context['components'] = components.get('components')
    context['REQUIREMENT_ENTITY'] = components.get('REQUIREMENT_ENTITY')
    context['ADDITIONAL_REQUIREMENT_ENTITY_1'] = components.get(
        'ADDITIONAL_REQUIREMENT_ENTITY_1')
    context['ADDITIONAL_REQUIREMENT_ENTITY_2'] = components.get(
        'ADDITIONAL_REQUIREMENT_ENTITY_2')
    context['proposal'] = proposal
    context[
        'proposal_folder_entity_version'] = mdl.entity_version.get_by_entity_and_date(
            proposal.entity, None) if proposal else None
    context['differences'] = get_difference_of_proposal(proposal, learning_unit_year) \
        if proposal and proposal.learning_unit_year == learning_unit_year \
        else {}

    # append permissions
    context.update(learning_unit_year_permissions(learning_unit_year, person))
    context.update(
        learning_unit_proposal_permissions(proposal, person,
                                           learning_unit_year))
    context['can_manage_volume'] = is_eligible_for_modification(
        context["learning_unit_year"], person)

    return context
コード例 #6
0
ファイル: xls_comparison.py プロジェクト: uclouvain/osis
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
コード例 #7
0
def get_learning_unit_identification_context(learning_unit_year_id, person):
    context = get_common_context_learning_unit_year(learning_unit_year_id,
                                                    person)

    learning_unit_year = context['learning_unit_year']
    proposal = proposal_learning_unit.find_by_learning_unit_year(
        learning_unit_year)

    context[
        'learning_container_year_partims'] = learning_unit_year.get_partims_related(
        )
    context['organization'] = get_organization_from_learning_unit_year(
        learning_unit_year)
    context['campus'] = get_campus_from_learning_unit_year(learning_unit_year)
    context['experimental_phase'] = True
    context['show_subtype'] = show_subtype(learning_unit_year)
    context.update(get_all_attributions(learning_unit_year))
    context['components'] = get_components_identification(learning_unit_year)
    context['proposal'] = proposal
    context[
        'proposal_folder_entity_version'] = mdl_base.entity_version.get_by_entity_and_date(
            proposal.folder.entity, None) if proposal else None
    context['differences'] = _get_difference_of_proposal(proposal)

    # perms learning unit
    context['can_propose'] = is_eligible_to_create_modification_proposal(
        learning_unit_year, person)
    context['can_edit_date'] = is_eligible_for_modification_end_date(
        learning_unit_year, person)
    context['can_edit'] = is_eligible_for_modification(learning_unit_year,
                                                       person)
    context['can_delete'] = can_delete_learning_unit_year(
        learning_unit_year, person)

    # perms proposal
    context['can_cancel_proposal'] = is_eligible_for_cancel_of_proposal(
        proposal, person)
    context['can_edit_learning_unit_proposal'] = is_eligible_to_edit_proposal(
        proposal, person)

    return context
コード例 #8
0
ファイル: xls_comparison.py プロジェクト: aelwhishi/osis
def _get_data_from_initial_data(initial_data):
    learning_unit_yr = get_by_id(initial_data.get('learning_unit_year')['id'])
    requirement_entity = find_by_id(
        initial_data.get('entities')['REQUIREMENT_ENTITY'])
    allocation_entity = find_by_id(
        initial_data.get('entities')['ALLOCATION_ENTITY'])
    add1_requirement_entity = find_by_id(
        initial_data.get('entities')['ADDITIONAL_REQUIREMENT_ENTITY_1'])
    add2_requirement_entity = find_by_id(
        initial_data.get('entities')['ADDITIONAL_REQUIREMENT_ENTITY_2'])
    campus = find_campus_by_id(
        initial_data.get('learning_unit_year')['campus'])

    organization = get_organization_from_learning_unit_year(learning_unit_yr)
    language = find_language_by_id(
        initial_data.get('learning_unit_year')['language'])
    lu_initial = initial_data.get('learning_unit', None)
    luy_initial = initial_data.get('learning_unit_year', None)
    lcy_initial = initial_data.get('learning_container_year', None)

    data = [
        str(_('Initial data')),
        luy_initial['acronym'],
        learning_unit_yr.academic_year.name,
        dict(
            LearningContainerYearType.choices())[lcy_initial['container_type']]
        if lcy_initial['container_type'] else '-',
        translate_status(luy_initial['status']),
        learning_unit_yr.get_subtype_display(),
        get_translation(luy_initial['internship_subtype']),
        volume_format(luy_initial['credits']),
        language.name if language else EMPTY_VALUE,
        dict(PERIODICITY_TYPES)[luy_initial['periodicity']]
        if luy_initial['periodicity'] else BLANK_VALUE,
        get_translation(luy_initial['quadrimester']),
        get_translation(luy_initial['session']),
        get_representing_string(lcy_initial['common_title']),
        get_representing_string(luy_initial['specific_title']),
        get_representing_string(lcy_initial['common_title_english']),
        get_representing_string(luy_initial['specific_title_english']),
        requirement_entity.most_recent_acronym
        if requirement_entity else BLANK_VALUE,
        allocation_entity.most_recent_acronym
        if allocation_entity else BLANK_VALUE,
        add1_requirement_entity.most_recent_acronym
        if add1_requirement_entity else BLANK_VALUE,
        add2_requirement_entity.most_recent_acronym
        if add2_requirement_entity else BLANK_VALUE,
        _('Yes') if luy_initial['professional_integration'] else _('No'),
        organization.name if organization else BLANK_VALUE,
        campus if campus else BLANK_VALUE,
        get_representing_string(lu_initial['faculty_remark']),
        get_representing_string(lu_initial['other_remark']),
        _('Yes') if lcy_initial.get('team') else _('No'),
        _('Yes') if lcy_initial.get('is_vacant') else _('No'),
        dict(vacant_declaration_type.DECLARATION_TYPE)[lcy_initial.get(
            'type_declaration_vacant')]
        if lcy_initial.get('type_declaration_vacant') else BLANK_VALUE,
        dict(attribution_procedure.ATTRIBUTION_PROCEDURES)[luy_initial.get(
            'attribution_procedure')]
        if luy_initial.get('attribution_procedure') else BLANK_VALUE,
    ]
    return _get_data_from_components_initial_data(data, initial_data)
コード例 #9
0
def _get_data_from_initial_data(initial_data, proposal_comparison=False):
    luy_initial = initial_data.get('learning_unit_year', {})
    lcy_initial = initial_data.get('learning_container_year', {})
    lu_initial = initial_data.get('learning_unit', {})

    if luy_initial.get('id'):
        learning_unit_yr = get_by_id(luy_initial.get('id'))
    else:
        learning_unit_yr = None

    requirement_entity = find_by_id(lcy_initial.get('requirement_entity'))
    allocation_entity = find_by_id(lcy_initial.get('allocation_entity'))
    add1_requirement_entity = find_by_id(lcy_initial.get('additional_entity_1'))
    add2_requirement_entity = find_by_id(lcy_initial.get('additional_entity_2'))
    campus = find_campus_by_id(luy_initial.get('campus'))

    organization = None
    if learning_unit_yr:
        organization = get_organization_from_learning_unit_year(learning_unit_yr)
    language = find_language_by_id(luy_initial.get('language'))

    if proposal_comparison:
        academic_year = _format_academic_year(learning_unit_yr.academic_year.name,
                                              find_academic_year_by_id(lu_initial.get('end_year'))
                                              if lu_initial.get('end_year') else None)
    else:
        academic_year = learning_unit_yr.academic_year.name

    data = [
        str(_('Initial data')),
        luy_initial.get('acronym', ''),
        academic_year,
        dict(LearningContainerYearType.choices())[lcy_initial.get('container_type')] if
        lcy_initial.get('container_type') else BLANK_VALUE,
        translate_status(luy_initial.get('status')),
        learning_unit_yr.get_subtype_display()
        if learning_unit_yr and learning_unit_yr.get_subtype_display() else BLANK_VALUE,
        get_translation(luy_initial.get('internship_subtype')),
        volume_format(Decimal(luy_initial['credits'])) if luy_initial.get('credits') else BLANK_VALUE,
        language.name if language else BLANK_VALUE,
        dict(PERIODICITY_TYPES)[luy_initial['periodicity']] if luy_initial.get('periodicity') else BLANK_VALUE,
        get_translation(luy_initial.get('quadrimester')),
        get_translation(luy_initial.get('session')),
        get_representing_string(lcy_initial.get('common_title')),
        get_representing_string(luy_initial.get('specific_title')),
        get_representing_string(lcy_initial.get('common_title_english')),
        get_representing_string(luy_initial.get('specific_title_english')),
        requirement_entity.most_recent_acronym if requirement_entity else BLANK_VALUE,
        allocation_entity.most_recent_acronym if allocation_entity else BLANK_VALUE,
        add1_requirement_entity.most_recent_acronym if add1_requirement_entity else BLANK_VALUE,
        add2_requirement_entity.most_recent_acronym if add2_requirement_entity else BLANK_VALUE,
        _('Yes') if luy_initial.get('professional_integration') else _('No'),
        organization.name if organization else BLANK_VALUE,
        campus if campus else BLANK_VALUE,
        get_representing_string(lu_initial.get('faculty_remark')),
        get_representing_string(lu_initial.get('other_remark')),
        _('Yes') if lcy_initial.get('team') else _('No'),
        _('Yes') if lcy_initial.get('is_vacant') else _('No'),
        dict(vacant_declaration_type.DECLARATION_TYPE)[lcy_initial.get('type_declaration_vacant')] if lcy_initial.get(
            'type_declaration_vacant') else BLANK_VALUE,
        dict(attribution_procedure.ATTRIBUTION_PROCEDURES)[luy_initial.get('attribution_procedure')] if luy_initial.get(
            'attribution_procedure') else BLANK_VALUE,
    ]
    return _get_data_from_components_initial_data(data, initial_data)