2023-05-23 18:14:06 +03:00
|
|
|
|
import json
|
|
|
|
|
from pprint import pprint
|
|
|
|
|
|
2023-05-23 23:36:45 +03:00
|
|
|
|
from passfinder.events.models import Region, Event
|
2023-05-23 18:14:06 +03:00
|
|
|
|
|
|
|
|
|
with open("data/pos-attr.json") as f:
|
|
|
|
|
data = json.load(f)
|
|
|
|
|
|
2023-05-23 23:36:45 +03:00
|
|
|
|
|
2023-05-23 18:14:06 +03:00
|
|
|
|
reggg = {
|
|
|
|
|
"г. Санкт-Петербург": "Санкт-Петербург",
|
|
|
|
|
"г. Москва": "Москва",
|
|
|
|
|
"г. Севастополь": "Севастополь",
|
|
|
|
|
"Республика Адыгея (Адыгея)": "Республика Адыгея",
|
|
|
|
|
"Чувашская Республика - Чувашия": "Чувашская Республика",
|
|
|
|
|
"Республика Татарстан (Татарстан)": "Республика Татарстан",
|
|
|
|
|
"Республика Северная Осетия - Алания": "Республика Северная Осетия – Алания",
|
|
|
|
|
"Ханты-Мансийский автономный округ - Югра": "Ханты-Мансийский автономный округ — Югра",
|
|
|
|
|
}
|
2023-05-23 23:36:45 +03:00
|
|
|
|
rett = []
|
2023-05-23 18:14:06 +03:00
|
|
|
|
ret = []
|
|
|
|
|
for infff in data:
|
|
|
|
|
info = infff["general"]
|
|
|
|
|
if info["address"] and "mapPosition" in info["address"]:
|
|
|
|
|
r_name = (
|
|
|
|
|
reggg[info["region"]["value"]]
|
|
|
|
|
if info["region"]["value"] in reggg
|
|
|
|
|
else info["region"]["value"]
|
|
|
|
|
)
|
|
|
|
|
res = {
|
|
|
|
|
"title": info["name"],
|
|
|
|
|
"parser_source": "mkrf.ru",
|
2023-05-24 13:32:17 +03:00
|
|
|
|
# "region": Region.objects.get(title=r_name),
|
2023-05-23 18:14:06 +03:00
|
|
|
|
"lat": info["address"]["mapPosition"]["coordinates"][0],
|
|
|
|
|
"lon": info["address"]["mapPosition"]["coordinates"][1],
|
|
|
|
|
"address": info["address"]["fullAddress"],
|
|
|
|
|
"type": "attraction",
|
|
|
|
|
"extra_kwargs": {"objectType": info["objectType"]["value"]},
|
|
|
|
|
}
|
|
|
|
|
if "typologies" in info:
|
|
|
|
|
res["extra_kwargs"]["typologies"] = [x["value"] for x in info["typologies"]]
|
2023-05-24 13:32:17 +03:00
|
|
|
|
|
2023-05-23 23:36:45 +03:00
|
|
|
|
if "securityInfo" in info or "borderInfo" in info:
|
|
|
|
|
for ev in Event.objects.filter(
|
|
|
|
|
title=info["name"],
|
|
|
|
|
address=res["address"],
|
|
|
|
|
lat=res["lat"],
|
|
|
|
|
lon=res["lon"],
|
|
|
|
|
):
|
2023-05-24 13:32:17 +03:00
|
|
|
|
ev.extra_kwargs = res["extra_kwargs"]
|
2023-05-23 23:36:45 +03:00
|
|
|
|
ev.save()
|
|
|
|
|
|
2023-05-23 18:14:06 +03:00
|
|
|
|
ret.append(res)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_att():
|
|
|
|
|
return ret
|