Exemple #1
0
def test_decrypt_env(monkeypatch):
    monkeypatch.setattr(Env, "ENVIRON", {
        "TEST_VAR": "ok",
        "TEST_DECRYPT": "prefix-{{ key-name }}-data"
    })

    store = MockStore({"key-name": "secret"})

    env = Env()
    resolve_django_environ(env, store)

    assert env.str("TEST_VAR") == "ok"
    assert env.str("TEST_DECRYPT") == "prefix-secret-data"
Exemple #2
0
import logging.config

from appoptics_apm import djangoware
from django.utils.translation import ugettext_lazy as _
from environ import Env, Path

ENV = Env()

BASE_DIR = Path(__file__) - 2

SECRET_KEY = ENV.str("SECRET_KEY")
NEVERCACHE_KEY = ENV.str("NEVERCACHE_KEY")
COMPRESS_ENABLED = ENV.str("COMPRESS_ENABLED")
COMPRESS_OFFLINE = ENV.str("COMPRESS_OFFLINE")

######################
# MEZZANINE SETTINGS #
######################

# The following settings are already defined with default values in
# the ``defaults.py`` module within each of Mezzanine's apps, but are
# common enough to be put here, commented out, for conveniently
# overriding. Please consult the settings documentation for a full list
# of settings Mezzanine implements:
# http://mezzanine.jupo.org/docs/configuration.html#default-settings

# Controls the ordering and grouping of the admin menu.
#
# ADMIN_MENU_ORDER = (
#     ("Content", ("pages.Page", "blog.BlogPost",
#        "generic.ThreadedComment", (_("Media Library"), "media-library"),)),
Exemple #3
0
import os
from environ import Env

env = Env()
env.read_env(env.str("ENV_PATH", default=".env"))

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = env.str("SECRET_KEY")
DEBUG = env.bool("DEBUG", False)
ALLOWED_HOSTS = []

ROOT_URLCONF = "server.urls"

INSTALLED_APPS = [
    "django.contrib.admin", "django.contrib.auth",
    "django.contrib.contenttypes", "django.contrib.sessions",
    "django.contrib.messages", "django.contrib.staticfiles",
    "django_extensions", "widget_tweaks", "channels", "live_chat"
]

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",
]

