""" Django settings for project project. Generated by 'django-admin startproject' using Django 2.2.2. For more information on this file, see https://docs.djangoproject.com/en/2.2/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/2.2/ref/settings/ """ import os import sys # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) PROJECT_ROOT = os.path.abspath(os.path.join(BASE_DIR, '..')) PUBLIC_ROOT = os.path.abspath(os.path.join(BASE_DIR, '..', 'media')) # # insert apps and libs dirs to sys.path for path in ('apps', 'services',): path = os.path.abspath(os.path.join(PROJECT_ROOT, '%s' % path)) path in sys.path or sys.path.insert(0, path) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'ta$edl0av6n#-xphew5922npa4f*h8mfv#$@4tids*gbrp17&b' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition CONTRIB_APPS = [ 'bootstrap_admin', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.gis', ] PROJECT_APPS = [ 'account.apps.AccountConfig', ] EXTERNAL_APPS = [ 'django_filters', 'drf_yasg', 'fcm_django', 'easy_thumbnails', 'rest_framework', 'rest_framework.authtoken', 'easy_select2', ] INSTALLED_APPS = CONTRIB_APPS + PROJECT_APPS + EXTERNAL_APPS 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 = 'project.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'project.wsgi.application' # Database # https://docs.djangoproject.com/en/2.2/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.contrib.gis.db.backends.postgis', 'NAME': os.environ.get('DB_NAME'), 'USER': os.environ.get('DB_USERNAME'), 'PASSWORD': os.environ.get('DB_PASSWORD'), 'HOST': os.environ.get('DB_HOSTNAME'), 'PORT': os.environ.get('DB_PORT'), }, } # Password validation # https://docs.djangoproject.com/en/2.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', }, ] # Account settings AUTH_USER_MODEL = 'account.User' LOGIN_URL = 'admin:login' LOGOUT_URL = 'admin:logout' # Internationalization # https://docs.djangoproject.com/en/2.2/topics/i18n/ LANGUAGE_CODE = 'ru' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True LOCALE_PATHS = ( os.path.abspath(os.path.join(BASE_DIR, 'locale')), ) # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/2.2/howto/static-files/ STATIC_ROOT = os.path.join(PUBLIC_ROOT, 'static') STATIC_URL = '/static/' MEDIA_ROOT = os.path.join(PUBLIC_ROOT, 'media') MEDIA_URL = '/media/' STATICFILES_DIRS = ( os.path.join(PROJECT_ROOT, 'static'), ) FILE_UPLOAD_PERMISSIONS = 0o644 AVAILABLE_VERSIONS = { # 'future': '1.0.1', 'current': '1.0.0', # 'temp': '1.0.0' } # Django Rest Framework REST_FRAMEWORK = { 'DEFAULT_FILTER_BACKENDS': ( 'django_filters.rest_framework.DjangoFilterBackend', ), 'PAGE_SIZE': 10, 'DEFAULT_PAGINATION_CLASS': 'utils.pagination.ProjectMobilePagination', 'COERCE_DECIMAL_TO_STRING': False, 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework.authentication.TokenAuthentication', 'rest_framework.authentication.SessionAuthentication', ), 'DEFAULT_VERSIONING_CLASS': 'rest_framework.versioning.AcceptHeaderVersioning', 'DEFAULT_VERSION': (AVAILABLE_VERSIONS['current'],), 'ALLOWED_VERSIONS': AVAILABLE_VERSIONS.values(), 'DEFAULT_PERMISSION_CLASSES': ( 'rest_framework.permissions.IsAuthenticated', ), # 'DATETIME_FORMAT': '%m-%d-%Y %H:%M:%S', # experiment # 'DATE_FORMAT': '%s.%f', # experiment } REST_DATE_FORMAT = '%m-%d-%Y' REST_DATETIME_FORMAT = '%m-%d-%Y %H:%M:%S' # SMS Settings SMS_EXPIRATION = 5 SMS_SEND_DELAY = 30 SMS_ATTEMPT_LIMIT = 3 # Following items used in several models # make auto migrations if change SMS_CODE_LENGTH = 6 SEND_SMS = True SMS_CODE_SHOW = False # SMSC Settings SMS_SERVICE = 'http://smsc.ru/sys/send.php' SMS_LOGIN = 'GM2019' SMS_PASSWORD = '}#6%Qe7CYG7n' SMS_SENDER = 'GM' # Django Rest Swagger SWAGGER_SETTINGS = { # "DEFAULT_GENERATOR_CLASS": "rest_framework.schemas.generators.BaseSchemaGenerator", 'JSON_EDITOR': False, 'SHOW_REQUEST_HEADERS': True, 'SECURITY_DEFINITIONS': { 'Basic': { 'type': 'basic' }, 'Token': { 'type': 'apiKey', 'name': 'Authorization', 'in': 'header' } }, } REDOC_SETTINGS = { 'LAZY_RENDERING': False, } # CELERY BROKER_URL = 'amqp://rabbitmq:5672' CELERY_RESULT_BACKEND = BROKER_URL CELERY_BROKER_URL = BROKER_URL CELERY_ACCEPT_CONTENT = ['application/json'] CELERY_TASK_SERIALIZER = 'json' CELERY_RESULT_SERIALIZER = 'json' CELERY_TIMEZONE = TIME_ZONE USE_CELERY = False # Django FCM (Firebase push notificatoins) FCM_DJANGO_SETTINGS = { 'FCM_SERVER_KEY': ( "AAAAJcC4Vbc:APA91bGovq7233-RHu2MbZTsuMU4jNf3obOue8s" "7qVznx-Xwr_h_R8Nz2Wfhf6hWIXdt99hr6xOH9WRVhxnC5eH96s" "6rYnpKEY6OrcVoLtceIR1yRrBZJtklDiSkP7daoeCqsnQmtB2m" ), } # Thumbnail settings THUMBNAIL_ALIASES = { '': { 'tiny': {'size': (100, 0), }, 'small': {'size': (480, 0), }, 'middle': {'size': (700, 0), }, 'large': {'size': (1500, 0), }, 'default': {'size': (300, 200), 'crop': True}, 'gallery': {'size': (240, 160), 'crop': True}, } }