def learning_unit_proposal_comparison(request, learning_unit_year_id): learning_unit_year = get_object_or_404( LearningUnitYear.objects.all().select_related( 'learning_unit', 'learning_container_year', 'campus', 'campus__organization'), pk=learning_unit_year_id) initial_data = proposal_learning_unit.find_by_learning_unit_year( learning_unit_year).initial_data initial_learning_unit_year, learning_unit_year_fields = get_learning_unit_year_comparison_context( initial_data, learning_unit_year) components = get_components_identification(learning_unit_year) components_list = [] for component in components['components']: volumes = get_volumes_comparison_context(component, initial_data) components_list.append([ _get_value_from_enum(LEARNING_COMPONENT_YEAR_TYPES, component['learning_component_year'].type), volumes ]) context = { 'learning_unit_year': learning_unit_year, 'learning_container_year_fields': get_learning_container_year_comparison_context( initial_data, learning_unit_year ), 'campus': [ learning_unit_year._meta.get_field('campus').verbose_name, initial_learning_unit_year.campus.name, learning_unit_year.campus.name] \ if initial_learning_unit_year.campus.name != learning_unit_year.campus.name else [], 'entities_fields': get_all_entities_comparison_context(initial_data, learning_unit_year), 'learning_unit_year_fields': learning_unit_year_fields, 'components': components_list } return render(request, "learning_unit/proposal_comparison.html", context)
def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['current_academic_year'] = self.current_academic_year context['is_person_linked_to_entity'] = self.person.is_linked_to_entity_in_charge_of_learning_unit_year( self.object ) context['warnings'] = self.object.warnings context['learning_container_year_partims'] = self.object.get_partims_related() context.update(get_all_attributions(self.object)) components = get_components_identification(self.object) 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') proposal = get_object_or_none(ProposalLearningUnit, learning_unit_year__learning_unit=self.object.learning_unit) context['proposal'] = proposal context['proposal_folder_entity_version'] = get_by_entity_and_date( proposal.entity, None) if proposal else None context['differences'] = get_difference_of_proposal(proposal, self.object) \ if proposal and proposal.learning_unit_year == self.object else {} context.update(self.get_context_permission(proposal)) context["versions"] = self.get_versions() context["has_partim"] = self.object.get_partims_related().exists() return context
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)
def get_full_context(learning_unit_year): context = {'learning_unit_year': learning_unit_year} initial_data = None components_list = {} if proposal_learning_unit.is_learning_unit_year_in_proposal( learning_unit_year): initial_data = reinitialize_learning_unit_year(components_list, context, initial_data, learning_unit_year) context['learning_unit_year_fields'] = get_learning_unit_context( learning_unit_year) context[ 'learning_container_year_fields'] = get_learning_container_year_context( learning_unit_year) context['campus'] = learning_unit_year.campus.name context['learning_container_year_partims'] = [ partim.subdivision for partim in learning_unit_year.get_partims_related() ] context['entities_fields'] = get_entities_context(initial_data, learning_unit_year) if 'components' not in context: components = get_components_identification(learning_unit_year) get_component_values(components, components_list) context['components'] = components_list return context
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
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
def get_full_context(learning_unit_year): context = {'learning_unit_year': learning_unit_year} initial_data = None components_list = {} if proposal_learning_unit.is_learning_unit_year_in_proposal( learning_unit_year): initial_data = reinitialize_learning_unit_year(components_list, context, initial_data, learning_unit_year) context['learning_unit_year_fields'] = get_learning_unit_context( learning_unit_year) context[ 'learning_container_year_fields'] = get_learning_container_year_context( learning_unit_year) context['campus'] = learning_unit_year.campus.name context['learning_container_year_partims'] = [ partim.subdivision for partim in learning_unit_year.get_partims_related() ] context['entities_fields'] = get_entities_context(initial_data, learning_unit_year) if 'components' not in context: components = get_components_identification(learning_unit_year) for component in components['components']: volumes = { _('Volume total annual'): component['volumes']['VOLUME_TOTAL'] or 0, _('Planned classes'): component['volumes']['PLANNED_CLASSES'] or 0, _('Volume Q1'): component['volumes']['VOLUME_Q1'] or 0, _('Volume Q2'): component['volumes']['VOLUME_Q2'] or 0 } components_list[_get_value_from_enum( LEARNING_COMPONENT_YEAR_TYPES, component['learning_component_year'].type)] = volumes context['components'] = components_list return context