Merge pull request 'zorn-dev' (#6) from zorn-dev into PMSManager_refactor
Reviewed-on: SmartSolTech/touchh_bot#6
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -14,4 +14,5 @@ old_bot
|
||||
*.log
|
||||
db.sqlite3
|
||||
# Ignore files
|
||||
.fake
|
||||
.fake
|
||||
docker-compose.override.yaml
|
||||
|
||||
11
Dockerfile
Normal file
11
Dockerfile
Normal file
@@ -0,0 +1,11 @@
|
||||
FROM python:3.12-alpine
|
||||
|
||||
COPY requirements.txt /
|
||||
|
||||
RUN set -ex ;\
|
||||
apk add --no-cache musl-dev mariadb-connector-c-dev gcc ;\
|
||||
pip3 install -r /requirements.txt ;\
|
||||
pip3 cache purge ;\
|
||||
apk del --rdepends --purge musl-dev gcc
|
||||
|
||||
WORKDIR /app
|
||||
3
bin/cli
Executable file
3
bin/cli
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
docker compose exec web python3 manage.py "$@"
|
||||
3
bin/pip3
Executable file
3
bin/pip3
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
docker compose exec web pip3 "$@"
|
||||
12
bin/update
Executable file
12
bin/update
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
cd `dirname $0`/..
|
||||
|
||||
git pull
|
||||
|
||||
docker compose down
|
||||
docker compose build
|
||||
docker compose up -d web
|
||||
sleep 1
|
||||
./bin/cli migrate
|
||||
docker compose up -d
|
||||
29
docker-compose.yaml
Normal file
29
docker-compose.yaml
Normal file
@@ -0,0 +1,29 @@
|
||||
services:
|
||||
db:
|
||||
image: mariadb:11.6
|
||||
restart: on-failure
|
||||
environment:
|
||||
- MYSQL_RANDOM_ROOT_PASSWORD=1
|
||||
- MYSQL_DATABASE=touchh
|
||||
- MYSQL_USER=touchh
|
||||
- MYSQL_PASSWORD=${MYSQL_PASSWORD:-touchh}
|
||||
volumes:
|
||||
- ./var/mysql:/var/lib/mysql
|
||||
bot:
|
||||
&py_service
|
||||
build: .
|
||||
image: touchh-py
|
||||
restart: on-failure
|
||||
command: ['python3', 'manage.py', 'run_bot']
|
||||
depends_on: ['db']
|
||||
stop_signal: SIGINT
|
||||
volumes:
|
||||
- .:/app
|
||||
scheduler:
|
||||
<<: *py_service
|
||||
command: ['python3', 'manage.py', 'start_scheduler']
|
||||
web:
|
||||
<<: *py_service
|
||||
command: ['python3', 'manage.py', 'runserver', '0.0.0.0:8000']
|
||||
ports:
|
||||
- "${DOCKER_HTTP_BIND:-8000}:8000"
|
||||
@@ -15,7 +15,7 @@ logging.basicConfig(
|
||||
level=logging.WARNING, # Установите уровень логов для всех обработчиков
|
||||
format='%(asctime)s [%(levelname)s] %(message)s',
|
||||
handlers=[
|
||||
logging.FileHandler("bnovo_plugin.log"), # Логи пишутся в файл
|
||||
logging.FileHandler("var/log/bnovo_plugin.log"), # Логи пишутся в файл
|
||||
logging.StreamHandler() # Логи выводятся в консоль
|
||||
]
|
||||
)
|
||||
@@ -223,8 +223,8 @@ class BnovoPMSPlugin(BasePMSPlugin):
|
||||
data = response.json()
|
||||
bookings = data.get("bookings", [])
|
||||
rooms = data.get("rooms", [])
|
||||
|
||||
|
||||
|
||||
|
||||
logger.debug(f'bookings: {bookings}\n rooms: {rooms}')
|
||||
all_bookings.extend(bookings)
|
||||
|
||||
|
||||
@@ -64,73 +64,3 @@ ua-parser-builtins==0.18.0.post1
|
||||
urllib3==2.2.3
|
||||
user-agents==2.2.0
|
||||
yarl==1.18.3
|
||||
mysqlclient
|
||||
chardet
|
||||
python-decouple
|
||||
cryptography
|
||||
mysqlclientace_tools==0.0
|
||||
aiohappyeyeballs==2.4.4
|
||||
aiohttp==3.11.10
|
||||
aiosignal==1.3.1
|
||||
anyio==4.6.2.post1
|
||||
APScheduler==3.11.0
|
||||
asgiref==3.8.1
|
||||
async-timeout==5.0.1
|
||||
attrs==24.2.0
|
||||
certifi==2024.8.30
|
||||
cffi==1.17.1
|
||||
chardet==5.2.0
|
||||
charset-normalizer==3.4.0
|
||||
cryptography==44.0.0
|
||||
defusedxml==0.7.1
|
||||
Django==5.1.4
|
||||
django-environ==0.11.2
|
||||
django-filter==24.3
|
||||
django-health-check==3.18.3
|
||||
django-jazzmin==3.0.1
|
||||
django-jet==1.0.8
|
||||
et_xmlfile==2.0.0
|
||||
exceptiongroup==1.2.2
|
||||
fonttools==4.55.3
|
||||
fpdf2==2.8.2
|
||||
frozenlist==1.5.0
|
||||
geoip2==4.8.1
|
||||
git-filter-repo==2.47.0
|
||||
h11==0.14.0
|
||||
httpcore==1.0.7
|
||||
httpx==0.28.0
|
||||
idna==3.10
|
||||
jsonschema==4.23.0
|
||||
jsonschema-specifications==2024.10.1
|
||||
maxminddb==2.6.2
|
||||
multidict==6.1.0
|
||||
mysqlclient==2.2.6
|
||||
numpy==2.1.3
|
||||
openpyxl==3.1.5
|
||||
pandas==2.2.3
|
||||
pathspec==0.12.1
|
||||
pillow==11.0.0
|
||||
propcache==0.2.1
|
||||
psycopg==3.2.3
|
||||
pycparser==2.22
|
||||
PyMySQL==1.1.1
|
||||
python-dateutil==2.9.0.post0
|
||||
python-decouple==3.8
|
||||
python-dotenv==1.0.1
|
||||
python-telegram-bot==21.8
|
||||
pytz==2024.2
|
||||
PyYAML==6.0.2
|
||||
referencing==0.35.1
|
||||
requests==2.32.3
|
||||
rpds-py==0.22.3
|
||||
six==1.17.0
|
||||
sniffio==1.3.1
|
||||
sqlparse==0.5.2
|
||||
typing_extensions==4.12.2
|
||||
tzdata==2024.2
|
||||
tzlocal==5.2
|
||||
ua-parser==1.0.0
|
||||
ua-parser-builtins==0.18.0.post1
|
||||
urllib3==2.2.3
|
||||
user-agents==2.2.0
|
||||
yarl==1.18.3
|
||||
|
||||
@@ -4,4 +4,15 @@
|
||||
|
||||
.ml-6 {
|
||||
margin-left: 1.5rem !important;
|
||||
}
|
||||
}
|
||||
|
||||
.nav-sidebar ul.nav-treeview .nav-link {
|
||||
padding-left: 2rem;
|
||||
}
|
||||
.nav-sidebar .nav-link {
|
||||
display: flex;
|
||||
}
|
||||
.nav-sidebar .nav-link .nav-icon {
|
||||
margin-top: .2rem;
|
||||
margin-right: .3rem;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ INSTALLED_APPS = [
|
||||
'health_check.db',
|
||||
'health_check.cache',
|
||||
'app_settings',
|
||||
|
||||
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
@@ -101,11 +101,11 @@ GEOIP_PATH = os.path.join(BASE_DIR, 'geoip')
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.mysql',
|
||||
'NAME': os.getenv('DB_NAME'), # Имя базы данных
|
||||
'USER': os.getenv('DB_ROOT_USER'), # Имя пользователя базы данных
|
||||
'PASSWORD': os.getenv('DB_PASSWORD'), # Пароль пользователя
|
||||
'HOST': os.getenv('DB_HOST', default='0.0.0.0'), # Хост (по умолчанию localhost)
|
||||
'PORT': os.getenv('DB_PORT', default=3308), # Порт (по умолчанию 3306)
|
||||
'NAME': os.getenv('DB_NAME', default='touchh'), # Имя базы данных
|
||||
'USER': os.getenv('DB_ROOT_USER', default='touchh'), # Имя пользователя базы данных
|
||||
'PASSWORD': os.getenv('DB_PASSWORD', default='touchh'), # Пароль пользователя
|
||||
'HOST': os.getenv('DB_HOST', default='db'), # Хост (по умолчанию localhost)
|
||||
'PORT': os.getenv('DB_PORT', default=3306), # Порт (по умолчанию 3306)
|
||||
'ATOMIC_REQUESTS': True,
|
||||
|
||||
},
|
||||
@@ -139,7 +139,7 @@ LOGGING = {
|
||||
'file': {
|
||||
'level': os.getenv("LOG_LEVEL"),
|
||||
'class': 'logging.FileHandler',
|
||||
'filename': 'import_hotels.log', # Лог будет записываться в этот файл
|
||||
'filename': 'var/log/import_hotels.log', # Лог будет записываться в этот файл
|
||||
},
|
||||
},
|
||||
'loggers': {
|
||||
@@ -214,7 +214,7 @@ JAZZMIN_SETTINGS = {
|
||||
{"model": "hotels.userhotel", "label": "Пользователи отеля", "css_classes": "ml-6"},
|
||||
],
|
||||
},
|
||||
|
||||
|
||||
],
|
||||
"icons": {
|
||||
# Приложения
|
||||
@@ -238,7 +238,7 @@ JAZZMIN_SETTINGS = {
|
||||
"antifraud.violationlog": "fas fa-ban", # Журнал нарушений
|
||||
"hotels.importedhotel": "fas fa-download", # Импортированные отели
|
||||
"hotels.synclog": "fas fa-sync-alt", # Журнал синхронизации
|
||||
|
||||
|
||||
"auth": "fas fa-users-cog",
|
||||
"users": "fas fa-user-circle",
|
||||
"hotels": "fas fa-hotel",
|
||||
@@ -253,7 +253,7 @@ JAZZMIN_SETTINGS = {
|
||||
"app_settings.globalhotelsettings":"fas fa-hammer",
|
||||
"app_settings.globalsystemsettings":"fas fa-cogs",
|
||||
"scheduler": "fas fa-clock",
|
||||
"pms_integration": "fas fa-sync",
|
||||
"pms_integration": "fas fa-sync",
|
||||
"antifroud": "fas fa-shield-alt",
|
||||
"antifroud.externaldbsettings": "fas fa-database",
|
||||
"antifroud.roomdiscrepancy": "fas fa-user-secret",
|
||||
@@ -262,9 +262,9 @@ JAZZMIN_SETTINGS = {
|
||||
"antifroud.synclog": "fas fa-sync-alt",
|
||||
"antifroud.useractivitylog": "fas fa-qrcode",
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"theme": "sandstone",
|
||||
"dark_mode_theme": "darkly",
|
||||
"footer": {
|
||||
@@ -275,12 +275,11 @@ JAZZMIN_SETTINGS = {
|
||||
{"name": "Google", "url": "https://touchh.com", "new_window": True},
|
||||
{"name": "Smartsoltech", "url": "https://smartsoltech.kr", "new_window": True}
|
||||
],
|
||||
|
||||
|
||||
|
||||
|
||||
"show_ui_builder": False,
|
||||
"show_ui_builder_breadcrumbs": False,
|
||||
"show_ui_builder_tabs": False,
|
||||
"show_ui_builder_tabs_breadcrumbs": False,
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ class CustomLogger:
|
||||
self.logger.handlers.clear()
|
||||
|
||||
# Добавляем обработчик для файла
|
||||
file_handler = logging.FileHandler("project.log")
|
||||
file_handler = logging.FileHandler("var/log/project.log")
|
||||
file_handler.setFormatter(logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s"))
|
||||
file_handler.setLevel(self.log_level)
|
||||
|
||||
|
||||
2
var/.gitignore
vendored
Normal file
2
var/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
2
var/log/.gitignore
vendored
Normal file
2
var/log/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
Reference in New Issue
Block a user