From f09b90f63ef6ed2f0e8288aae0c5ee32fb4ffe09 Mon Sep 17 00:00:00 2001 From: "Andrey K. Choi" Date: Fri, 8 Aug 2025 09:23:57 +0900 Subject: [PATCH] init commit --- .gitignore | 179 ++++++++++++++++++++++++++++++ bin/backup.sh | 16 +++ bin/cli.sh | 12 ++ bin/deploy.sh | 30 +++++ bin/restart.sh | 5 + bin/start.sh | 4 + bin/stop.sh | 4 + bin/update.sh | 16 +++ bot/__init__.py | 0 bot/admin.py | 3 + bot/apps.py | 6 + bot/migrations/__init__.py | 0 bot/models.py | 3 + bot/tests.py | 3 + bot/views.py | 3 + database/__init__.py | 0 database/admin.py | 3 + database/apps.py | 6 + database/migrations/__init__.py | 0 database/models.py | 3 + database/tests.py | 3 + database/views.py | 3 + docker-compose.yml | 83 ++++++++++++++ docker/bot/Dockerfile | 15 +++ docker/celery/Dockerfile | 15 +++ docker/db/Dockerfile | 2 + docker/main/Dockerfile | 17 +++ docker/utils/Dockerfile | 21 ++++ drone.yml | 50 +++++++++ manage.py | 22 ++++ scheduller/__init__.py | 0 scheduller/admin.py | 3 + scheduller/apps.py | 6 + scheduller/migrations/__init__.py | 0 scheduller/models.py | 3 + scheduller/tests.py | 3 + scheduller/views.py | 3 + tg_autopost/__init__.py | 0 tg_autopost/asgi.py | 16 +++ tg_autopost/settings.py | 122 ++++++++++++++++++++ tg_autopost/urls.py | 22 ++++ tg_autopost/wsgi.py | 16 +++ utils/__init__.py | 0 utils/admin.py | 3 + utils/apps.py | 6 + utils/migrations/__init__.py | 0 utils/models.py | 3 + utils/tests.py | 3 + utils/views.py | 3 + webapp/__init__.py | 0 webapp/admin.py | 3 + webapp/apps.py | 6 + webapp/migrations/__init__.py | 0 webapp/models.py | 3 + webapp/tests.py | 3 + webapp/views.py | 3 + 56 files changed, 757 insertions(+) create mode 100644 .gitignore create mode 100755 bin/backup.sh create mode 100755 bin/cli.sh create mode 100755 bin/deploy.sh create mode 100755 bin/restart.sh create mode 100755 bin/start.sh create mode 100755 bin/stop.sh create mode 100755 bin/update.sh create mode 100644 bot/__init__.py create mode 100644 bot/admin.py create mode 100644 bot/apps.py create mode 100644 bot/migrations/__init__.py create mode 100644 bot/models.py create mode 100644 bot/tests.py create mode 100644 bot/views.py create mode 100644 database/__init__.py create mode 100644 database/admin.py create mode 100644 database/apps.py create mode 100644 database/migrations/__init__.py create mode 100644 database/models.py create mode 100644 database/tests.py create mode 100644 database/views.py create mode 100644 docker-compose.yml create mode 100644 docker/bot/Dockerfile create mode 100644 docker/celery/Dockerfile create mode 100644 docker/db/Dockerfile create mode 100644 docker/main/Dockerfile create mode 100644 docker/utils/Dockerfile create mode 100644 drone.yml create mode 100755 manage.py create mode 100644 scheduller/__init__.py create mode 100644 scheduller/admin.py create mode 100644 scheduller/apps.py create mode 100644 scheduller/migrations/__init__.py create mode 100644 scheduller/models.py create mode 100644 scheduller/tests.py create mode 100644 scheduller/views.py create mode 100644 tg_autopost/__init__.py create mode 100644 tg_autopost/asgi.py create mode 100644 tg_autopost/settings.py create mode 100644 tg_autopost/urls.py create mode 100644 tg_autopost/wsgi.py create mode 100644 utils/__init__.py create mode 100644 utils/admin.py create mode 100644 utils/apps.py create mode 100644 utils/migrations/__init__.py create mode 100644 utils/models.py create mode 100644 utils/tests.py create mode 100644 utils/views.py create mode 100644 webapp/__init__.py create mode 100644 webapp/admin.py create mode 100644 webapp/apps.py create mode 100644 webapp/migrations/__init__.py create mode 100644 webapp/models.py create mode 100644 webapp/tests.py create mode 100644 webapp/views.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..573bf97 --- /dev/null +++ b/.gitignore @@ -0,0 +1,179 @@ +# ---> Python +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# UV +# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +#uv.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/latest/usage/project/#working-with-version-control +.pdm.toml +.pdm-python +.pdm-build/ + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + +# Ruff stuff: +.ruff_cache/ + +# PyPI configuration file +.pypirc + +.history/ +.venv/ +.env diff --git a/bin/backup.sh b/bin/backup.sh new file mode 100755 index 0000000..a064671 --- /dev/null +++ b/bin/backup.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -e + +BACKUP_DIR="./backups" +TIMESTAMP=$(date +"%Y-%m-%d_%H-%M-%S") +FILENAME="backup_${TIMESTAMP}.sql" + +mkdir -p $BACKUP_DIR + +echo "💾 Делаем бэкап базы..." +docker compose exec db mysqldump -u"$DB_USER" -p"$DB_PASSWORD" "$DB_NAME" > "${BACKUP_DIR}/${FILENAME}" + +echo "✅ Бэкап сохранён: ${BACKUP_DIR}/${FILENAME}" +echo "📦 Архивируем бэкап..." +tar -czf "${BACKUP_DIR}/${FILENAME}.tar.gz" -C "$BACKUP_DIR" "$FILENAME" +echo "✅ Бэкап архивирован: ${BACKUP_DIR}/${FILENAME}.tar.gz" \ No newline at end of file diff --git a/bin/cli.sh b/bin/cli.sh new file mode 100755 index 0000000..deb6391 --- /dev/null +++ b/bin/cli.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# Запуск произвольной команды внутри контейнера Django + +CONTAINER="django" + +if [ -z "$1" ]; then + echo "Использование: ./scripts/cli.sh <команда>" + echo "Пример: ./scripts/cli.sh python manage.py migrate" + exit 1 +fi + +docker compose exec $CONTAINER "$@" diff --git a/bin/deploy.sh b/bin/deploy.sh new file mode 100755 index 0000000..76852df --- /dev/null +++ b/bin/deploy.sh @@ -0,0 +1,30 @@ +#!/bin/bash +set -e + +# Загружаем переменные окружения +source .env + +BACKUP_DIR="./backups" +TIMESTAMP=$(date +"%Y-%m-%d_%H-%M-%S") +FILENAME="backup_${TIMESTAMP}.sql" + +echo "💾 1. Создаём бэкап базы..." +mkdir -p $BACKUP_DIR +docker compose exec db mysqldump -u"$DB_USER" -p"$DB_PASSWORD" "$DB_NAME" > "${BACKUP_DIR}/${FILENAME}" +echo "✅ Бэкап сохранён: ${BACKUP_DIR}/${FILENAME}" + +echo "📥 2. Получаем обновления из git..." +git pull + +echo "🔨 3. Собираем контейнеры..." +docker compose build + +echo "⬆ 4. Применяем миграции..." +docker compose exec django python manage.py migrate + +echo "🔄 5. Перезапускаем сервисы..." +docker compose down +docker compose up -d + +echo "🎉 Деплой завершён успешно!" +echo "✅ Все операции выполнены успешно." \ No newline at end of file diff --git a/bin/restart.sh b/bin/restart.sh new file mode 100755 index 0000000..f42c911 --- /dev/null +++ b/bin/restart.sh @@ -0,0 +1,5 @@ +#!/bin/bash +echo "🔄 Перезапуск контейнеров..." +docker compose down +docker compose up -d +echo "✅ Контейнеры перезапущены." \ No newline at end of file diff --git a/bin/start.sh b/bin/start.sh new file mode 100755 index 0000000..c76ad17 --- /dev/null +++ b/bin/start.sh @@ -0,0 +1,4 @@ +#!/bin/bash +echo "🚀 Запуск контейнеров..." +docker compose up -d +echo "✅ Контейнеры запущены." \ No newline at end of file diff --git a/bin/stop.sh b/bin/stop.sh new file mode 100755 index 0000000..52f77f4 --- /dev/null +++ b/bin/stop.sh @@ -0,0 +1,4 @@ +#!/bin/bash +echo "🛑 Остановка контейнеров..." +docker compose down +echo "✅ Контейнеры остановлены." \ No newline at end of file diff --git a/bin/update.sh b/bin/update.sh new file mode 100755 index 0000000..b173e31 --- /dev/null +++ b/bin/update.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -e + +echo "📥 Получаем обновления..." +git pull + +echo "🔨 Собираем контейнеры..." +docker compose build + +echo "⬆ Обновляем БД..." +docker compose exec django python manage.py migrate + +echo "🚀 Запускаем контейнеры..." +docker compose up -d + +echo "✅ Обновление завершено." diff --git a/bot/__init__.py b/bot/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bot/admin.py b/bot/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/bot/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/bot/apps.py b/bot/apps.py new file mode 100644 index 0000000..1cd7ff2 --- /dev/null +++ b/bot/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class BotConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'bot' diff --git a/bot/migrations/__init__.py b/bot/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bot/models.py b/bot/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/bot/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/bot/tests.py b/bot/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/bot/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/bot/views.py b/bot/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/bot/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/database/__init__.py b/database/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/database/admin.py b/database/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/database/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/database/apps.py b/database/apps.py new file mode 100644 index 0000000..d047741 --- /dev/null +++ b/database/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class DatabaseConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'database' diff --git a/database/migrations/__init__.py b/database/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/database/models.py b/database/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/database/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/database/tests.py b/database/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/database/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/database/views.py b/database/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/database/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..817e36a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,83 @@ +version: "3.9" + +services: + db: + build: + context: . + dockerfile: docker/db/Dockerfile + container_name: mariadb + restart: unless-stopped + environment: + MYSQL_ROOT_PASSWORD: rootpass + MYSQL_DATABASE: tg_autopost + MYSQL_USER: tguser + MYSQL_PASSWORD: tgpass + ports: + - "3306:3306" + volumes: + - ./app/var/lib/mysql:/var/lib/mysql + + redis: + image: redis:7.2 + container_name: redis + restart: unless-stopped + ports: + - "6379:6379" + + django: + build: + context: . + dockerfile: docker/main/Dockerfile + container_name: django + command: python manage.py runserver 0.0.0.0:8000 + volumes: + - ./app:/app + ports: + - "8000:8000" + env_file: + - .env + depends_on: + - db + - redis + + bot: + build: + context: . + dockerfile: docker/bot/Dockerfile + container_name: bot + command: python manage.py runbot + volumes: + - ./app:/app + env_file: + - .env + depends_on: + - db + - redis + + celery_worker: + build: + context: . + dockerfile: docker/celery/Dockerfile + container_name: celery_worker + command: celery -A tg_autopost worker -l info + volumes: + - ./app:/app + env_file: + - .env + depends_on: + - db + - redis + + celery_beat: + build: + context: . + dockerfile: docker/celery/Dockerfile + container_name: celery_beat + command: celery -A tg_autopost beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler + volumes: + - ./app:/app + env_file: + - .env + depends_on: + - db + - redis diff --git a/docker/bot/Dockerfile b/docker/bot/Dockerfile new file mode 100644 index 0000000..c1961de --- /dev/null +++ b/docker/bot/Dockerfile @@ -0,0 +1,15 @@ +FROM python:3.12-slim + +WORKDIR /app + +RUN apt-get update && apt-get install -y \ + build-essential \ + libmariadb-dev \ + libmariadb-dev-compat \ + pkg-config \ + && rm -rf /var/lib/apt/lists/* + +COPY requirements.txt /app/ +RUN pip install --no-cache-dir -r requirements.txt + +COPY app /app diff --git a/docker/celery/Dockerfile b/docker/celery/Dockerfile new file mode 100644 index 0000000..c1961de --- /dev/null +++ b/docker/celery/Dockerfile @@ -0,0 +1,15 @@ +FROM python:3.12-slim + +WORKDIR /app + +RUN apt-get update && apt-get install -y \ + build-essential \ + libmariadb-dev \ + libmariadb-dev-compat \ + pkg-config \ + && rm -rf /var/lib/apt/lists/* + +COPY requirements.txt /app/ +RUN pip install --no-cache-dir -r requirements.txt + +COPY app /app diff --git a/docker/db/Dockerfile b/docker/db/Dockerfile new file mode 100644 index 0000000..feea25c --- /dev/null +++ b/docker/db/Dockerfile @@ -0,0 +1,2 @@ +FROM mariadb:11.6 +COPY docker/db/conf.d /etc/mysql/conf.d diff --git a/docker/main/Dockerfile b/docker/main/Dockerfile new file mode 100644 index 0000000..fd68d7f --- /dev/null +++ b/docker/main/Dockerfile @@ -0,0 +1,17 @@ +FROM python:3.12-slim + +WORKDIR /app + +RUN apt-get update && apt-get install -y \ + build-essential \ + libmariadb-dev \ + libmariadb-dev-compat \ + pkg-config \ + && rm -rf /var/lib/apt/lists/* + +COPY requirements.txt /app/ +RUN pip install --no-cache-dir -r requirements.txt + +COPY app /app + +EXPOSE 8000 diff --git a/docker/utils/Dockerfile b/docker/utils/Dockerfile new file mode 100644 index 0000000..cd8a78f --- /dev/null +++ b/docker/utils/Dockerfile @@ -0,0 +1,21 @@ +FROM python:3.12-slim + +WORKDIR /app + +# Системные зависимости для mysqlclient и прочего +RUN apt-get update && apt-get install -y \ + build-essential \ + libmariadb-dev \ + libmariadb-dev-compat \ + pkg-config \ + && rm -rf /var/lib/apt/lists/* + +COPY requirements.txt /app/ +RUN pip install --no-cache-dir -r requirements.txt + +COPY . /app/ + +# Для Django collectstatic (если понадобится) +RUN mkdir -p /app/static && mkdir -p /app/media + +EXPOSE 8000 diff --git a/drone.yml b/drone.yml new file mode 100644 index 0000000..be55d76 --- /dev/null +++ b/drone.yml @@ -0,0 +1,50 @@ +kind: pipeline +type: docker +name: tg_autopost_deploy + +trigger: + branch: + - main + event: + - push + +steps: + - name: build + image: docker:26.1 + environment: + DOCKER_BUILDKIT: 1 + volumes: + - name: docker_sock + path: /var/run/docker.sock + commands: + - echo "🔨 Сборка и пуш образов..." + - docker compose -f docker-compose.yml build + + - name: test + image: python:3.12-slim + commands: + - pip install -r requirements.txt + - python manage.py test || echo "⚠ Тесты не настроены" + + - name: deploy + image: appleboy/drone-ssh + settings: + host: + from_secret: ssh_host + username: + from_secret: ssh_user + password: + from_secret: ssh_pass + port: 22 + script: + - cd /home/data/tg_autopost + - git pull + - docker compose build + - docker compose exec django python manage.py migrate + - docker compose down + - docker compose up -d + +volumes: + - name: docker_sock + host: + path: /var/run/docker.sock diff --git a/manage.py b/manage.py new file mode 100755 index 0000000..9126ee0 --- /dev/null +++ b/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tg_autopost.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/scheduller/__init__.py b/scheduller/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/scheduller/admin.py b/scheduller/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/scheduller/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/scheduller/apps.py b/scheduller/apps.py new file mode 100644 index 0000000..2e61054 --- /dev/null +++ b/scheduller/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class SchedullerConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'scheduller' diff --git a/scheduller/migrations/__init__.py b/scheduller/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/scheduller/models.py b/scheduller/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/scheduller/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/scheduller/tests.py b/scheduller/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/scheduller/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/scheduller/views.py b/scheduller/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/scheduller/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/tg_autopost/__init__.py b/tg_autopost/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tg_autopost/asgi.py b/tg_autopost/asgi.py new file mode 100644 index 0000000..5ceb631 --- /dev/null +++ b/tg_autopost/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for tg_autopost project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/5.2/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tg_autopost.settings') + +application = get_asgi_application() diff --git a/tg_autopost/settings.py b/tg_autopost/settings.py new file mode 100644 index 0000000..a81fc65 --- /dev/null +++ b/tg_autopost/settings.py @@ -0,0 +1,122 @@ +""" +Django settings for tg_autopost project. + +Generated by 'django-admin startproject' using Django 5.2.5. + +For more information on this file, see +https://docs.djangoproject.com/en/5.2/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/5.2/ref/settings/ +""" + +from pathlib import Path + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/5.2/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'django-insecure-&$8$$go%kyh9c3bdm+g0+w&ntem!nttra43ckixv1%=3hhsi)=' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'tg_autopost.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'tg_autopost.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/5.2/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/5.2/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/5.2/howto/static-files/ + +STATIC_URL = 'static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/tg_autopost/urls.py b/tg_autopost/urls.py new file mode 100644 index 0000000..d43ce89 --- /dev/null +++ b/tg_autopost/urls.py @@ -0,0 +1,22 @@ +""" +URL configuration for tg_autopost project. + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/5.2/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import path + +urlpatterns = [ + path('admin/', admin.site.urls), +] diff --git a/tg_autopost/wsgi.py b/tg_autopost/wsgi.py new file mode 100644 index 0000000..a0bb345 --- /dev/null +++ b/tg_autopost/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for tg_autopost project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/5.2/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tg_autopost.settings') + +application = get_wsgi_application() diff --git a/utils/__init__.py b/utils/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/utils/admin.py b/utils/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/utils/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/utils/apps.py b/utils/apps.py new file mode 100644 index 0000000..83e83de --- /dev/null +++ b/utils/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class UtilsConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'utils' diff --git a/utils/migrations/__init__.py b/utils/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/utils/models.py b/utils/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/utils/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/utils/tests.py b/utils/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/utils/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/utils/views.py b/utils/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/utils/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/webapp/__init__.py b/webapp/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/webapp/admin.py b/webapp/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/webapp/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/webapp/apps.py b/webapp/apps.py new file mode 100644 index 0000000..af0035d --- /dev/null +++ b/webapp/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class WebappConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'webapp' diff --git a/webapp/migrations/__init__.py b/webapp/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/webapp/models.py b/webapp/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/webapp/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/webapp/tests.py b/webapp/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/webapp/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/webapp/views.py b/webapp/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/webapp/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here.