""" Django settings for webproj project. Generated by 'django-admin startproject' using Django 3.0.8. For more information on this file, see https://docs.djangoproject.com/en/3.0/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/3.0/ref/settings/ """ import os from pathlib import Path from django.utils.translation import ugettext_lazy as _ from . import fsconfig DEVELOPING = os.uname()[1] == 'forest' SITE_NAME = fsconfig.SITE_NAME BASE_DIR = fsconfig.BASE_DIR SECRET_KEY = fsconfig.SECRET_KEY DEBUG = fsconfig.DEBUG and DEVELOPING ALLOWED_HOSTS = [ *fsconfig.SITE_DOMAIN, 'localhost', '127.0.0.1', ] if DEBUG and DEVELOPING: ALLOWED_HOSTS = '*' if not DEBUG: SECURE_BROWSER_XSS_FILTER = True SECURE_HSTS_INCLUDE_SUBDOMAINS = True SECURE_HSTS_PRELOAD = True SECURE_HSTS_SECONDS = 31536000 # CORS_ORIGIN_WHITELIST = ["https://"+x for x in fsconfig.SITE_DOMAIN] CSRF_TRUSTED_ORIGINS = fsconfig.SITE_DOMAIN # SECURE_SSL_REDIRECT = True and not DEBUG SECURE_CONTENT_TYPE_NOSNIFF = True CSRF_COOKIE_SECURE = True SESSION_COOKIE_SECURE = True X_FRAME_OPTIONS = 'DENY' SASS_PRECISION = 13 SASS_OUTPUT_STYLE = 'compact' SASS_PROCESSOR_AUTO_INCLUDE = True SASS_PROCESSOR_ENABLED = True SASS_PROCESSOR_INCLUDE_DIRS = [ os.path.join(BASE_DIR, 'static'), ] # Application definition SITE_ID = 1 INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'webproj.bot', ] 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 = 'webproj.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', ], }, }, ] TEMPLATES[0]['DIRS'].append(os.path.join(BASE_DIR, 'webproj', 'templates')) WSGI_APPLICATION = 'webproj.wsgi.application' # Database # https://docs.djangoproject.com/en/3.0/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': str(Path(BASE_DIR).joinpath('db.sqlite3')), } } # Password validation # https://docs.djangoproject.com/en/3.0/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/3.0/topics/i18n/ # LANGUAGES = [(iso, _(lang)) for iso, lang in fsconfig.LANGUAGES] LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True # if LANGUAGE_CODE not in LANGUAGES: # LANGUAGES.append(LANGUAGE_CODE) # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.0/howto/static-files/ STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'webproj', 'static_source'), ] MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media') if DEBUG and DEVELOPING: EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' DEFAULT_FROM_EMAIL = f'{SITE_NAME} ' RANGE_1_UNTIL_13 = range(1, 13) SETTINGS_EXPORT = [ 'SITE_NAME', 'RANGE_1_UNTIL_13', 'DEBUG', ] STATICFILES_FINDERS = [ 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', # 'sass_processor.finders.CssFinder', ] REST_FRAMEWORK = { 'DEFAULT_RENDERER_CLASSES': ( 'rest_framework.renderers.JSONRenderer', 'rest_framework.renderers.BrowsableAPIRenderer', ) } ROSETTA_WSGI_AUTO_RELOAD = True ACCOUNT_ACTIVATION_DAYS = 7 REGISTRATION_DEFAULT_FROM_EMAIL = f'{SITE_NAME} Registration ' REGISTRATION_EMAIL_HTML = True REGISTRATION_AUTO_LOGIN = True REGISTRATION_OPEN = fsconfig.REGISTRATION_OPEN CORS_URLS_REGEX = r'^/api/.*$' # CORS_ORIGIN_REGEX_WHITELIST = [r'^.*$'] CORS_ORIGIN_ALLOW_ALL = True DJANGO_TELEGRAMBOT = { 'MODE': 'WEBHOOK', # (Optional [str]) # The default value is WEBHOOK, # otherwise you may use 'POLLING' # NB: if use polling you must provide to run # a management command that starts a worker 'WEBHOOK_SITE': f'https://{fsconfig.SITE_DOMAIN[0]}', 'WEBHOOK_PREFIX': '/telegram', # (Optional[str]) # If this value is specified, # a prefix is added to webhook url # 'WEBHOOK_CERTIFICATE' : 'cert.pem', # If your site use self-signed # certificate, must be set with location of your public key # certificate.(More info at https://core.telegram.org/bots/self-signed ) 'BOTS': [ { 'TOKEN': fsconfig.TELEGRAM_TOKEN, # Your bot token. # 'ALLOWED_UPDATES':(Optional[list[str]]), # List the types of # updates you want your bot to receive. For example, specify # ``["message", "edited_channel_post", "callback_query"]`` to # only receive updates of these types. See ``telegram.Update`` # for a complete list of available update types. # Specify an empty list to receive all updates regardless of type # (default). If not specified, the previous setting will be used. # Please note that this parameter doesn't affect updates created # before the call to the setWebhook, so unwanted updates may be # received for a short period of time. # 'TIMEOUT':(Optional[int|float]), # If this value is specified, # use it as the read timeout from the server # 'WEBHOOK_MAX_CONNECTIONS':(Optional[int]), # Maximum allowed number of # simultaneous HTTPS connections to the webhook for update # delivery, 1-100. Defaults to 40. Use lower values to limit the # load on your bot's server, and higher values to increase your # bot's throughput. # 'POLL_INTERVAL' : (Optional[float]), # Time to wait between polling updates from Telegram in #seconds. Default is 0.0 # 'POLL_CLEAN':(Optional[bool]), # Whether to clean any pending updates on Telegram servers before # actually starting to poll. Default is False. # 'POLL_BOOTSTRAP_RETRIES':(Optional[int]), # Whether the bootstrapping phase of the `Updater` # will retry on failures on the Telegram server. # | < 0 - retry indefinitely # | 0 - no retries (default) # | > 0 - retry up to X times # 'POLL_READ_LATENCY':(Optional[float|int]), # Grace time in seconds for receiving the reply from # server. Will be added to the `timeout` value and used as the read timeout from # server (Default: 2). }, # Other bots here with same structure. ], } exec('from server_secrets.extraconfig import *')