· 5 years ago · Feb 25, 2020, 07:12 PM
1"""
2Django settings for dostavisor project.
3
4Generated by 'django-admin startproject' using Django 2.2.6.
5
6For more information on this file, see
7https://docs.djangoproject.com/en/2.2/topics/settings/
8
9For the full list of settings and their values, see
10https://docs.djangoproject.com/en/2.2/ref/settings/
11"""
12
13import os
14
15VERSION = "0.1.0"
16
17HERE_APP_ID = 'DWy97j1EoF1Ip9fiBrBZ'
18HERE_CODE = 'gigwGeNgysXTxlpxDi97AQ'
19
20# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
21BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
22
23
24# Quick-start development settings - unsuitable for production
25# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
26
27# SECURITY WARNING: keep the secret key used in production secret!
28SECRET_KEY = 'f&*$_7i92eih)=5sv1r9!guxporm&)!d2qp0sn=rctjg3gj)c3'
29
30# SECURITY WARNING: don't run with debug turned on in production!
31DEBUG = True
32
33ALLOWED_HOSTS = ['dostavizor.handh.ru', 'localhost']
34
35# Application definition
36
37INSTALLED_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 'rest_framework',
45 'rest_framework.authtoken',
46 'channels',
47 'dostavisor.api',
48 'dostavisor.common',
49]
50
51MIDDLEWARE = [
52 'django.middleware.security.SecurityMiddleware',
53 'django.contrib.sessions.middleware.SessionMiddleware',
54 'django.middleware.common.CommonMiddleware',
55 'django.middleware.csrf.CsrfViewMiddleware',
56 'django.contrib.auth.middleware.AuthenticationMiddleware',
57 'django.contrib.messages.middleware.MessageMiddleware',
58 'django.middleware.clickjacking.XFrameOptionsMiddleware',
59]
60
61ROOT_URLCONF = 'dostavisor.urls'
62
63TEMPLATES = [
64 {
65 'BACKEND': 'django.template.backends.django.DjangoTemplates',
66 'DIRS': [],
67 'APP_DIRS': True,
68 'OPTIONS': {
69 'context_processors': [
70 'django.template.context_processors.debug',
71 'django.template.context_processors.request',
72 'django.contrib.auth.context_processors.auth',
73 'django.contrib.messages.context_processors.messages',
74 ],
75 },
76 },
77]
78
79WSGI_APPLICATION = 'dostavisor.wsgi.application'
80
81
82# Database
83# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
84
85DATABASES = {
86 'default': {
87 'ENGINE': 'django.db.backends.postgresql',
88 'NAME': 'dostavisor',
89 'USER': 'dostavisor_user',
90 'HOST': 'db',
91 'PASSWORD': 'password',
92 'PORT': 5432,
93 }
94}
95
96CELERY_BROKER_URL = 'redis://localhost:6379/0'
97CELERY_RESULT_BACKEND = 'redis://localhost:6379/0'
98
99
100# Password validation
101# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
102
103AUTH_PASSWORD_VALIDATORS = [
104 {
105 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
106 },
107 {
108 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
109 },
110 {
111 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
112 },
113 {
114 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
115 },
116]
117
118REST_FRAMEWORK = {
119 'DEFAULT_AUTHENTICATION_CLASSES': (
120 'dostavisor.common.authentication.CustomTokenAuthentication',
121 ),
122 'DEFAULT_PERMISSION_CLASSES': (
123 'rest_framework.permissions.AllowAny',
124 ),
125 'EXCEPTION_HANDLER': 'dostavisor.common.exception.custom_exception_handler',
126 'TEST_REQUEST_DEFAULT_FORMAT': 'json',
127}
128
129
130# Internationalization
131# https://docs.djangoproject.com/en/2.2/topics/i18n/
132
133LANGUAGE_CODE = 'en-us'
134
135TIME_ZONE = 'UTC'
136
137USE_I18N = True
138
139USE_L10N = True
140
141# USE_TZ = True
142
143
144# Static files (CSS, JavaScript, Images)
145# https://docs.djangoproject.com/en/2.2/howto/static-files/
146
147STATIC_URL = '/static/'
148
149ASGI_APPLICATION = 'dostavisor.routing.application'
150
151CHANNEL_LAYERS = {
152 'default': {
153 # TODO switch on redis or rabbitmq
154 "BACKEND": "channels.layers.InMemoryChannelLayer"
155 # 'BACKEND': 'channels_redis.core.RedisChannelLayer',
156 # 'CONFIG': {
157 # "hosts": [('127.0.0.1', 6379)],
158 # },
159 },
160}
161
162# max count of items in sections
163CELL_BIG_SECTION_ITEMS_COUNT = 8
164CELL_SMALL_SECTION_ITEMS_COUNT = 12
165# max count of items by type(separated by field MenuItem.in_big_section)
166CELL_ITEMS_COUNT_PIZZA = 12
167CELL_ITEMS_COUNT_OTHER = 24
168
169PERFECT_DELIVERY_TIME = 45 * 60 # 45 min in seconds