diff --git a/bin/migrate.sh b/bin/migrate.sh old mode 100644 new mode 100755 index e1f0a30..bee58bf --- a/bin/migrate.sh +++ b/bin/migrate.sh @@ -1,3 +1,3 @@ #!/usr/bin/env bash # Run migrations -docker exec ${} python3 smartsoltech/manage.py migrate \ No newline at end of file +docker exec ${django_app} python3 smartsoltech/manage.py migrate \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index c5885be..2753b97 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,8 +2,8 @@ version: '3.8' services: - db: - image: postgres:latest + postgres_db: + image: postgres:17 container_name: postgres_db env_file: .env volumes: @@ -23,7 +23,7 @@ services: container_name: pgadmin env_file: .env depends_on: - - db + - postgres_db ports: - "8080:80" environment: @@ -59,7 +59,7 @@ services: ports: - "8000:8000" depends_on: - - db + - postgres_db networks: - web_db_network diff --git a/endpoint_test.sh b/endpoint_test.sh new file mode 100755 index 0000000..8d58394 --- /dev/null +++ b/endpoint_test.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +BASE_URL="http://localhost:8002/auth" +EMAIL="testuser@example.com" +PASSWORD="secret123" + +echo "1️⃣ Регистрация пользователя..." +curl -s -X POST "$BASE_URL/register" \ + -H "Content-Type: application/json" \ + -d "{\"email\": \"$EMAIL\", \"password\": \"$PASSWORD\"}" | tee response_register.json +echo -e "\n" + +USER_ID=$(jq .id response_register.json) + +echo "2️⃣ Аутентификация..." +curl -s -X POST "$BASE_URL/login" \ + -H "Content-Type: application/json" \ + -d "{\"email\": \"$EMAIL\", \"password\": \"$PASSWORD\"}" | tee response_login.json +echo -e "\n" + +TOKEN=$(jq -r .access_token response_login.json) + +echo "🔐 Получен токен: $TOKEN" +AUTH_HEADER="Authorization: Bearer $TOKEN" + +echo "3️⃣ Получение текущего пользователя (/me)..." +curl -s -X GET "$BASE_URL/me" -H "$AUTH_HEADER" | tee response_me.json +echo -e "\n" + +echo "4️⃣ Получение списка всех пользователей..." +curl -s -X GET "$BASE_URL/users" | tee response_users.json +echo -e "\n" + +echo "5️⃣ Получение пользователя по ID ($USER_ID)..." +curl -s -X GET "$BASE_URL/users/$USER_ID" | tee response_user.json +echo -e "\n" + +echo "6️⃣ Обновление пользователя..." +curl -s -X PUT "$BASE_URL/users/$USER_ID" \ + -H "Content-Type: application/json" \ + -d "{\"email\": \"updated_$EMAIL\", \"role\": \"admin\"}" | tee response_update.json +echo -e "\n" + +echo "7️⃣ Удаление пользователя..." +curl -s -X DELETE "$BASE_URL/users/$USER_ID" | tee response_delete.json +echo -e "\n" + +echo "✅ Тест завершён." diff --git a/response_delete.json b/response_delete.json new file mode 100644 index 0000000..672bf46 --- /dev/null +++ b/response_delete.json @@ -0,0 +1 @@ +{"detail":"User 4 deleted"} \ No newline at end of file diff --git a/response_login.json b/response_login.json new file mode 100644 index 0000000..d578b9c --- /dev/null +++ b/response_login.json @@ -0,0 +1 @@ +{"access_token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI0Iiwicm9sZSI6InVzZXIiLCJleHAiOjE3NTI0OTc2NDV9.S_tquLFIPnyG6XlfwIw97hJv0l9oKpTcYw_XG0mDd6w","token_type":"bearer"} \ No newline at end of file diff --git a/response_me.json b/response_me.json new file mode 100644 index 0000000..289436b --- /dev/null +++ b/response_me.json @@ -0,0 +1 @@ +{"id":4,"email":"testuser@example.com","role":"user"} \ No newline at end of file diff --git a/response_register.json b/response_register.json new file mode 100644 index 0000000..289436b --- /dev/null +++ b/response_register.json @@ -0,0 +1 @@ +{"id":4,"email":"testuser@example.com","role":"user"} \ No newline at end of file diff --git a/response_update.json b/response_update.json new file mode 100644 index 0000000..a54cdf8 --- /dev/null +++ b/response_update.json @@ -0,0 +1 @@ +{"id":4,"email":"updated_testuser@example.com","role":"admin"} \ No newline at end of file diff --git a/response_user.json b/response_user.json new file mode 100644 index 0000000..289436b --- /dev/null +++ b/response_user.json @@ -0,0 +1 @@ +{"id":4,"email":"testuser@example.com","role":"user"} \ No newline at end of file diff --git a/response_users.json b/response_users.json new file mode 100644 index 0000000..8c60e3c --- /dev/null +++ b/response_users.json @@ -0,0 +1 @@ +[{"id":1,"email":"user1@example.com","role":"user"},{"id":4,"email":"testuser@example.com","role":"user"}] \ No newline at end of file diff --git a/smartsoltech/comunication/telegram_bot.py b/smartsoltech/comunication/telegram_bot.py index 80914e2..85f263a 100644 --- a/smartsoltech/comunication/telegram_bot.py +++ b/smartsoltech/comunication/telegram_bot.py @@ -14,12 +14,35 @@ class TelegramBot: def __init__(self): # Получение настроек бота из базы данных bot_settings = TelegramSettings.objects.first() - if bot_settings: - TELEGRAM_BOT_TOKEN = bot_settings.bot_token - self.bot = telebot.TeleBot(TELEGRAM_BOT_TOKEN) - logging.info("[TelegramBot] Бот инициализирован с токеном.") + if bot_settings and bot_settings.bot_token: + TELEGRAM_BOT_TOKEN = bot_settings.bot_token.strip() + + # Проверяем валидность токена + if self._validate_token(TELEGRAM_BOT_TOKEN): + self.bot = telebot.TeleBot(TELEGRAM_BOT_TOKEN) + logging.info(f"[TelegramBot] Бот инициализирован с токеном для {bot_settings.bot_name}.") + else: + logging.error(f"[TelegramBot] Токен невалиден: {TELEGRAM_BOT_TOKEN[:10]}...") + raise Exception(f"Невалидный токен Telegram бота. Обновите токен в базе данных.") else: - raise Exception("Telegram bot settings not found") + raise Exception("Telegram bot settings not found or token is empty") + + def _validate_token(self, token): + """Проверяет валидность токена через Telegram API""" + url = f"https://api.telegram.org/bot{token}/getMe" + try: + response = requests.get(url, timeout=10) + result = response.json() + if result.get('ok'): + bot_info = result.get('result', {}) + logging.info(f"[TelegramBot] Токен валиден. Бот: @{bot_info.get('username', 'unknown')}") + return True + else: + logging.error(f"[TelegramBot] Ошибка Telegram API: {result.get('description', 'Unknown error')}") + return False + except requests.RequestException as e: + logging.error(f"[TelegramBot] Ошибка при проверке токена: {e}") + return False def start_bot_polling(self): logging.info("[TelegramBot] Бот начал работу в режиме polling.") diff --git a/smartsoltech/media/static/img/blog/tsvetok_lepestki_buton_1459893_1280x720.jpg b/smartsoltech/media/static/img/blog/tsvetok_lepestki_buton_1459893_1280x720.jpg new file mode 100644 index 0000000..cfe1c87 Binary files /dev/null and b/smartsoltech/media/static/img/blog/tsvetok_lepestki_buton_1459893_1280x720.jpg differ diff --git a/smartsoltech/media/static/img/project/3.png b/smartsoltech/media/static/img/project/3.png new file mode 100644 index 0000000..bb6c0bc Binary files /dev/null and b/smartsoltech/media/static/img/project/3.png differ diff --git a/smartsoltech/media/static/img/services/1_j0npR4p.png b/smartsoltech/media/static/img/services/1_j0npR4p.png new file mode 100644 index 0000000..c78927b Binary files /dev/null and b/smartsoltech/media/static/img/services/1_j0npR4p.png differ diff --git a/smartsoltech/media/static/img/services/photo_2025-07-10_09-33-12.jpg b/smartsoltech/media/static/img/services/photo_2025-07-10_09-33-12.jpg new file mode 100644 index 0000000..c73c5fc Binary files /dev/null and b/smartsoltech/media/static/img/services/photo_2025-07-10_09-33-12.jpg differ diff --git a/smartsoltech/media/static/img/services/photo_2025-07-10_09-33-17_2.jpg b/smartsoltech/media/static/img/services/photo_2025-07-10_09-33-17_2.jpg new file mode 100644 index 0000000..83cbab8 Binary files /dev/null and b/smartsoltech/media/static/img/services/photo_2025-07-10_09-33-17_2.jpg differ diff --git a/smartsoltech/media/static/img/services/photo_2025-07-10_09-33-24_2.jpg b/smartsoltech/media/static/img/services/photo_2025-07-10_09-33-24_2.jpg new file mode 100644 index 0000000..7d28501 Binary files /dev/null and b/smartsoltech/media/static/img/services/photo_2025-07-10_09-33-24_2.jpg differ diff --git a/smartsoltech/media/static/img/services/photo_2025-07-10_09-33-34.jpg b/smartsoltech/media/static/img/services/photo_2025-07-10_09-33-34.jpg new file mode 100644 index 0000000..56934b5 Binary files /dev/null and b/smartsoltech/media/static/img/services/photo_2025-07-10_09-33-34.jpg differ diff --git a/smartsoltech/smartsoltech/settings.py b/smartsoltech/smartsoltech/settings.py index 1a35377..80ab3c5 100644 --- a/smartsoltech/smartsoltech/settings.py +++ b/smartsoltech/smartsoltech/settings.py @@ -29,9 +29,11 @@ SECRET_KEY = config('SECRET_KEY') DEBUG = True # Allowed hosts and CSRF trusted origins -ALLOWED_HOSTS = config('ALLOWED_HOSTS', default='').split(',') +ALLOWED_HOSTS = config('ALLOWED_HOSTS', default='localhost').split(',') CSRF_TRUSTED_ORIGINS = config('CSRF_TRUSTED_ORIGINS', default='').split(',') +print(f"ALLOWED_HOSTS: {ALLOWED_HOSTS}") +print(f"CSRF_TRUSTED_ORIGINS: {CSRF_TRUSTED_ORIGINS}") # Application definition diff --git a/smartsoltech/static/qr_codes/request_3.png b/smartsoltech/static/qr_codes/request_3.png new file mode 100644 index 0000000..99aa08c Binary files /dev/null and b/smartsoltech/static/qr_codes/request_3.png differ diff --git a/smartsoltech/static/qr_codes/request_347.png b/smartsoltech/static/qr_codes/request_347.png deleted file mode 100644 index 20274e5..0000000 Binary files a/smartsoltech/static/qr_codes/request_347.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_348.png b/smartsoltech/static/qr_codes/request_348.png deleted file mode 100644 index 660b3b6..0000000 Binary files a/smartsoltech/static/qr_codes/request_348.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_349.png b/smartsoltech/static/qr_codes/request_349.png deleted file mode 100644 index 70caaae..0000000 Binary files a/smartsoltech/static/qr_codes/request_349.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_350.png b/smartsoltech/static/qr_codes/request_350.png deleted file mode 100644 index 9a23111..0000000 Binary files a/smartsoltech/static/qr_codes/request_350.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_351.png b/smartsoltech/static/qr_codes/request_351.png deleted file mode 100644 index 7fc93fb..0000000 Binary files a/smartsoltech/static/qr_codes/request_351.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_352.png b/smartsoltech/static/qr_codes/request_352.png deleted file mode 100644 index ca74a9b..0000000 Binary files a/smartsoltech/static/qr_codes/request_352.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_353.png b/smartsoltech/static/qr_codes/request_353.png deleted file mode 100644 index 7a091c8..0000000 Binary files a/smartsoltech/static/qr_codes/request_353.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_354.png b/smartsoltech/static/qr_codes/request_354.png deleted file mode 100644 index 2a26ed3..0000000 Binary files a/smartsoltech/static/qr_codes/request_354.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_355.png b/smartsoltech/static/qr_codes/request_355.png deleted file mode 100644 index 42c8e11..0000000 Binary files a/smartsoltech/static/qr_codes/request_355.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_356.png b/smartsoltech/static/qr_codes/request_356.png deleted file mode 100644 index 8130d2b..0000000 Binary files a/smartsoltech/static/qr_codes/request_356.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_357.png b/smartsoltech/static/qr_codes/request_357.png deleted file mode 100644 index 7366983..0000000 Binary files a/smartsoltech/static/qr_codes/request_357.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_358.png b/smartsoltech/static/qr_codes/request_358.png deleted file mode 100644 index 78edf7f..0000000 Binary files a/smartsoltech/static/qr_codes/request_358.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_359.png b/smartsoltech/static/qr_codes/request_359.png deleted file mode 100644 index e5c15f9..0000000 Binary files a/smartsoltech/static/qr_codes/request_359.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_360.png b/smartsoltech/static/qr_codes/request_360.png deleted file mode 100644 index c394655..0000000 Binary files a/smartsoltech/static/qr_codes/request_360.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_361.png b/smartsoltech/static/qr_codes/request_361.png deleted file mode 100644 index c59e296..0000000 Binary files a/smartsoltech/static/qr_codes/request_361.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_362.png b/smartsoltech/static/qr_codes/request_362.png deleted file mode 100644 index 2a66d26..0000000 Binary files a/smartsoltech/static/qr_codes/request_362.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_363.png b/smartsoltech/static/qr_codes/request_363.png deleted file mode 100644 index fd69da5..0000000 Binary files a/smartsoltech/static/qr_codes/request_363.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_364.png b/smartsoltech/static/qr_codes/request_364.png deleted file mode 100644 index 63d642b..0000000 Binary files a/smartsoltech/static/qr_codes/request_364.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_365.png b/smartsoltech/static/qr_codes/request_365.png deleted file mode 100644 index 620f687..0000000 Binary files a/smartsoltech/static/qr_codes/request_365.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_366.png b/smartsoltech/static/qr_codes/request_366.png deleted file mode 100644 index 83ec5fc..0000000 Binary files a/smartsoltech/static/qr_codes/request_366.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_367.png b/smartsoltech/static/qr_codes/request_367.png deleted file mode 100644 index fbe1ea5..0000000 Binary files a/smartsoltech/static/qr_codes/request_367.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_368.png b/smartsoltech/static/qr_codes/request_368.png deleted file mode 100644 index ee07650..0000000 Binary files a/smartsoltech/static/qr_codes/request_368.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_369.png b/smartsoltech/static/qr_codes/request_369.png deleted file mode 100644 index 2629e11..0000000 Binary files a/smartsoltech/static/qr_codes/request_369.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_370.png b/smartsoltech/static/qr_codes/request_370.png deleted file mode 100644 index 3ae6000..0000000 Binary files a/smartsoltech/static/qr_codes/request_370.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_371.png b/smartsoltech/static/qr_codes/request_371.png deleted file mode 100644 index 1c25c3c..0000000 Binary files a/smartsoltech/static/qr_codes/request_371.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_372.png b/smartsoltech/static/qr_codes/request_372.png deleted file mode 100644 index 305f58f..0000000 Binary files a/smartsoltech/static/qr_codes/request_372.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_373.png b/smartsoltech/static/qr_codes/request_373.png deleted file mode 100644 index 2b19917..0000000 Binary files a/smartsoltech/static/qr_codes/request_373.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_374.png b/smartsoltech/static/qr_codes/request_374.png deleted file mode 100644 index ac2ee3f..0000000 Binary files a/smartsoltech/static/qr_codes/request_374.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_375.png b/smartsoltech/static/qr_codes/request_375.png deleted file mode 100644 index 909e4c8..0000000 Binary files a/smartsoltech/static/qr_codes/request_375.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_376.png b/smartsoltech/static/qr_codes/request_376.png deleted file mode 100644 index a8a6091..0000000 Binary files a/smartsoltech/static/qr_codes/request_376.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_377.png b/smartsoltech/static/qr_codes/request_377.png deleted file mode 100644 index b3bd76a..0000000 Binary files a/smartsoltech/static/qr_codes/request_377.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_378.png b/smartsoltech/static/qr_codes/request_378.png deleted file mode 100644 index af115b8..0000000 Binary files a/smartsoltech/static/qr_codes/request_378.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_379.png b/smartsoltech/static/qr_codes/request_379.png deleted file mode 100644 index 5360a78..0000000 Binary files a/smartsoltech/static/qr_codes/request_379.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_380.png b/smartsoltech/static/qr_codes/request_380.png deleted file mode 100644 index 7462e76..0000000 Binary files a/smartsoltech/static/qr_codes/request_380.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_381.png b/smartsoltech/static/qr_codes/request_381.png deleted file mode 100644 index 0d5d9f1..0000000 Binary files a/smartsoltech/static/qr_codes/request_381.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_382.png b/smartsoltech/static/qr_codes/request_382.png deleted file mode 100644 index 594faef..0000000 Binary files a/smartsoltech/static/qr_codes/request_382.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_383.png b/smartsoltech/static/qr_codes/request_383.png deleted file mode 100644 index de100a0..0000000 Binary files a/smartsoltech/static/qr_codes/request_383.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_384.png b/smartsoltech/static/qr_codes/request_384.png deleted file mode 100644 index f5477e9..0000000 Binary files a/smartsoltech/static/qr_codes/request_384.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_385.png b/smartsoltech/static/qr_codes/request_385.png deleted file mode 100644 index 1b5f303..0000000 Binary files a/smartsoltech/static/qr_codes/request_385.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_386.png b/smartsoltech/static/qr_codes/request_386.png deleted file mode 100644 index 205d603..0000000 Binary files a/smartsoltech/static/qr_codes/request_386.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_387.png b/smartsoltech/static/qr_codes/request_387.png deleted file mode 100644 index 99fddf1..0000000 Binary files a/smartsoltech/static/qr_codes/request_387.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_388.png b/smartsoltech/static/qr_codes/request_388.png deleted file mode 100644 index fc89186..0000000 Binary files a/smartsoltech/static/qr_codes/request_388.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_389.png b/smartsoltech/static/qr_codes/request_389.png deleted file mode 100644 index 091213a..0000000 Binary files a/smartsoltech/static/qr_codes/request_389.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_390.png b/smartsoltech/static/qr_codes/request_390.png deleted file mode 100644 index f4c6926..0000000 Binary files a/smartsoltech/static/qr_codes/request_390.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_391.png b/smartsoltech/static/qr_codes/request_391.png deleted file mode 100644 index 00f409a..0000000 Binary files a/smartsoltech/static/qr_codes/request_391.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_392.png b/smartsoltech/static/qr_codes/request_392.png deleted file mode 100644 index 18acd10..0000000 Binary files a/smartsoltech/static/qr_codes/request_392.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_393.png b/smartsoltech/static/qr_codes/request_393.png deleted file mode 100644 index 5815aae..0000000 Binary files a/smartsoltech/static/qr_codes/request_393.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_394.png b/smartsoltech/static/qr_codes/request_394.png deleted file mode 100644 index e78b9a9..0000000 Binary files a/smartsoltech/static/qr_codes/request_394.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_395.png b/smartsoltech/static/qr_codes/request_395.png deleted file mode 100644 index 10871cd..0000000 Binary files a/smartsoltech/static/qr_codes/request_395.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_396.png b/smartsoltech/static/qr_codes/request_396.png deleted file mode 100644 index 43b8d00..0000000 Binary files a/smartsoltech/static/qr_codes/request_396.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_397.png b/smartsoltech/static/qr_codes/request_397.png deleted file mode 100644 index c948f27..0000000 Binary files a/smartsoltech/static/qr_codes/request_397.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_398.png b/smartsoltech/static/qr_codes/request_398.png deleted file mode 100644 index 97fd34e..0000000 Binary files a/smartsoltech/static/qr_codes/request_398.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_399.png b/smartsoltech/static/qr_codes/request_399.png deleted file mode 100644 index 1ed790e..0000000 Binary files a/smartsoltech/static/qr_codes/request_399.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_4.png b/smartsoltech/static/qr_codes/request_4.png new file mode 100644 index 0000000..5ca5005 Binary files /dev/null and b/smartsoltech/static/qr_codes/request_4.png differ diff --git a/smartsoltech/static/qr_codes/request_400.png b/smartsoltech/static/qr_codes/request_400.png deleted file mode 100644 index c417152..0000000 Binary files a/smartsoltech/static/qr_codes/request_400.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_401.png b/smartsoltech/static/qr_codes/request_401.png deleted file mode 100644 index 3500aa0..0000000 Binary files a/smartsoltech/static/qr_codes/request_401.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_402.png b/smartsoltech/static/qr_codes/request_402.png deleted file mode 100644 index e50a096..0000000 Binary files a/smartsoltech/static/qr_codes/request_402.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_403.png b/smartsoltech/static/qr_codes/request_403.png deleted file mode 100644 index 36ba848..0000000 Binary files a/smartsoltech/static/qr_codes/request_403.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_404.png b/smartsoltech/static/qr_codes/request_404.png deleted file mode 100644 index 92b63e9..0000000 Binary files a/smartsoltech/static/qr_codes/request_404.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_405.png b/smartsoltech/static/qr_codes/request_405.png deleted file mode 100644 index 00dfff9..0000000 Binary files a/smartsoltech/static/qr_codes/request_405.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_406.png b/smartsoltech/static/qr_codes/request_406.png deleted file mode 100644 index 54516a7..0000000 Binary files a/smartsoltech/static/qr_codes/request_406.png and /dev/null differ diff --git a/smartsoltech/static/qr_codes/request_5.png b/smartsoltech/static/qr_codes/request_5.png new file mode 100644 index 0000000..becf1af Binary files /dev/null and b/smartsoltech/static/qr_codes/request_5.png differ diff --git a/smartsoltech/static/qr_codes/request_6.png b/smartsoltech/static/qr_codes/request_6.png new file mode 100644 index 0000000..926a658 Binary files /dev/null and b/smartsoltech/static/qr_codes/request_6.png differ diff --git a/smartsoltech/web/templates/web/about.html b/smartsoltech/web/templates/web/about.html index 2add32f..a6700c8 100644 --- a/smartsoltech/web/templates/web/about.html +++ b/smartsoltech/web/templates/web/about.html @@ -7,7 +7,7 @@

