mirror of
https://github.com/task-17-lct/backend.git
synced 2024-11-30 18:23:44 +03:00
added hotels, restaurants
This commit is contained in:
parent
63d4a0a850
commit
7e75d9230f
63
parsers/hotel.py
Normal file
63
parsers/hotel.py
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
import json
|
||||||
|
from pprint import pprint
|
||||||
|
|
||||||
|
from django.contrib.gis.geos import Point
|
||||||
|
|
||||||
|
from passfinder.events.models import City, Region
|
||||||
|
|
||||||
|
with open("data/hotels.json") as f:
|
||||||
|
data = json.load(f)
|
||||||
|
|
||||||
|
|
||||||
|
result = []
|
||||||
|
for r in data:
|
||||||
|
d = {}
|
||||||
|
al = True
|
||||||
|
info = r["dictionary_data"]
|
||||||
|
d["oid"] = r["_id"]["$oid"]
|
||||||
|
d["title"] = info["title"]
|
||||||
|
d["address"] = info["address"]
|
||||||
|
if "stars" in info and info["stars"]:
|
||||||
|
d["stars"] = int(info["stars"])
|
||||||
|
|
||||||
|
if "city" in info:
|
||||||
|
try:
|
||||||
|
d["city"] = City.objects.get(oid=info["city"])
|
||||||
|
except City.DoesNotExist:
|
||||||
|
...
|
||||||
|
if "region" in info:
|
||||||
|
try:
|
||||||
|
d["region"] = Region.objects.get(oid=info["region"])
|
||||||
|
except Region.DoesNotExist:
|
||||||
|
...
|
||||||
|
if "geo_data" in info and info["geo_data"]["coordinates"]:
|
||||||
|
d["location"] = Point(
|
||||||
|
info["geo_data"]["coordinates"][0], info["geo_data"]["coordinates"][1]
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
al = False
|
||||||
|
if "rooms" in info:
|
||||||
|
d["rooms"] = info["rooms"]
|
||||||
|
|
||||||
|
phones = []
|
||||||
|
if "phones" in info:
|
||||||
|
for phone in info["phones"]:
|
||||||
|
phones.append(
|
||||||
|
{"hotel": d["oid"], "name": phone["name"], "number": phone["number"]}
|
||||||
|
)
|
||||||
|
if phones:
|
||||||
|
d["phones"] = phones
|
||||||
|
|
||||||
|
media = []
|
||||||
|
if "images" in info:
|
||||||
|
for m in info["images"]:
|
||||||
|
media.append({"file": m["source"]["id"], "type": "image"})
|
||||||
|
if media:
|
||||||
|
d["media"] = media
|
||||||
|
|
||||||
|
if al:
|
||||||
|
result.append(d)
|
||||||
|
|
||||||
|
|
||||||
|
def get_hotel():
|
||||||
|
return result
|
67
parsers/restaurant.py
Normal file
67
parsers/restaurant.py
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
import json
|
||||||
|
from pprint import pprint
|
||||||
|
|
||||||
|
from django.contrib.gis.geos import Point
|
||||||
|
|
||||||
|
from passfinder.events.models import City, Region
|
||||||
|
|
||||||
|
with open("data/restaurants.json") as f:
|
||||||
|
data = json.load(f)
|
||||||
|
|
||||||
|
|
||||||
|
result = []
|
||||||
|
for r in data:
|
||||||
|
d = {}
|
||||||
|
al = True
|
||||||
|
info = r["dictionary_data"]
|
||||||
|
d["oid"] = r["_id"]["$oid"]
|
||||||
|
d["title"] = info["title"]
|
||||||
|
if "description" in info:
|
||||||
|
d["description"] = info["description"]
|
||||||
|
else:
|
||||||
|
d["description"] = ""
|
||||||
|
d["address"] = info["address"]
|
||||||
|
if "bill" in info:
|
||||||
|
d["bill"] = int(info["bill"])
|
||||||
|
if "parser_source" in info:
|
||||||
|
d["parser_source"] = info["parser_source"]
|
||||||
|
if "avg_time_visit" in info:
|
||||||
|
d["avg_time_visit"] = int(info["avg_time_visit"])
|
||||||
|
if "can_reserve" in info:
|
||||||
|
d["can_reserve"] = bool(info["can_reserve"])
|
||||||
|
if "working_time" in info:
|
||||||
|
d["working_time"] = info["working_time"]
|
||||||
|
if "phones" in info and info["phones"]:
|
||||||
|
d["phones"] = info["phones"]
|
||||||
|
|
||||||
|
if "city" in info:
|
||||||
|
try:
|
||||||
|
d["city"] = City.objects.get(oid=info["city"])
|
||||||
|
except City.DoesNotExist:
|
||||||
|
...
|
||||||
|
if "region" in info:
|
||||||
|
try:
|
||||||
|
d["region"] = Region.objects.get(oid=info["region"])
|
||||||
|
except Region.DoesNotExist:
|
||||||
|
...
|
||||||
|
|
||||||
|
if "geo_data" in info and info["geo_data"]["coordinates"]:
|
||||||
|
d["location"] = Point(
|
||||||
|
info["geo_data"]["coordinates"][0], info["geo_data"]["coordinates"][1]
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
al = False
|
||||||
|
|
||||||
|
media = []
|
||||||
|
if "images" in info:
|
||||||
|
for m in info["images"]:
|
||||||
|
media.append({"file": m["source"]["id"], "type": "image"})
|
||||||
|
if media and 1 == 2:
|
||||||
|
d["media"] = media
|
||||||
|
|
||||||
|
if al:
|
||||||
|
result.append(d)
|
||||||
|
|
||||||
|
|
||||||
|
def get_restaurant():
|
||||||
|
return result
|
19
passfinder/events/migrations/0012_restaurant_address.py
Normal file
19
passfinder/events/migrations/0012_restaurant_address.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
# Generated by Django 4.2.1 on 2023-05-21 06:58
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("events", "0011_remove_event_purchase_method_and_more"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="restaurant",
|
||||||
|
name="address",
|
||||||
|
field=models.CharField(default="", max_length=250),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
]
|
|
@ -0,0 +1,40 @@
|
||||||
|
# Generated by Django 4.2.1 on 2023-05-21 07:05
|
||||||
|
|
||||||
|
import django.contrib.postgres.fields
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("events", "0012_restaurant_address"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name="restaurant",
|
||||||
|
name="phone",
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="restaurant",
|
||||||
|
name="phones",
|
||||||
|
field=django.contrib.postgres.fields.ArrayField(
|
||||||
|
base_field=models.CharField(max_length=18), null=True, size=None
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="restaurant",
|
||||||
|
name="avg_time_visit",
|
||||||
|
field=models.IntegerField(null=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="restaurant",
|
||||||
|
name="bill",
|
||||||
|
field=models.IntegerField(null=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="restaurant",
|
||||||
|
name="can_reserve",
|
||||||
|
field=models.BooleanField(default=True),
|
||||||
|
),
|
||||||
|
]
|
|
@ -155,8 +155,9 @@ class ExcursionRoute(models.Model):
|
||||||
|
|
||||||
|
|
||||||
class Restaurant(BasePoint):
|
class Restaurant(BasePoint):
|
||||||
bill = models.IntegerField()
|
address = models.CharField(max_length=250)
|
||||||
avg_time_visit = models.IntegerField()
|
bill = models.IntegerField(null=True)
|
||||||
can_reserve = models.BooleanField()
|
can_reserve = models.BooleanField(default=True)
|
||||||
|
avg_time_visit = models.IntegerField(null=True)
|
||||||
working_time = models.JSONField(null=True)
|
working_time = models.JSONField(null=True)
|
||||||
phone = models.CharField(max_length=18)
|
phones = ArrayField(models.CharField(max_length=18), null=True)
|
||||||
|
|
136
requirements.txt
Normal file
136
requirements.txt
Normal file
|
@ -0,0 +1,136 @@
|
||||||
|
amqp==5.1.1 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
anyio==3.6.2 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
appnope==0.1.3 ; python_version >= "3.11" and python_version < "4.0" and sys_platform == "darwin"
|
||||||
|
argon2-cffi-bindings==21.2.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
argon2-cffi==21.3.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
asgiref==3.6.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
astroid==2.15.5 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
asttokens==2.2.1 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
async-timeout==4.0.2 ; python_version >= "3.11" and python_full_version <= "3.11.2"
|
||||||
|
attrs==23.1.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
backcall==0.2.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
billiard==3.6.4.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
black==22.12.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
celery==5.2.7 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
celery[redis]==5.2.7 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
certifi==2023.5.7 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
cffi==1.15.1 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
cfgv==3.3.1 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
charset-normalizer==3.1.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
click-didyoumean==0.3.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
click-plugins==1.1.1 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
click-repl==0.2.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
click==8.1.3 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
colorama==0.4.6 ; python_version >= "3.11" and python_version < "4.0" and sys_platform == "win32" or python_version >= "3.11" and python_version < "4.0" and platform_system == "Windows"
|
||||||
|
coverage==7.2.5 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
cron-descriptor==1.3.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
decorator==5.1.1 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
dill==0.3.6 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
distlib==0.3.6 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
django-celery-beat==2.5.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
django-cors-headers==3.14.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
django-coverage-plugin==3.0.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
django-debug-toolbar==3.8.1 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
django-environ==0.9.0 ; python_version >= "3.11" and python_version < "4"
|
||||||
|
django-extensions==3.2.1 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
django-ipware==5.0.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
django-location-field==2.7.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
django-model-utils==4.3.1 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
django-polymorphic==3.1.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
django-redis==5.2.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
django-structlog==4.1.1 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
django-stubs-ext==4.2.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
django-stubs==1.16.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
django-timezone-field==5.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
django==4.2.1 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
djangorestframework-stubs==1.10.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
djangorestframework==3.14.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
drf-spectacular==0.25.1 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
executing==1.2.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
factory-boy==3.2.1 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
faker==18.9.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
filelock==3.12.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
flake8-isort==6.0.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
flake8==6.0.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
flower==1.2.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
humanize==4.6.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
identify==2.5.24 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
idna==3.4 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
inflection==0.5.1 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
iniconfig==2.0.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
ipdb==0.13.13 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
ipython==8.13.2 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
isort==5.12.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
jedi==0.18.2 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
jsonschema==4.17.3 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
kombu==5.2.4 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
lazy-object-proxy==1.9.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
markupsafe==2.1.2 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
matplotlib-inline==0.1.6 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
mccabe==0.7.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
mypy-extensions==1.0.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
mypy==0.991 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
nodeenv==1.8.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
packaging==23.1 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
parso==0.8.3 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
pathspec==0.11.1 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
pexpect==4.8.0 ; python_version >= "3.11" and python_version < "4.0" and sys_platform != "win32"
|
||||||
|
pickleshare==0.7.5 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
pillow==9.5.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
platformdirs==3.5.1 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
pluggy==1.0.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
pre-commit==2.21.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
prometheus-client==0.16.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
prompt-toolkit==3.0.38 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
psutil==5.9.5 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
psycopg2==2.9.6 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
ptyprocess==0.7.0 ; python_version >= "3.11" and python_version < "4.0" and sys_platform != "win32"
|
||||||
|
pure-eval==0.2.2 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
pycodestyle==2.10.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
pycparser==2.21 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
pyflakes==3.0.1 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
pygments==2.15.1 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
pylint-celery==0.3 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
pylint-django==2.5.3 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
pylint-plugin-utils==0.8.1 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
pylint==2.17.4 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
pyrsistent==0.19.3 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
pytest-django==4.5.2 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
pytest-sugar==0.9.7 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
pytest==7.3.1 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
python-crontab==2.7.1 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
python-dateutil==2.8.2 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
python-slugify==7.0.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
pytz==2022.7.1 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
pyyaml==6.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
redis==4.5.5 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
requests==2.30.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
sentry-sdk==1.23.1 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
setuptools==67.7.2 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
six==1.16.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
sniffio==1.3.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
sqlparse==0.4.4 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
stack-data==0.6.2 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
structlog==23.1.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
termcolor==2.3.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
text-unidecode==1.3 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
tomli==2.0.1 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
tomlkit==0.11.8 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
tornado==6.3.2 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
traitlets==5.9.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
types-pytz==2023.3.0.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
types-pyyaml==6.0.12.9 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
types-requests==2.30.0.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
types-urllib3==1.26.25.13 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
typing-extensions==4.5.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
tzdata==2023.3 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
uritemplate==4.1.1 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
urllib3==1.26.15 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
vine==5.0.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
virtualenv==20.23.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
watchdog==3.0.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
watchfiles==0.18.1 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
wcwidth==0.2.6 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
werkzeug[watchdog]==2.3.4 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
whitenoise==6.4.0 ; python_version >= "3.11" and python_version < "4.0"
|
||||||
|
wrapt==1.15.0 ; python_version >= "3.11" and python_version < "4.0"
|
Loading…
Reference in New Issue
Block a user