def _get_entity_types(self): entity_types = {} for stop_type in self.entity_type_definitions: et = self.entity_type_definitions[stop_type] try: entity_type = EntityType.objects.get(slug=et['slug']) except EntityType.DoesNotExist: entity_type = EntityType(slug=et['slug']) entity_type.uri = "http://mollyproject.org/schema/maps#%s" % et['uri-local'] entity_type.article = et['article'] entity_type.verbose_name = et['verbose-name'] entity_type.verbose_name_plural = et['verbose-name-plural'] entity_type.show_in_nearby_list = et['nearby'] entity_type.show_in_category_list = et['category'] entity_type.save() entity_types[stop_type] = entity_type for entity_type in entity_types.values(): if entity_type.slug == 'public-transport-access-node': continue entity_type.subtype_of.add(entity_types[None]) return entity_types
def _get_entity_types(self): entity_types = {} category, created = EntityTypeCategory.objects.get_or_create( name=_('Transport')) category.save() for stop_type in self.entity_type_definitions: et = self.entity_type_definitions[stop_type] try: entity_type = EntityType.objects.get(slug=et['slug']) except EntityType.DoesNotExist: entity_type = EntityType(slug=et['slug']) entity_type.category = category entity_type.uri = "http://mollyproject.org/schema/maps#%s" % et[ 'uri-local'] if created: entity_type.show_in_nearby_list = et['nearby'] entity_type.show_in_category_list = et['category'] entity_type.save() for lang_code, lang_name in settings.LANGUAGES: with override(lang_code): set_name_in_language(entity_type, lang_code, verbose_name=ugettext( et['verbose-name']), verbose_name_singular=ugettext( et['verbose-name-singular']), verbose_name_plural=ugettext( et['verbose-name-plural'])) entity_types[stop_type] = entity_type for stop_type, entity_type in entity_types.items(): if entity_type.slug == 'public-transport-access-node': continue entity_type.subtype_of.add(entity_types[None]) if stop_type.startswith( 'MET' ) and stop_type != 'MET' and entity_type.slug != self.RAIL_STATION_DEFINITION[ 'slug']: entity_type.subtype_of.add(entity_types['MET']) return entity_types
def _get_entity_types(self): entity_types = {} category, created = EntityTypeCategory.objects.get_or_create(name=_('Transport')) category.save() for stop_type in self.entity_type_definitions: et = self.entity_type_definitions[stop_type] try: entity_type = EntityType.objects.get(slug=et['slug']) except EntityType.DoesNotExist: entity_type = EntityType(slug=et['slug']) entity_type.category = category entity_type.uri = "http://mollyproject.org/schema/maps#%s" % et['uri-local'] if created: entity_type.show_in_nearby_list = et['nearby'] entity_type.show_in_category_list = et['category'] entity_type.save() for lang_code, lang_name in settings.LANGUAGES: with override(lang_code): set_name_in_language(entity_type, lang_code, verbose_name=ugettext(et['verbose-name']), verbose_name_singular=ugettext(et['verbose-name-singular']), verbose_name_plural=ugettext(et['verbose-name-plural'])) entity_types[stop_type] = entity_type for stop_type, entity_type in entity_types.items(): if entity_type.slug == 'public-transport-access-node': continue entity_type.subtype_of.add(entity_types[None]) if stop_type.startswith('MET') and stop_type != 'MET' and entity_type.slug != self.RAIL_STATION_DEFINITION['slug']: entity_type.subtype_of.add(entity_types['MET']) return entity_types