Contact us

-

Curae hendrerit donec commodo hendrerit egestas tempus, turpis facilisis nostra nunc. Vestibulum dui eget ultrices.

+

@@ -28,7 +28,7 @@
Email
-

a.choI@smartsoltech.kr

+

a.choi@smartsoltech.kr

diff --git a/smartsoltech/web/templates/web/base.html b/smartsoltech/web/templates/web/base.html index 71fdda8..69ff0b9 100644 --- a/smartsoltech/web/templates/web/base.html +++ b/smartsoltech/web/templates/web/base.html @@ -9,7 +9,6 @@ - {% block title %}Smartsoltech{% endblock %} diff --git a/smartsoltech/web/templates/web/header.html b/smartsoltech/web/templates/web/header.html index 45bccf8..3076083 100644 --- a/smartsoltech/web/templates/web/header.html +++ b/smartsoltech/web/templates/web/header.html @@ -10,10 +10,10 @@ Главная
diff --git a/smartsoltech/web/templates/web/navbar.html b/smartsoltech/web/templates/web/navbar.html index 4e0f0c0..8f67d03 100644 --- a/smartsoltech/web/templates/web/navbar.html +++ b/smartsoltech/web/templates/web/navbar.html @@ -6,9 +6,8 @@ SmartSolTech diff --git a/update_bot_token.sh b/update_bot_token.sh new file mode 100755 index 0000000..437a110 --- /dev/null +++ b/update_bot_token.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# Скрипт для обновления токена Telegram бота +# Использование: ./update_bot_token.sh "НОВЫЙ_ТОКЕН" + +if [ $# -eq 0 ]; then + echo "❌ Ошибка: Необходимо указать токен" + echo "Использование: $0 \"НОВЫЙ_ТОКЕН\"" + echo "" + echo "Пример: $0 \"1234567890:ABCDEFghijklmnopqrstuvwxyz\"" + echo "" + echo "Получите токен от @BotFather в Telegram:" + echo "1. Отправьте /mybots" + echo "2. Выберите своего бота" + echo "3. Нажмите 'API Token'" + exit 1 +fi + +NEW_TOKEN="$1" + +echo "🔄 Обновление токена Telegram бота..." + +# Проверяем валидность токена +echo "🔍 Проверка валидности токена..." +RESPONSE=$(curl -s "https://api.telegram.org/bot${NEW_TOKEN}/getMe") +if echo "$RESPONSE" | grep -q '"ok":true'; then + BOT_USERNAME=$(echo "$RESPONSE" | grep -o '"username":"[^"]*"' | cut -d'"' -f4) + echo "✅ Токен валиден! Бот: @${BOT_USERNAME}" +else + echo "❌ Ошибка: Токен невалиден!" + echo "Ответ API: $RESPONSE" + exit 1 +fi + +# Обновляем токен в базе данных +echo "💾 Обновление токена в базе данных..." +docker exec postgres_db psql -U trevor -d 2st_db -c " +UPDATE comunication_telegramsettings +SET bot_token = '$NEW_TOKEN', bot_name = '@${BOT_USERNAME}' +WHERE id = 1; +" + +if [ $? -eq 0 ]; then + echo "✅ Токен успешно обновлен в базе данных!" + echo "🔄 Перезапуск контейнера telegram_bot..." + docker restart telegram_bot + echo "🎉 Готово! Проверьте логи: docker logs telegram_bot" +else + echo "❌ Ошибка при обновлении базы данных" + exit 1 +fi \ No newline at end of file diff --git a/update_telegram_token.py b/update_telegram_token.py new file mode 100644 index 0000000..f182dfd --- /dev/null +++ b/update_telegram_token.py @@ -0,0 +1,104 @@ +#!/usr/bin/env python3 +""" +Скрипт для обновления токена Telegram бота в базе данных +""" +import os +import sys +import django +import requests + +# Настройка Django +sys.path.append('/app/smartsoltech') +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'smartsoltech.settings') +django.setup() + +from comunication.models import TelegramSettings + +def validate_token(token): + """Проверяет валидность токена через Telegram API""" + url = f"https://api.telegram.org/bot{token}/getMe" + try: + response = requests.get(url, timeout=10) + return response.json().get('ok', False) + except requests.RequestException: + return False + +def update_telegram_token(new_token, bot_name=None): + """Обновляет токен Telegram бота в базе данных""" + + # Проверяем валидность токена + if not validate_token(new_token): + print(f"❌ Ошибка: Токен {new_token} невалиден!") + return False + + # Получаем информацию о боте + url = f"https://api.telegram.org/bot{new_token}/getMe" + response = requests.get(url) + bot_info = response.json() + + if bot_info.get('ok'): + bot_username = bot_info['result']['username'] + print(f"✅ Токен валиден. Бот: @{bot_username}") + + # Обновляем настройки в базе данных + telegram_settings, created = TelegramSettings.objects.get_or_create( + id=1, + defaults={ + 'bot_name': f"@{bot_username}", + 'bot_token': new_token, + 'use_polling': True + } + ) + + if not created: + telegram_settings.bot_token = new_token + telegram_settings.bot_name = bot_name or f"@{bot_username}" + telegram_settings.save() + print(f"✅ Токен обновлен в базе данных для бота {telegram_settings.bot_name}") + else: + print(f"✅ Создана новая запись для бота @{bot_username}") + + return True + else: + print(f"❌ Ошибка при получении информации о боте") + return False + +if __name__ == "__main__": + print("🤖 Скрипт обновления токена Telegram бота") + print("=" * 50) + + # Проверяем текущий токен + try: + current_settings = TelegramSettings.objects.first() + if current_settings: + print(f"Текущий бот: {current_settings.bot_name}") + print(f"Текущий токен: {current_settings.bot_token[:10]}...") + + if not validate_token(current_settings.bot_token): + print("❌ Текущий токен невалиден") + else: + print("✅ Текущий токен валиден") + else: + print("⚠️ Настройки Telegram бота не найдены") + except Exception as e: + print(f"❌ Ошибка при проверке текущих настроек: {e}") + + print("\n" + "=" * 50) + print("Для обновления токена:") + print("1. Идите к @BotFather в Telegram") + print("2. Создайте нового бота или используйте /token для существующего") + print("3. Скопируйте токен и введите его ниже") + print("=" * 50) + + new_token = input("\nВведите новый токен бота (или 'exit' для выхода): ").strip() + + if new_token.lower() == 'exit': + print("Выход...") + sys.exit(0) + + if update_telegram_token(new_token): + print("\n🎉 Токен успешно обновлен!") + print("Теперь перезапустите контейнер telegram_bot:") + print("docker restart telegram_bot") + else: + print("\n❌ Не удалось обновить токен") \ No newline at end of file