diff --git a/.gitignore b/.gitignore index 86c40a3..4719771 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,146 @@ /Документы/База.drawio /Документы/ТЗ.docx + +#django project +/venv/ +/.idea/ +/.vscode/ +/__pycache__/ +/.env/ +/.env +/lyceum/db.sqlite3 +/erd.txt +/lyceum/send_mail + +# 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 +*.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 +.pdm.toml + +# 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/ + +/.dev/ +/.prod/ +/.test/ +/er.txt diff --git a/CineSync/CineSync/settings.py b/CineSync/CineSync/settings.py index 5b8f9b8..de8df23 100644 --- a/CineSync/CineSync/settings.py +++ b/CineSync/CineSync/settings.py @@ -1,42 +1,34 @@ -""" -Django settings for CineSync project. - -Generated by 'django-admin startproject' using Django 4.2. - -For more information on this file, see -https://docs.djangoproject.com/en/4.2/topics/settings/ - -For the full list of settings and their values, see -https://docs.djangoproject.com/en/4.2/ref/settings/ -""" - +import os from pathlib import Path +from dotenv import load_dotenv -# Build paths inside the project like this: BASE_DIR / 'subdir'. +load_dotenv() BASE_DIR = Path(__file__).resolve().parent.parent +SECRET_KEY = os.environ.get("DJANGO_SECRET_KEY", default="google") -# Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/ +DEBUG = os.environ.get("DJANGO_DEBUG", default="false") +DEBUG = DEBUG.lower().strip() in ("true", "yes", "1", "y", "t") -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'django-insecure-!ht+z5!qp#ln(@f%%cqs7yokqa0vk38qe5q%%@a)ga*$pmoxh)' - -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +AUTH_USER_MODEL = "auth.User" ALLOWED_HOSTS = [] - -# Application definition - INSTALLED_APPS = [ + 'films.apps.FilmsConfig', + 'home.apps.HomeConfig', + 'tickets.apps.TicketsConfig', + 'timetable.apps.TimetableConfig', + 'users.apps.UsersConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + "sorl.thumbnail", + "ckeditor", + "django_cleanup.apps.CleanupConfig", ] MIDDLEWARE = [ @@ -49,12 +41,22 @@ MIDDLEWARE = [ 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] +if DEBUG: + INSTALLED_APPS += [ + "debug_toolbar", + ] + MIDDLEWARE += [ + "debug_toolbar.middleware.DebugToolbarMiddleware", + ] + ROOT_URLCONF = 'CineSync.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], + 'DIRS': [ + BASE_DIR / "templates", + ], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ @@ -67,12 +69,14 @@ TEMPLATES = [ }, ] +INTERNAL_IPS = [ + "127.0.0.1", + "localhost", + "*", +] + WSGI_APPLICATION = 'CineSync.wsgi.application' - -# Database -# https://docs.djangoproject.com/en/4.2/ref/settings/#databases - DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', @@ -80,10 +84,6 @@ DATABASES = { } } - -# Password validation -# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators - AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', @@ -99,11 +99,7 @@ AUTH_PASSWORD_VALIDATORS = [ }, ] - -# Internationalization -# https://docs.djangoproject.com/en/4.2/topics/i18n/ - -LANGUAGE_CODE = 'en-us' +LANGUAGE_CODE = 'ru' TIME_ZONE = 'UTC' @@ -111,13 +107,16 @@ USE_I18N = True USE_TZ = True - -# Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/4.2/howto/static-files/ - STATIC_URL = 'static/' -# Default primary key field type -# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field - DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' + +MEDIA_URL = "/media/" + +MEDIA_ROOT = BASE_DIR / "media" + +LOGIN_URL = "/users/login/" + +LOGIN_REDIRECT_URL = "/" + +LOGOUT_REDIRECT_URL = "/users/login/" diff --git a/CineSync/users/models.py b/CineSync/users/models.py index 71a8362..7da5429 100644 --- a/CineSync/users/models.py +++ b/CineSync/users/models.py @@ -1,3 +1,19 @@ -from django.db import models +from django.conf import settings +from django.db.models import Model, OneToOneField, CASCADE, DateField, CharField -# Create your models here. + +class Profile(Model): + user = OneToOneField( + settings.AUTH_USER_MODEL, + verbose_name='пользователь', + related_name='profile', + related_query_name='profile', + on_delete=CASCADE, + ) + birthday = DateField( + null=True, + blank=True, + ) + role = CharField( + verbose_name='роль пользователя', + ) diff --git a/requirements/dev.txt b/requirements/dev.txt new file mode 100644 index 0000000..41da87c --- /dev/null +++ b/requirements/dev.txt @@ -0,0 +1,3 @@ +-r prod.txt +black==24.1.1 +django-debug-toolbar==4.3.0 \ No newline at end of file diff --git a/requirements/prod.txt b/requirements/prod.txt new file mode 100644 index 0000000..ec20c50 --- /dev/null +++ b/requirements/prod.txt @@ -0,0 +1,6 @@ +Django==4.2 +django-ckeditor==6.7.0 +django-cleanup==8.1.0 +pillow==10.2.0 +python-dotenv~=1.0.1 +sorl-thumbnail==12.10.0 \ No newline at end of file diff --git a/requirements/test.txt b/requirements/test.txt new file mode 100644 index 0000000..81e20aa --- /dev/null +++ b/requirements/test.txt @@ -0,0 +1,11 @@ +-r prod.txt +flake8==7.0.0 +flake8-bugbear==24.2.6 +flake8-clean-block==0.1.2 +flake8-commas==2.1.0 +flake8-expression-complexity==0.0.11 +flake8-import-order==0.18.2 +flake8-quotes==3.3.2 +flake8-return==1.2.0 +parameterized==0.9.0 +pep8-naming==0.13.3 \ No newline at end of file diff --git a/Документы/База.drawio.png b/Документы/База.drawio.png index 98576ac..0a2b3dd 100644 Binary files a/Документы/База.drawio.png and b/Документы/База.drawio.png differ