def _get_filter_entity_management(requirement_entity_acronym, with_entity_subordinated): entity_ids = get_entities_ids(requirement_entity_acronym, with_entity_subordinated) return list( offer_year_entity.search(type=offer_year_entity_type.ENTITY_MANAGEMENT, entity=entity_ids).values_list( 'education_group_year', flat=True).distinct())
def get_object_list(self): clean_data = { key: value for key, value in self.cleaned_data.items() if value is not None } entity_versions_prefetch = models.Prefetch('entity__entityversion_set', to_attr='entity_versions') offer_year_entity_prefetch = models.Prefetch('offeryearentity_set', queryset=offer_year_entity.search(type=offer_year_entity_type.ENTITY_MANAGEMENT)\ .prefetch_related(entity_versions_prefetch), to_attr='offer_year_entities') if clean_data.get('requirement_entity_acronym'): clean_data['id'] = _get_filter_entity_management( clean_data['requirement_entity_acronym'], clean_data.get('with_entity_subordinated', False)) education_groups = education_group_year.search( **clean_data).prefetch_related(offer_year_entity_prefetch) return [ _append_entity_management(education_group) for education_group in education_groups ]
def get_object_list(self): clean_data = { key: value for key, value in self.cleaned_data.items() if value is not None } offer_year_entity_prefetch = models.Prefetch( 'offeryearentity_set', queryset=offer_year_entity.search(type=offer_year_entity_type.ENTITY_MANAGEMENT)\ .prefetch_related( models.Prefetch('entity__entityversion_set', to_attr='entity_versions') ), to_attr='offer_year_entities' ) if clean_data.get('entity_management'): clean_data['id'] = _get_filter_entity_management( clean_data['entity_management']) education_groups = education_group_year.search(**clean_data)[:MAX_RECORDS + 1]\ .prefetch_related(offer_year_entity_prefetch) return [ _append_entity_management(education_group) for education_group in education_groups ]
def find_from_offer_year(offer_year): return [ entity_version.get_last_version(off_year_entity.entity) for off_year_entity in offer_year_entity.search( offer_year=offer_year).distinct('entity') ]
def _get_filter_entity_management(entity_management): entity_ids = _get_entities_ids(entity_management) return list(offer_year_entity.search(link_type=offer_year_entity_type.ENTITY_MANAGEMENT, entity=entity_ids)\ .values_list('education_group_year', flat=True).distinct())
def find_from_offer_year(offer_year): return [entity_version.get_last_version(off_year_entity.entity) for off_year_entity in offer_year_entity.search(offer_year=offer_year).distinct('entity')]