|
| 1 | +""" |
| 2 | +Django settings for mybot project. |
| 3 | +
|
| 4 | +Generated by 'django-admin startproject' using Django 3.2.6. |
| 5 | +
|
| 6 | +For more information on this file, see |
| 7 | +https://docs.djangoproject.com/en/3.2/topics/settings/ |
| 8 | +
|
| 9 | +For the full list of settings and their values, see |
| 10 | +https://docs.djangoproject.com/en/3.2/ref/settings/ |
| 11 | +""" |
| 12 | + |
| 13 | +import os |
| 14 | +from pathlib import Path |
| 15 | + |
| 16 | +import dj_database_url |
| 17 | + |
| 18 | + |
| 19 | +# Build paths inside the project like this: BASE_DIR / 'subdir'. |
| 20 | +BASE_DIR = Path(__file__).resolve().parent.parent |
| 21 | + |
| 22 | + |
| 23 | +# Quick-start development settings - unsuitable for production |
| 24 | +# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ |
| 25 | + |
| 26 | +# SECURITY WARNING: keep the secret key used in production secret! |
| 27 | +SECRET_KEY = os.environ.get("DJANGO_SECRET_KEY", 'SOME_KIND_OF_KEY') |
| 28 | + |
| 29 | +# SECURITY WARNING: don't run with debug turned on in production! |
| 30 | +DEBUG = os.environ.get("DJANGO_DEBUG", True) != "False" |
| 31 | + |
| 32 | +ALLOWED_HOSTS = ['mipt-faltbot.herokuapp.com', '127.0.0.1'] |
| 33 | + |
| 34 | + |
| 35 | +# Application definition |
| 36 | + |
| 37 | +INSTALLED_APPS = [ |
| 38 | + 'django.contrib.admin', |
| 39 | + 'django.contrib.auth', |
| 40 | + 'django.contrib.contenttypes', |
| 41 | + 'django.contrib.sessions', |
| 42 | + 'django.contrib.messages', |
| 43 | + 'django.contrib.staticfiles', |
| 44 | + 'vk_bot.apps.VkBotConfig', |
| 45 | +] |
| 46 | + |
| 47 | +MIDDLEWARE = [ |
| 48 | + 'django.middleware.security.SecurityMiddleware', |
| 49 | + 'whitenoise.middleware.WhiteNoiseMiddleware', |
| 50 | + 'django.contrib.sessions.middleware.SessionMiddleware', |
| 51 | + 'django.middleware.common.CommonMiddleware', |
| 52 | + 'django.middleware.csrf.CsrfViewMiddleware', |
| 53 | + 'django.contrib.auth.middleware.AuthenticationMiddleware', |
| 54 | + 'django.contrib.messages.middleware.MessageMiddleware', |
| 55 | + 'django.middleware.clickjacking.XFrameOptionsMiddleware', |
| 56 | +] |
| 57 | + |
| 58 | +ROOT_URLCONF = 'mybot.urls' |
| 59 | + |
| 60 | +TEMPLATES = [ |
| 61 | + { |
| 62 | + 'BACKEND': 'django.template.backends.django.DjangoTemplates', |
| 63 | + 'DIRS': [BASE_DIR / 'templates'] |
| 64 | + , |
| 65 | + 'APP_DIRS': True, |
| 66 | + 'OPTIONS': { |
| 67 | + 'context_processors': [ |
| 68 | + 'django.template.context_processors.debug', |
| 69 | + 'django.template.context_processors.request', |
| 70 | + 'django.contrib.auth.context_processors.auth', |
| 71 | + 'django.contrib.messages.context_processors.messages', |
| 72 | + ], |
| 73 | + }, |
| 74 | + }, |
| 75 | +] |
| 76 | + |
| 77 | +WSGI_APPLICATION = 'mybot.wsgi.application' |
| 78 | + |
| 79 | + |
| 80 | +# Database |
| 81 | +# https://docs.djangoproject.com/en/3.2/ref/settings/#databases |
| 82 | + |
| 83 | +DATABASES = { |
| 84 | + 'default': { |
| 85 | + 'ENGINE': 'django.db.backends.sqlite3', |
| 86 | + 'NAME': BASE_DIR / 'db.sqlite3', |
| 87 | + } |
| 88 | +} |
| 89 | + |
| 90 | +# Heroku: Update database configuration from $DATABASE_URL. |
| 91 | +db_from_env = dj_database_url.config(conn_max_age=500) |
| 92 | +DATABASES['default'].update(db_from_env) |
| 93 | + |
| 94 | + |
| 95 | +# Password validation |
| 96 | +# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators |
| 97 | + |
| 98 | +AUTH_PASSWORD_VALIDATORS = [ |
| 99 | + { |
| 100 | + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', |
| 101 | + }, |
| 102 | + { |
| 103 | + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', |
| 104 | + }, |
| 105 | + { |
| 106 | + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', |
| 107 | + }, |
| 108 | + { |
| 109 | + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', |
| 110 | + }, |
| 111 | +] |
| 112 | + |
| 113 | + |
| 114 | +# Internationalization |
| 115 | +# https://docs.djangoproject.com/en/3.2/topics/i18n/ |
| 116 | + |
| 117 | +LANGUAGE_CODE = 'en-us' |
| 118 | + |
| 119 | +TIME_ZONE = 'Europe/Moscow' |
| 120 | + |
| 121 | +USE_I18N = True |
| 122 | + |
| 123 | +USE_L10N = True |
| 124 | + |
| 125 | +USE_TZ = True |
| 126 | + |
| 127 | + |
| 128 | +# Static files (CSS, JavaScript, Images) |
| 129 | +# https://docs.djangoproject.com/en/3.2/howto/static-files/ |
| 130 | + |
| 131 | + |
| 132 | +# The absolute path to the directory where collectstatic will collect static files for deployment. |
| 133 | +STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') |
| 134 | + |
| 135 | +# The URL to use when referring to static files (where they will be served from) |
| 136 | +STATIC_URL = '/static/' |
| 137 | + |
| 138 | +# Default primary key field type |
| 139 | +# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field |
| 140 | + |
| 141 | +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' |
| 142 | + |
| 143 | +# Simplified static file serving. |
| 144 | +# https://warehouse.python.org/project/whitenoise/ |
| 145 | +STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' |
| 146 | + |
| 147 | + |
| 148 | +# VK Callback API Settings |
| 149 | +VK_SECRET_KEY = os.environ.get("VK_SECRET_KEY", "YOUR_SECRET_KEY") |
| 150 | +ACCESS_TOKEN = os.environ.get("ACCESS_TOKEN", "YOUR_ACCESS_TOKEN") |
| 151 | +VK_CONFIRMATION_CODE = os.environ.get("VK_CONFIRMATION_CODE", "YOUR_CONFIRMATION_CODE") |
| 152 | +API_VERSION = 5.131 |
| 153 | + |
| 154 | + |
| 155 | +# VK Keyboard settings |
| 156 | +MAX_BUTTONS_ON_LINE = 5 |
| 157 | +MAX_INLINE_LINES = 6 |
| 158 | +MAX_DEFAULT_LINES = 10 |
| 159 | + |
| 160 | + |
| 161 | +# Response settings |
| 162 | +SCHEDULE_ENABLED = os.environ.get("SCHEDULE_ENABLED", False) == 'True' |
| 163 | +LINKS_ENABLED = os.environ.get("LINKS_ENABLED", False) == 'True' |
| 164 | + |
| 165 | +VK_ADMIN_ID = 174445151 |
| 166 | +GROUP_ID = 202550577 |
| 167 | + |
| 168 | + |
| 169 | + |
0 commit comments