mirror of
https://github.com/task-17-lct/backend.git
synced 2024-11-10 22:16:35 +03:00
loaded hotels
This commit is contained in:
parent
1b25e6dccd
commit
cbce253ab0
File diff suppressed because it is too large
Load Diff
39
parsers/osm/apartment.py
Normal file
39
parsers/osm/apartment.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
import json
|
||||
|
||||
with open("data/osm/apartment.json") as f:
|
||||
data = json.load(f)
|
||||
|
||||
|
||||
ress = []
|
||||
|
||||
for el in data["elements"]:
|
||||
if "tags" in el and "name" in el["tags"] and "lat" in el and "lon" in el:
|
||||
info = el["tags"]
|
||||
if "tourism" in info:
|
||||
del info["tourism"]
|
||||
res = {
|
||||
"title": info["name:ru"] if "name:ru" in info else info["name"],
|
||||
"type": "apartment",
|
||||
"parser_source": "openstreetmap.org",
|
||||
"lat": el["lat"],
|
||||
"lon": el["lon"],
|
||||
"extra_kwargs": info,
|
||||
}
|
||||
if "rooms" in info:
|
||||
res["rooms"] = {"amount": info["rooms"]}
|
||||
|
||||
if "description" in info:
|
||||
res["description"] = info["description"]
|
||||
|
||||
if "email" in info:
|
||||
res["email"] = info["email"]
|
||||
|
||||
if "stars" in info:
|
||||
res["stars"] = int(float(info["stars"]))
|
||||
else:
|
||||
res["stars"] = 0
|
||||
ress.append(res)
|
||||
|
||||
|
||||
def get_hotels():
|
||||
return ress
|
39
parsers/osm/chalet.py
Normal file
39
parsers/osm/chalet.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
import json
|
||||
|
||||
with open("data/osm/chalet.json") as f:
|
||||
data = json.load(f)
|
||||
|
||||
|
||||
ress = []
|
||||
|
||||
for el in data["elements"]:
|
||||
if "tags" in el and "name" in el["tags"] and "lat" in el and "lon" in el:
|
||||
info = el["tags"]
|
||||
if "tourism" in info:
|
||||
del info["tourism"]
|
||||
res = {
|
||||
"title": info["name:ru"] if "name:ru" in info else info["name"],
|
||||
"type": "chalet",
|
||||
"parser_source": "openstreetmap.org",
|
||||
"lat": el["lat"],
|
||||
"lon": el["lon"],
|
||||
"extra_kwargs": info,
|
||||
}
|
||||
if "rooms" in info:
|
||||
res["rooms"] = {"amount": info["rooms"]}
|
||||
|
||||
if "description" in info:
|
||||
res["description"] = info["description"]
|
||||
|
||||
if "email" in info:
|
||||
res["email"] = info["email"]
|
||||
|
||||
if "stars" in info:
|
||||
res["stars"] = int(float(info["stars"]))
|
||||
else:
|
||||
res["stars"] = 0
|
||||
ress.append(res)
|
||||
|
||||
|
||||
def get_hotels():
|
||||
return ress
|
39
parsers/osm/guest_house.py
Normal file
39
parsers/osm/guest_house.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
import json
|
||||
|
||||
with open("data/osm/hostel_2.json") as f:
|
||||
data = json.load(f)
|
||||
|
||||
|
||||
ress = []
|
||||
|
||||
for el in data["elements"]:
|
||||
if "tags" in el and "name" in el["tags"] and "lat" in el and "lon" in el:
|
||||
info = el["tags"]
|
||||
if "tourism" in info:
|
||||
del info["tourism"]
|
||||
res = {
|
||||
"title": info["name:ru"] if "name:ru" in info else info["name"],
|
||||
"type": "guest_house",
|
||||
"parser_source": "openstreetmap.org",
|
||||
"lat": el["lat"],
|
||||
"lon": el["lon"],
|
||||
"extra_kwargs": info,
|
||||
}
|
||||
if "rooms" in info:
|
||||
res["rooms"] = {"amount": info["rooms"]}
|
||||
|
||||
if "description" in info:
|
||||
res["description"] = info["description"]
|
||||
|
||||
if "email" in info:
|
||||
res["email"] = info["email"]
|
||||
|
||||
if "stars" in info:
|
||||
res["stars"] = int(float(info["stars"]))
|
||||
else:
|
||||
res["stars"] = 0
|
||||
ress.append(res)
|
||||
|
||||
|
||||
def get_hostels():
|
||||
return ress
|
39
parsers/osm/hostels.py
Normal file
39
parsers/osm/hostels.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
import json
|
||||
|
||||
with open("data/osm/hostel.json") as f:
|
||||
data = json.load(f)
|
||||
|
||||
|
||||
ress = []
|
||||
|
||||
for el in data["elements"]:
|
||||
if "tags" in el and "name" in el["tags"] and "lat" in el and "lon" in el:
|
||||
info = el["tags"]
|
||||
if "tourism" in info:
|
||||
del info["tourism"]
|
||||
res = {
|
||||
"title": info["name:ru"] if "name:ru" in info else info["name"],
|
||||
"type": "hostel",
|
||||
"parser_source": "openstreetmap.org",
|
||||
"lat": el["lat"],
|
||||
"lon": el["lon"],
|
||||
"extra_kwargs": info,
|
||||
}
|
||||
if "rooms" in info:
|
||||
res["rooms"] = {"amount": info["rooms"]}
|
||||
|
||||
if "description" in info:
|
||||
res["description"] = info["description"]
|
||||
|
||||
if "email" in info:
|
||||
res["email"] = info["email"]
|
||||
|
||||
if "stars" in info:
|
||||
res["stars"] = int(float(info["stars"]))
|
||||
else:
|
||||
res["stars"] = 0
|
||||
ress.append(res)
|
||||
|
||||
|
||||
def get_hostels():
|
||||
return ress
|
39
parsers/osm/motel.py
Normal file
39
parsers/osm/motel.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
import json
|
||||
|
||||
with open("data/osm/motel.json") as f:
|
||||
data = json.load(f)
|
||||
|
||||
|
||||
ress = []
|
||||
|
||||
for el in data["elements"]:
|
||||
if "tags" in el and "name" in el["tags"] and "lat" in el and "lon" in el:
|
||||
info = el["tags"]
|
||||
if "tourism" in info:
|
||||
del info["tourism"]
|
||||
res = {
|
||||
"title": info["name:ru"] if "name:ru" in info else info["name"],
|
||||
"type": "motel",
|
||||
"parser_source": "openstreetmap.org",
|
||||
"lat": el["lat"],
|
||||
"lon": el["lon"],
|
||||
"extra_kwargs": info,
|
||||
}
|
||||
if "rooms" in info:
|
||||
res["rooms"] = {"amount": info["rooms"]}
|
||||
|
||||
if "description" in info:
|
||||
res["description"] = info["description"]
|
||||
|
||||
if "email" in info:
|
||||
res["email"] = info["email"]
|
||||
|
||||
if "stars" in info:
|
||||
res["stars"] = int(float(info["stars"]))
|
||||
else:
|
||||
res["stars"] = 0
|
||||
ress.append(res)
|
||||
|
||||
|
||||
def get_hotels():
|
||||
return ress
|
|
@ -36,11 +36,9 @@ class Meta:
|
|||
|
||||
|
||||
class EventSerializer(serializers.ModelSerializer):
|
||||
city_name = serializers.CharField(source="city.title")
|
||||
|
||||
class Meta:
|
||||
model = Event
|
||||
fields = ("type", "title", "description", "city", "city_name", "oid")
|
||||
fields = ("type", "title", "description", "city", "oid")
|
||||
|
||||
|
||||
class PointSerializer(serializers.ModelSerializer):
|
||||
|
|
30
passfinder/events/migrations/0021_alter_hotel_type.py
Normal file
30
passfinder/events/migrations/0021_alter_hotel_type.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
# Generated by Django 4.2.1 on 2023-05-25 22:40
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("events", "0020_hotel_extra_kwargs_hotel_type_alter_hotel_address_and_more"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="hotel",
|
||||
name="type",
|
||||
field=models.CharField(
|
||||
choices=[
|
||||
("hotel", "отель"),
|
||||
("hostel", "хостел"),
|
||||
("guest_house", "гостевой дом"),
|
||||
("motel", "мотель"),
|
||||
("apartment", "квартира"),
|
||||
("chalet", "домик"),
|
||||
],
|
||||
db_index=True,
|
||||
default="hotel",
|
||||
max_length=11,
|
||||
),
|
||||
),
|
||||
]
|
|
@ -182,6 +182,8 @@ class HotelType(models.TextChoices):
|
|||
hostel = "hostel", "хостел"
|
||||
guest_house = "guest_house", "гостевой дом"
|
||||
motel = "motel", "мотель"
|
||||
apartment = "apartment", "квартира"
|
||||
chalet = "chalet", "домик"
|
||||
|
||||
type = models.CharField(
|
||||
db_index=True,
|
||||
|
|
Loading…
Reference in New Issue
Block a user