def get_context_data(self, **kwargs): context = super(MandatesListView, self).get_context_data(**kwargs) phd_list = ['RESEARCH', 'SUPERVISION', 'VICE_RECTOR', 'DONE'] research_list = ['SUPERVISION', 'VICE_RECTOR', 'DONE'] supervision_list = ['VICE_RECTOR', 'DONE'] vice_rector_list = ['VICE_RECTOR', 'DONE'] current_reviewer = reviewer.find_by_person(self.request.user.person) can_delegate = reviewer.can_delegate(current_reviewer) context['can_delegate'] = can_delegate context['reviewer'] = current_reviewer entity = entity_version.get_last_version(current_reviewer.entity) context['entity'] = entity context['phd_list'] = phd_list context['research_list'] = research_list context['supervision_list'] = supervision_list context['vice_rector_list'] = vice_rector_list context['is_supervisor'] = self.is_supervisor context['filter'] = self.kwargs.get("filter", None) context['year'] = academic_year.find_academic_year_by_id( self.request.session.get('selected_academic_year')).year start_date = academic_year.find_academic_year_by_id( int(self.request.session.get('selected_academic_year'))).start_date for mandate in context['object_list']: entities = [] entities_id = mandate.mandateentity_set.all().order_by('id') for entity in entities_id: current_entityversion = entity_version.get_by_entity_and_date( entity.entity, start_date)[0] if current_entityversion is None: current_entityversion = entity_version.get_last_version( entity.entity) entities.append(current_entityversion) mandate.entities = entities return context
def get_context_data(self, **kwargs): context = super(AssistantsListView, self).get_context_data(**kwargs) context['year'] = academic_year.current_academic_year().year start_date = academic_year.current_academic_year().start_date context['is_reviewer'] = self.is_reviewer context['current_reviewer'] = self.reviewer if self.reviewer: entity = entity_version.get_last_version(self.reviewer.entity) else: entity = None context['entity'] = entity if self.is_reviewer: can_delegate = reviewer.can_delegate( reviewer.find_by_person(self.request.user.person)) context['can_delegate'] = can_delegate else: context['can_delegate'] = False for mandate in context['object_list']: entities = [] entities_id = mandate.mandateentity_set.all().order_by('id') for entity in entities_id: current_entityversion = entity_version.get_by_entity_and_date( entity.entity, start_date)[0] if current_entityversion is None: current_entityversion = entity_version.get_last_version( entity.entity) entities.append(current_entityversion) mandate.entities = entities return context
def __str__(self): version = entity_version.get_by_entity_and_date( self.entity, self.assistant_mandate.academic_year.start_date) if version is None: version = entity_version.get_last_version(self.entity) return u"%s - %s" % (self.assistant_mandate.assistant, version[0].acronym)
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 warnings(self): if self._warnings is None: self._warnings = [] if not entity_version.get_by_entity_and_date(self.entity, self.learning_container_year.academic_year.start_date): self._warnings.append(_("The linked %(entity)s does not exist at the start date of the academic year" " linked to this learning unit") % {'entity': _(self.type.lower())}) return self._warnings
def get_entities_for_mandate(mandate): entities = [] entities_id = mandate.mandateentity_set.all().order_by('id') for this_entity in entities_id: current_entity_versions = entity_version.get_by_entity_and_date( this_entity.entity, academic_year.starting_academic_year().start_date) current_entity_version = current_entity_versions[0] if current_entity_versions \ else entity_version.get_last_version(this_entity.entity) entities.append(current_entity_version) return entities
def post_clean(self, start_date): entity = self.cleaned_data.get('requesting_entity') if not entity: return True entity_v = entity_version.get_by_entity_and_date(entity, start_date) if not entity_v: self.add_error('requesting_entity', _("The linked entity does not exist at the start date of the " "academic year linked to this learning unit")) else: self.entity_version = entity_v return not self.errors
def _check_entity_version_exists(learning_container_year) -> list: warnings = [] for link_type, entity in learning_container_year.get_map_entity_by_type().items(): # Optional entities do not need warnings when they are empty. if not entity and link_type in [ADDITIONAL_REQUIREMENT_ENTITY_1, ADDITIONAL_REQUIREMENT_ENTITY_2]: continue link_type_translated = EntityContainerYearLinkTypes.get_value(link_type) if not entity_version.get_by_entity_and_date(entity, learning_container_year.academic_year.start_date): warnings.append( _("The linked %(entity)s does not exist at the start date of the academic year" " linked to this learning unit") % {'entity': link_type_translated} ) return warnings
def __str__(self): version = entity_version.get_by_entity_and_date(self.entity, self.assistant_mandate.academic_year.start_date) if version is None: version = entity_version.get_last_version(self.entity) return u"%s - %s" % (self.assistant_mandate.assistant, version[0].acronym)