TEMPLATES = [
Exemple #4
0
import json
import platform
from json import JSONDecodeError
from os import path
from pathlib import Path

from environ import Env

env = Env()
env.read_env()

BASE_DIR = Path(__file__).resolve(strict=True).parent.parent

SECRET_KEY = env.str('SECRET_KEY')
ALLOWED_HOSTS = env.list('ALLOWED_HOSTS')
DEBUG = True

INSTALLED_APPS = [
    'recipe_db.apps.RecipeDbConfig',
    'web_app.apps.WebAppConfig',
    'django.contrib.humanize',
    'web_app.apps.WebAppStaticFilesConfig',
    'meta',
]

try:
    import data_import
    INSTALLED_APPS.append('data_import.apps.DataImportConfig')
except ModuleNotFoundError:
    pass
Exemple #5
0
# )

# Setting to turn on featured images for blog posts. Defaults to False.
#
# BLOG_USE_FEATURED_IMAGE = True

# If True, the django-modeltranslation will be added to the
# INSTALLED_APPS setting.
USE_MODELTRANSLATION = False


########################
# MAIN DJANGO SETTINGS #
########################

SECRET_KEY = env.str('SECRET_KEY', default='')
NEVERCACHE_KEY = env.str('NEVERCACHE_KEY', default='')

# Hosts/domain names that are valid for this site; required if DEBUG is False
# See https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
ALLOWED_HOSTS = env.list('ALLOWED_HOSTS', default=[])

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = env.str('TIME_ZONE', default='UTC')
Exemple #6
0

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '-zvb+1j&=#)#%&i%8o&(o12xh8ihu8#$z%1vmexz36kb)x0$$3'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

if environ.str("HT_STAGE") in ["prod"]:
    ALLOWED_HOSTS = []
else:
    ALLOWED_HOSTS = ["*"]


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'minio_storage',
Exemple #7
0

########## WSGI CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application
WSGI_APPLICATION = '%s.wsgi.application' % PACKAGE_NAME
########## END WSGI CONFIGURATION


########## SOUTH CONFIGURATION
# See: http://south.readthedocs.org/en/latest/installation.html#configuring-your-django-installation
INSTALLED_APPS += (
    # Database migration helpers:
    'south',
)
# Don't need to use South when setting up a test database.
SOUTH_TESTS_MIGRATE = False
SOUTH_DATABASE_ADAPTERS = {'default':'south.db.postgresql_psycopg2'}

########## END SOUTH CONFIGURATION

########## ATTREZZI CONFIGURATION
ATTREZZI_ACCESSO_URL = env.str('ATTREZZI_ACCESSO_URL', 'http://example.com')
ATTREZZI = {
    'ACCESSO_ACCESS_TOKEN_URL': '%s/o/token/' % ATTREZZI_ACCESSO_URL,
    'ACCESSO_AUTHORIZE_URL': '%s/o/authorize/' % ATTREZZI_ACCESSO_URL,
    'ACCESSO_PROFILE_URL': '%s/api/v1/users/me' % ATTREZZI_ACCESSO_URL,
}
########## END ATTREZZI CONFIGURATION

LOGIN_REDIRECT_URL = "/"
ACCOUNT_EMAIL_VERIFICATION = None
# silently fail. Thus we silence `axes.W002` (invalid MIDDLEWARE configuration).
SILENCED_SYSTEM_CHECKS = ["axes.W002"]

url = urlparse(SITE_URL)

ADMINS: List[Tuple[str, str]] = [("webmaster", "*****@*****.**")]
MANAGERS = ADMINS
ADMIN_USER = env.dict("ADMIN_USER")
ALLOWED_HOSTS: List[str] = [url.hostname or url.netloc]
CORS_ORIGIN_WHITELIST: List[str] = [SITE_URL]

# Services
CELERY_BROKER_URL = env("CELERY_BROKER_URL")
# NOTE: This needs to be set to something unique per site so that the different
# celery instances data is namespaced on the shared broker (probably redis)
CELERY_TASK_DEFAULT_QUEUE = env.str("CELERY_TASK_DEFAULT_QUEUE")
DATABASES = {"default": env.db_url(default=default_databse_url)}

# Storage
DEFAULT_FILE_STORAGE = "webapp.storage.MediaS3"
STATICFILES_STORAGE = "webapp.storage.StaticS3"

AWS_S3_REGION_NAME = env("AWS_S3_REGION_NAME")
AWS_STORAGE_BUCKET_NAME = env("AWS_STORAGE_BUCKET_NAME")

INSTALLED_APPS = [
    # Project apps
    "webapp.apps.WebAppConfig",
    "users.apps.UsersConfig",
    # Our defaults
    "corsheaders",
Exemple #9
0
from pathlib import Path

from environ import Env

env = Env()

BASE_DIR = Path(__file__).resolve().parent.parent.parent

SECRET_KEY = env.str("CRUFTBOT_SECRET_KEY")

DEBUG = env.bool("CRUFTBOT_DEBUG")

ALLOWED_HOSTS = []

INSTALLED_APPS = [
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
    "django.contrib.staticfiles",
    "django.contrib.sites",
    "actstream",
    "axes",
    "rest_framework",
    "drf_yasg",
    "allauth",
    "allauth.account",
    "allauth.socialaccount",
    "allauth.socialaccount.providers.github",
    "allauth.socialaccount.providers.gitlab",
    "corsheaders",
    "cruftbot.apps.CruftbotConfig",
Exemple #10
0
import os

from environ import Env

env = Env()

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = env.str('SECRET_KEY', 'Rq77Yq9xtDjRtHyj')

DEBUG = True

ALLOWED_HOSTS = env.list('DJANGO_ALLOWED_HOSTS',
                         default=['localhost', '127.0.0.1'])

SYSTEM_FEE = 0.05  # in percents

# Application definition
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'backend.transactions',
    'backend.api',
    'frontend',
    'rest_framework',
Exemple #11
0
FIXTURES_DIR = 'fixtures'
FIXTURES_PATH = join(REPO_PATH, FIXTURES_DIR)

# Add our project to our pythonpath, this way we don't need to type our project
# name in our dotted import paths:
path.append(PROJECT_PATH)

# load environment variables
Env.read_env(normpath(join(REPO_PATH, '.env')))
env = Env()
######### END PATH CONFIGURATION

########## OPEN_RICOSTRUZIONE CONFIGURATION
DEBUG = env.bool('DEBUG', False)
TEMPLATE_DEBUG = env.bool('TEMPLATE_DEBUG', False)
INSTANCE_TYPE = env.str('INSTANCE_TYPE', '')

ADMINS = (
    ('Guglielmo Celata', '*****@*****.**'),
)

MANAGERS = ADMINS

DATABASES = {
    'default': env.db('DB_DEFAULT_URL', default='sqlite:///{0}'.format(normpath(join(RESOURCES_PATH, 'db', 'default.db')))),
}       

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# In a Windows environment this must be set to your system time zone.
Exemple #12
0
import os

import babel
from environ import Env

env = Env()
DEBUG = env.bool('DEBUG', default=False)
SECRET_KEY = env.str('SECRET_KEY', default=('cfh' if DEBUG else Env.NOTSET))
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
ALLOWED_HOSTS = ['*']

DATABASES = {
    'default': env.db_url(default='postgis://*****:*****@localhost:5432/cfh')
}

INSTALLED_APPS = list(filter(None, [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.gis',
    'rest_framework',
    'parler',
    'cfh',
    'issues',
    'issues_citysdk',
    'issues_media',
    'issues_hel',
    'issues_log',
Exemple #13
0
import os

from environ import Env

env = Env()
HOME_DIR = env.str(
    "HOME_DIR",
    default=os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))
)

env.read_env(os.path.join(HOME_DIR, ".env"))
DEBUG = env.bool("DEBUG", False)
SECRET_KEY = env.bool("SECRET_KEY", "Sehr lecker Wurst" if DEBUG else Env.NOTSET)
ALLOWED_HOSTS = env.list("ALLOWED_HOSTS", default=["*"])
DATABASES = {
    "default": env.db_url(default="sqlite:///%s" % os.path.join(HOME_DIR, "wurst.sqlite3"))
}
STATIC_ROOT = env.str("STATIC_ROOT", default=os.path.join(HOME_DIR, "static"))
MEDIA_ROOT = env.str("MEDIA_ROOT", default=os.path.join(HOME_DIR, "media"))

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'reversion',
    'rest_framework',
    'rest_framework.authtoken',
    'wurst.core',
For more information on this file, see
https://docs.djangoproject.com/en/2.1/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.1/ref/settings/
"""

import os

from environ import Env, Path

ENV = Env()

BASE_DIR = Path(__file__) - 3

SECRET_KEY = ENV.str("SECRET_KEY")

DEBUG = ENV.bool("DEBUG", default=False)

ALLOWED_HOSTS = []

# Application definition

INSTALLED_APPS = [
    "corsheaders",
    "whitenoise.runserver_nostatic",
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
    "django.contrib.messages",
Exemple #15
0
#!/usr/bin/env python3.7

# Requirement:
# django-environ==0.4.5

import os

from environ import Env

env = Env()

# 通过环境变量获取到配置文件名
env_file = f'env.{env.str("PROJECT_ENV")}'

# 通过环境变量获取配置路径,并加载配置
if 'CONFIG_PATH' in env:
    env_file_path = os.path.join(env.get_value('CONFIG_PATH'), env_file)
    assert os.path.exists(env_file_path), f'{env_file_path} do not exists'
    env.read_env(env_file_path)
else:
    env_file_path = env_file
    env.read_env(env_file_path)

if __name__ == '__main__':
    print(env.str('agent_user'))
    print(env.str('corp_user'))
Exemple #16
0
# -*- coding: utf-8 -*-
from multiprocessing import cpu_count

from environ import Env

env = Env()

bind = '0.0.0.0:80'

reload = env.bool('GUNICORN_RELOAD', default=False)
workers = env.int('GUNICORN_WORKERS', default=(cpu_count() * 2 + 1))

loglevel = env.str('GUNICORN_LOG_LEVEL', default='error')
errorlog = '-'  # stderr
accesslog = '-' if env.bool('GUNICORN_ACCESS_LOG', default=False) else None

timeout = 60
from .helpers.storages import STORAGES, DEFAULT_STORAGE
from .helpers.templates import DEFAULT_TEMPLATES
# from .helpers.simple_jwt_settings import SIMPLE_JWT
from .helpers.validators import DEFAULT_VALIDATORS

BASE_DIR: str = dirname(dirname(abspath(__file__)))
# Environment variables
env = Env()
Env.read_env()
# Sentry
# SENTRY_DSN: str = env.str(var='SENTRY_DSN')
# integrations: Tuple = (DjangoIntegration(), CeleryIntegration())
# init(dsn=SENTRY_DSN, integrations=integrations)
# Django
DEBUG: bool = env.bool(var='DEBUG')
SECRET_KEY: str = env.str(var='SECRET_KEY')
APPEND_SLASH: bool = True
ALLOWED_HOSTS: Tuple = ('*', )
INSTALLED_APPS: Tuple = DEFAULT_APPS
MIDDLEWARE: Tuple = DEFAULT_MIDDLEWARES
ROOT_URLCONF: str = 'core.urls'
TEMPLATES: Tuple = DEFAULT_TEMPLATES
WSGI_APPLICATION: str = 'core.wsgi.application'
DATABASES: MappingProxyType = MappingProxyType({'default': env.db()})

CACHES = {
    'default': {
        'BACKEND': 'django_redis.cache.RedisCache',
        'LOCATION': "redis://redis:6379/1",
        'OPTIONS': {
            'CLIENT_CLASS': 'django_redis.client.DefaultClient',
Exemple #18
0
# -*- coding: utf-8 -*-
from multiprocessing import cpu_count

from environ import Env

env = Env()

bind = '0.0.0.0:80'

reload = env.bool('GUNICORN_RELOAD', default=False)
workers = env.int('GUNICORN_WORKERS', default=(cpu_count() * 2 + 1))

loglevel = env.str('GUNICORN_LOG_LEVEL', default='error')
errorlog = '-'  # stderr
accesslog = '-' if env.bool('GUNICORN_ACCESS_LOG', default=False) else None
Exemple #19
0
from pathlib import Path

from environ import Env

env = Env()

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = env.str(
    'SECRET_KEY', default='g%mpcyry0nse06!3363q@ajl%ssrf-)_q!zefl_73&v$28r2aj')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env.bool('DEBUG', default=False)

ALLOWED_HOSTS = env.list('ALLOWED_HOSTS', default=[])

# Application definition

DJANGO_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]

THIRD_PARTY_APPS = [
    'rest_framework_filters',
Exemple #20
0
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
dotenv.load_dotenv()
env = Env()

# 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 = env('DJANGO_SECRET_KEY')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env.bool('DJANGO_DEBUG', False)

ALLOWED_HOSTS = env.str('ALLOWED_HOSTS', '').split(',')

# Application definition

INSTALLED_APPS = [
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
    "django.contrib.messages",
    "django.contrib.staticfiles",
    'rest_framework',
    "django_extensions",
    "apps.users",
    "apps.pets",
]
from environ import Env, Path

env = Env()

BASE_PATH = Path(__file__) - 2
BASE_DIR = BASE_PATH()
Env.read_env(BASE_PATH("local.env"))

SECRET_KEY = env.str("SECRET_KEY", "my-secret-key")
DEBUG = env.bool("DEBUG", False)
ALLOWED_HOSTS = ["*"]

INSTALLED_APPS = [
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
    "django.contrib.messages",
    "django.contrib.staticfiles",
]

INSTALLED_APPS += [
    "django_extensions",
    "django_celery_results",
    "app",
]

MIDDLEWARE = [
    "django.middleware.security.SecurityMiddleware",
    "django.contrib.sessions.middleware.SessionMiddleware",
    "django.middleware.common.CommonMiddleware",
Exemple #22
0
import os

from environ import Env

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# 读取环境变量,.env 文件采用 utf-8 编码
Env.read_env(open(os.path.join(BASE_DIR, '.env'), encoding='utf-8'))
env = Env()

ROOT_URLCONF = 'project.urls'
WSGI_APPLICATION = 'project.wsgi.application'

DEBUG = env.bool('DJANGO_DEBUG', True)
ALLOWED_HOSTS = env.list('DJANGO_ALLOWED_HOSTS', default=[])
SECRET_KEY = env.str('DJANGO_SECRET_KEY', '7=w%b(0@#ojjb6egx7+ba!@rnq-pfs8mrue^-i(wm$gxag3e17')

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django_extensions',
    'django_summernote',
    'bootstrap3',
    'apps.core',
    'apps.blog',
]
Exemple #23
0
import os
from environ import Env

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
env = Env()
envfile = os.path.join(BASE_DIR, ".env")
if os.path.isfile(envfile):
    env.read_env(envfile)

DEBUG = env.bool("DEBUG", default=False)
SECRET_KEY = env.str("SECRET_KEY",
                     default=("nom" * 20 if DEBUG else Env.NOTSET))
ALLOWED_HOSTS = env.list("ALLOWED_HOST", default=["*"])

APPEND_SLASH = True
AUTH_USER_MODEL = "safka.User"
LANGUAGE_CODE = "en-us"
ROOT_URLCONF = "safka_project.urls"
STATIC_URL = "/static/"
TIME_ZONE = "UTC"
USE_I18N = True
USE_L10N = True
USE_TZ = True
WSGI_APPLICATION = "safka_project.wsgi.application"
CAVALRY_ENABLED = bool(DEBUG)

INSTALLED_APPS = [
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
Exemple #24
0
from raven.exceptions import InvalidGitRepository

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
assert os.path.isfile(os.path.join(BASE_DIR, 'manage.py'))

#####################
# Local environment #
#####################
env = Env()
env.read_env(os.path.join(BASE_DIR, '.env'))

########################
# Django core settings #
########################
DEBUG = env.bool('DEBUG', default=False)
SECRET_KEY = env.str('SECRET_KEY', default=('' if not DEBUG else 'xxx'))
ALLOWED_HOSTS = ['*']

#########
# Paths #
#########
default_var_root = os.path.join(BASE_DIR, 'var')
user_var_root = os.path.expanduser('~/var')
if os.path.isdir(user_var_root):
    default_var_root = user_var_root
VAR_ROOT = env.str('VAR_ROOT', default_var_root)

# Create var root if it doesn't exist
if not os.path.isdir(VAR_ROOT):
    print('Creating var root %s' % VAR_ROOT)
    os.makedirs(VAR_ROOT)
Exemple #25
0

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

ENV_FILE = os.path.join(BASE_DIR, ".env")
if os.path.exists(ENV_FILE):
    Env.read_env(ENV_FILE)

env = Env()

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = env.str("DJANGO_SECRET_KEY")

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env.bool("DEBUG", False)

ALLOWED_HOSTS = env.list("ALLOWED_HOSTS", default=[])

# django-allow-cidr
ALLOWED_CIDR_NETS = ["10.0.0.0/8"]

WSGI_APPLICATION = "conf.wsgi.application"

INSTALLED_APPS = [
    "django.contrib.sessions",
    "django.contrib.messages",
    "django.contrib.staticfiles",
Exemple #26
0
from environ import Env
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker

env = Env()
Env.read_env()

DATABASE_URL: str = env.str(var='DATABASE_URL')

engine = create_engine(DATABASE_URL)

SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)

Base = declarative_base()
Exemple #27
0
https://docs.djangoproject.com/en/2.0/ref/settings/
"""

import os

import sentry_sdk
from django.contrib.messages import constants as message_constants
from environ import Env
from sentry_sdk.integrations.celery import CeleryIntegration
from sentry_sdk.integrations.django import DjangoIntegration

ENV = Env()

# Sentry
sentry_sdk.init(
    dsn=ENV.str("SENTRY_DSN", None),
    environment=ENV.str("SENTRY_ENVIRONMENT", None),
    release=ENV.str("SENTRY_RELEASE", None),
    integrations=[CeleryIntegration(),
                  DjangoIntegration()],
)

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = ENV.str("SECRET_KEY", "debug-secret")
from environ import Env

# Initiate env function
env = Env()

# Read .env file
Env.read_env()

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = env.str('SECRET_KEY')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env.bool('DEBUG', default=True)

ALLOWED_HOSTS = env.list('ALLOWED_HOSTS', default=[])

# Application definition

INSTALLED_APPS = [
    'api.v1',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
Exemple #29
0
import os

from environ import Env


BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
assert os.path.isfile(os.path.join(BASE_DIR, 'manage.py'))

env = Env()
env.read_env(os.path.join(BASE_DIR, '.env'))

DEBUG = env.bool('DEBUG', default=False)
SECRET_KEY = env.str('SECRET_KEY', default=('' if not DEBUG else 'xxx'))

DATABASES = {
    'default': env.db_url(
        default='psql://*****:*****@postgres/tallessa',
    ),
}

CACHES = {'default': env.cache_url(default='locmemcache://')}

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    'rest_framework',
Exemple #30
0
# -*- coding: utf-8 -*-
from multiprocessing import cpu_count

from environ import Env

env = Env()

bind = ['0.0.0.0:80']

reload = env.bool('GUNICORN_RELOAD', False)
workers = env.int('GUNICORN_WORKERS', cpu_count() * 2 + 1)

loglevel = env.str('GUNICORN_LOG_LEVEL', 'info')
errorlog = '-'  # stderr
accesslog = '-' if env.bool('GUNICORN_ACCESS_LOG', False) else None
Exemple #31
0
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import path
from environ import Env

from core import views
from utils.file_location import get_absolute_path

env = Env()

urlpatterns = [
    path(env.str('ADMIN_URL', 'admin') + '/', admin.site.urls),
    path('succeed',
         views.RegistrationSucceedTemplateView.as_view(),
         name='registration_succeed'),
    path('', views.IndexCreateView.as_view(), name='index')
]

if settings.DEBUG:
    urlpatterns += static(settings.MEDIA_URL,
                          document_root=settings.MEDIA_ROOT)
    urlpatterns += static(settings.STATIC_URL,
                          document_root=get_absolute_path('static'))
Exemple #32
0
from environ import Env

from .base import *  # noqa: F401, F403

env = Env()

DEBUG = False

SECRET_KEY = env.str("DJANGO_SECRET_KEY", default="!!!SET DJANGO_SECRET_KEY!!!")

TEST_RUNNER = "utils.test_runner.PytestTestRunner"

CACHES = {"default": {"BACKEND": "django.core.cache.backends.locmem.LocMemCache", "LOCATION": ""}}

DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": "test.sql"}}

PASSWORD_HASHERS = ["django.contrib.auth.hashers.MD5PasswordHasher"]

EMAIL_BACKEND = "django.core.mail.backends.locmem.EmailBackend"
EMAIL_HOST = "localhost"
EMAIL_PORT = 1025
Exemple #33
0
from environ import Env

from .base import *  # noqa: F401, F403

env = Env()

SECRET_KEY = env.str('SECRET_KEY', default='keepitsecret')
DEBUG = env.bool('DEBUG', default=False)

ALLOWED_HOSTS = env.list('ALLOWED_HOSTS', default=['*'])
DATABASES = {
    'default': env.db(default='sqlite:///db.sqlite'),
}
TIME_ZONE = env.str('TIME_ZONE', default='UTC')
LANGUAGE_CODE = env.str('LANGUAGE_CODE', default='en-us')

STATIC_ROOT = env.str('STATIC_ROOT', default=f'{BASE_DIR}static/')
STATIC_URL = env.str('STATIC_URL', default='/static/')
MEDIA_ROOT = env.str('MEDIA_ROOT', default=f'{BASE_DIR}media/')
MEDIA_URL = env.str('MEDIA_URL', default='/media/')
from raven.exceptions import InvalidGitRepository

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
assert os.path.isfile(os.path.join(BASE_DIR, 'manage.py'))

#####################
# Local environment #
#####################
env = Env()
env.read_env(os.path.join(BASE_DIR, '.env'))

########################
# Django core settings #
########################
DEBUG = env.bool('DEBUG', default=False)
TIER = env.str('TIER', default='dev')
SECRET_KEY = env.str('SECRET_KEY', default=('' if not DEBUG else 'xxx'))
ALLOWED_HOSTS = ['*']

#########
# Paths #
#########
default_var_root = os.path.join(BASE_DIR, 'var')
user_var_root = os.path.expanduser('~/var')
if os.path.isdir(user_var_root):
    default_var_root = user_var_root
VAR_ROOT = env.str('VAR_ROOT', default_var_root)

# Create var root if it doesn't exist
if not os.path.isdir(VAR_ROOT):
    os.makedirs(VAR_ROOT)
Exemple #35
0
from django.urls import reverse_lazy

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

ENV_FILE = os.path.join(BASE_DIR, ".env")
if os.path.exists(ENV_FILE):
    Env.read_env(ENV_FILE)

env = Env()

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = env.str("DJANGO_SECRET_KEY")

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env.bool("DEBUG", False)

ALLOWED_HOSTS = env.list("ALLOWED_HOSTS", default=[])

# django-allow-cidr
ALLOWED_CIDR_NETS = ["10.0.0.0/8"]

WSGI_APPLICATION = "conf.wsgi.application"

INSTALLED_APPS = [
    "django.contrib.sessions",
    "django.contrib.messages",
    "django.contrib.staticfiles",
Exemple #36
0
Env.read_env(normpath(join(CONFIG_PATH, '.env')))
env = Env()
########## END PATH CONFIGURATION


########## DEBUG CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
DEBUG = env.bool('DEBUG', False)

# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
TEMPLATE_DEBUG = DEBUG
########## END DEBUG CONFIGURATION


########## MANAGER CONFIGURATION
ADMIN_EMAIL = env.str('ADMIN_EMAIL', 'admin@%s.com' % PROJECT_NAME)
ADMIN_NAME = env.str('ADMIN_NAME', ADMIN_EMAIL.split('@')[0])

# See: https://docs.djangoproject.com/en/dev/ref/settings/#admins
ADMINS = (
    (ADMIN_EMAIL, ADMIN_NAME),
)

# See: https://docs.djangoproject.com/en/dev/ref/settings/#managers
MANAGERS = ADMINS

# See: https://docs.djangoproject.com/en/dev/ref/settings/#default-from-email
DEFAULT_FROM_EMAIL = env.str('DEFAULT_FROM_EMAIL', ADMIN_EMAIL)
########## END MANAGER CONFIGURATION

Exemple #37
0
import os

from django.utils.translation import ugettext_lazy as _
from environ import Env

BASE_DIR = os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))
assert os.path.exists(os.path.join(BASE_DIR, "manage.py"))

env = Env()

DEBUG = False
LANGUAGE_CODE = "fi"
LANGUAGES = [('fi', _('Finnish')), ('sv', _('Swedish')), ('en', _('English'))]
VAR_ROOT = env.str("VAR_ROOT", default=BASE_DIR)
if not os.path.isdir(VAR_ROOT):
    os.makedirs(VAR_ROOT)
MEDIA_ROOT = os.path.join(VAR_ROOT, "media")
MEDIA_URL = "/media/"
ROOT_URLCONF = "paatos.urls"
STATIC_ROOT = os.path.join(VAR_ROOT, "static")
STATIC_URL = "/static/"
TIME_ZONE = "Europe/Helsinki"
USE_I18N = True
USE_L10N = True
USE_TZ = True
WSGI_APPLICATION = "paatos.wsgi.application"

INSTALLED_APPS = [
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.contenttypes",
    DEFAULT_LOCALE_PATHS, DEFAULT_LANGUAGES
)
from .helpers.middlewares import DEFAULT_MIDDLEWARES
from .helpers.rest_framework_settings import (
    REST_FRAMEWORK_SETTINGS
)
from .helpers.storages import STORAGES, DEFAULT_STORAGE
from .helpers.templates import DEFAULT_TEMPLATES
from .helpers.validators import DEFAULT_VALIDATORS

BASE_DIR: str = dirname(dirname(abspath(__file__)))
# Environment variables
env = Env()
Env.read_env()
# Sentry
SENTRY_DSN: str = env.str(var='SENTRY_DSN')
# Django
DEBUG: bool = env.bool(var='DEBUG')
SECRET_KEY: str = env.str(var='SECRET_KEY')
APPEND_SLASH: bool = True
ALLOWED_HOSTS: Tuple = ('*',)
INSTALLED_APPS: Tuple = DEFAULT_APPS
MIDDLEWARE: Tuple = DEFAULT_MIDDLEWARES
ROOT_URLCONF: str = 'core.urls'
TEMPLATES: Tuple = DEFAULT_TEMPLATES
WSGI_APPLICATION: str = 'core.wsgi.application'
DATABASES: MappingProxyType = MappingProxyType({'default': env.db()})
AUTH_PASSWORD_VALIDATORS: Tuple = DEFAULT_VALIDATORS
AUTH_USER_MODEL = 'users.User'
# Security
SECURE_BROWSER_XSS_FILTER: bool = True
Exemple #39
0
from environ import Env
from django.utils.translation import ugettext_lazy as _

BASE_DIR = os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))
assert os.path.exists(os.path.join(BASE_DIR, "manage.py"))

env = Env()

DEBUG = False
LANGUAGE_CODE = "fi"
LANGUAGES = [
    ('fi', _('Finnish')),
    ('sv', _('Swedish')),
    ('en', _('English'))
]
VAR_ROOT = env.str("VAR_ROOT", default=BASE_DIR)
if not os.path.isdir(VAR_ROOT):
    os.makedirs(VAR_ROOT)
MEDIA_ROOT = os.path.join(VAR_ROOT, "media")
MEDIA_URL = "/media/"
ROOT_URLCONF = "paatos.urls"
STATIC_ROOT = os.path.join(VAR_ROOT, "static")
STATIC_URL = "/static/"
TIME_ZONE = "Europe/Helsinki"
USE_I18N = True
USE_L10N = True
USE_TZ = True
WSGI_APPLICATION = "paatos.wsgi.application"


INSTALLED_APPS = [