You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
2.1 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

from django.contrib.gis.geos.point import Point
from .repositories import LocationRepository, OrganizationRepository, CategoryRepository
MAPPING_DATA = {
'alpine_hut': 'Домики в горах',
'apartment': 'Апартаменты',
'aquarium': 'Океанариумы',
'artwork': 'Паблик-арты',
'attraction': 'Достопримечательности',
'camp_pitch': 'Места для палатки',
'camp_site': 'Кемпинги',
'caravan_site': 'Караванинги',
'chalet': 'Коттеджи',
'gallery': 'Художественные галереи',
'guest_house': 'Гостевые дома',
'hostel': 'Хостелы',
'hotel': 'Отели',
'information': 'Информационные центры',
'motel': 'Мотели',
'museum': 'Музеи',
'wilderness_hut': 'Лесные домики',
'zoo': 'Зоопарки',
'beach': 'Пляжи',
'fuel': 'Заправки',
'parking': 'Парковки',
'restaurant': 'Рестораны',
'picnic_site': 'Места для пикника',
'viewpoint': 'Смотровые площадки',
'shop': 'Магазины',
'winery': 'Винодельни',
'brewery': 'Пивоварни',
'bicycle_rental': 'Места с арендой велосипедов',
'theme_park': 'Парки аттракционов',
'farm': 'Фермы',
'trail_riding': 'Ранчо',
'charging_station': 'Зарядные станции'
}
def parse_organizations_to_db(data):
for k in data.keys():
for obj in data[k]:
OrganizationRepository.create(
location=LocationRepository.get_or_create(
coords=Point(float(obj['latitude']), float(obj['longitude'])),
address=obj['street'] + obj['housenumber']
),
name=obj['name'],
phone=obj['phone'],
website=obj['website'],
description=obj['description'],
category=CategoryRepository.get_by_name(MAPPING_DATA[obj['category']])
)