env = Env()  # pylint: disable=invalid-name
{%- if cookiecutter.monitoring == 'Sentry' %}

SENTRY_DSN = env('SENTRY_DSN', default=None)

if SENTRY_DSN:
    import sentry_sdk

    sentry_sdk.init(dsn=SENTRY_DSN, integrations=[
        sentry_sdk.integrations.django.DjangoIntegration(),
    ])
{%- endif %}

BASE_DIR = dirname(dirname(abspath(__file__)))

DEBUG = env.bool('DJANGO_DEBUG', default=False)

SECRET_KEY = 'dummy-secret' if DEBUG else env('DJANGO_SECRET_KEY')

ALLOWED_HOSTS = ['*']

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'handlers': {
        'console': {
            'level': env('DJANGO_LOG_LEVEL', default='INFO'),
            'class': 'logging.StreamHandler',
        },
    },
    'loggers': {
Exemplo n.º 2
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
Exemplo n.º 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 = [
Exemplo n.º 4
0
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',
    'django.contrib.staticfiles',
    'rest_framework',
    'dynamic_rest',
Exemplo n.º 5
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',
Exemplo n.º 6
0
import os

from environ import Env

from ..path import BASE_DIR

env = Env()
SOURCE_DIR = BASE_DIR.parent

READ_DOT_ENV_FILE = env.bool("DJANGO_READ_DOT_ENV_FILE", default=False)
if READ_DOT_ENV_FILE:
    env.read_env(os.path.join(SOURCE_DIR, ".envs", ".env"))
Exemplo n.º 7
0
"""Settings for your application."""
from datetime import timedelta
from pathlib import Path
from typing import Any, Dict, List, Tuple, Type
from urllib.parse import urlparse

from environ import Env

env = Env()

# Bootstrap debug
DEBUG = env.bool("DEBUG")

default_databse_url = env.NOTSET

scheme: Dict[str, Tuple[Type, Any]] = {
    "CELERY_BROKER_URL": (str, "redis://"),
    "AXES_META_PRECEDENCE_ORDER":
    (tuple, ("HTTP_X_FORWARDED_FOR", "X_FORWARDED_FOR")),
}

if DEBUG:
    default_databse_url = (  # pylint: disable=invalid-name
        "postgres://*****:*****@db:5432/django")
    scheme = {
        **scheme,
        **{
            "CELERY_BROKER_URL": (str, "redis://redis/0"),
            "ADMIN_USER": (dict, {
                "email": "*****@*****.**",
                "password": "******"
Exemplo n.º 8
0
from environ import Env

from inloop.accounts import constance as accounts_constance
from inloop.gitload import constance as gitload_constance
from inloop.solutions import constance as solutions_constance

if sys.getfilesystemencoding() != 'utf-8':
    raise ImproperlyConfigured('LANG must be a utf-8 locale')

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

env = Env()

SECRET_KEY = env('SECRET_KEY')
DEBUG = env.bool('DEBUG', default=False)
ALLOWED_HOSTS = [host.strip() for host in env.list('ALLOWED_HOSTS')]
INTERNAL_IPS = [ip.strip() for ip in env.list('INTERNAL_IPS', default='')]

SITE_ID = 1

INSTALLED_APPS = [
    'inloop.accounts',
    'inloop.common',
    'inloop.grading',
    'inloop.solutions',
    'inloop.tasks',
    'inloop.testrunner',
    'inloop.gitload',
    'inloop.statistics',
    'inloop.medics',
# )
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': {
Exemplo n.º 10
0
from environ import Env

from inloop.accounts import constance as accounts_constance
from inloop.gitload import constance as gitload_constance
from inloop.solutions import constance as solutions_constance

if sys.getfilesystemencoding() != "utf-8":
    raise ImproperlyConfigured("LANG must be a utf-8 locale")

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

env = Env()

SECRET_KEY = env("SECRET_KEY")
DEBUG = env.bool("DEBUG", default=False)
ALLOWED_HOSTS = [host.strip() for host in env.list("ALLOWED_HOSTS")]
INTERNAL_IPS = [ip.strip() for ip in env.list("INTERNAL_IPS", default="")]

SITE_ID = 1

INSTALLED_APPS = [
    "inloop.accounts",
    "inloop.common",
    "inloop.grading",
    "inloop.solutions",
    "inloop.tasks",
    "inloop.testrunner",
    "inloop.gitload",
    "django.contrib.admin",
    "django.contrib.auth",
Exemplo n.º 11
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",
Exemplo n.º 12
0
LOG_PATH = join(RESOURCES_PATH,'logs')

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
Exemplo n.º 13
0
RESOURCE_DIR = 'resources'
RESOURCES_PATH = join(REPO_PATH, RESOURCE_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(CONFIG_PATH, '.env')))
env = Env()
########## END PATH CONFIGURATION


########## START VOISIETEQUI CONFIGURATION
# Site status
EARLYBIRD_ENABLE = env.bool('EARLYBIRD_ENABLE', default=False)
RESULTS_DUMP = normpath(join(RESOURCES_PATH, 'results.csv'))

# PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
# REPO_ROOT = os.path.abspath(os.path.dirname(PROJECT_ROOT))

ELECTION_CODE = env('ELECTION_CODE', default='election')
ELECTION_NAME = env('ELECTION_NAME', default='Elezioni')
PARTY_LEADER = env('PARTY_LEADER', default='Segretario')
PARTY_COALITION = env('PARTY_COALITION', default='Coalizione')

PARTY_TERM = env('PARTY_TERM', default='Partito')
PARTY_TERM_PLURAL = env('PARTY_TERM_PLURAL', default='Partiti')
PARTY_TERM_GENDER = env('PARTY_TERM_GENDER', default='male')
OF_PARTY_TERM_PLURAL = env('OF_PARTY_TERM_PLURAL', default='dei partiti')
THE_PARTY_TERM_PLURAL = env('THE_PARTY_TERM_PLURAL', default='i partiti')
Exemplo n.º 14
0
"""Settings for your application."""
from datetime import timedelta
from typing import Any, Dict, List, Tuple, Type
from urllib.parse import urlparse

import sentry_sdk
from environ import Env
from sentry_sdk.integrations.django import DjangoIntegration

env = Env()

# Bootstrap debug
DEBUG = env.bool("DEBUG")

default_databse_url = env.NOTSET

scheme: Dict[str, Tuple[Type, Any]] = {
    "CELERY_BROKER_URL": (str, "redis://"),
    "AXES_META_PRECEDENCE_ORDER":
    (tuple, ("HTTP_X_FORWARDED_FOR", "X_FORWARDED_FOR")),
    "SENTRY_ENABLED": (bool, True),
    "SENTRY_ENVIRONMENT": (str, "production"),
}

if DEBUG:
    default_databse_url = (  # pylint: disable=invalid-name
        "postgres://*****:*****@db:5432/django")
    scheme = {
        **scheme,
        **{
            "CELERY_BROKER_URL": (str, "redis://redis/0"),
Exemplo n.º 15
0
ENV = Env()

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = Path(__file__) - 3

# 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.str("SECRET_KEY")

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

#ALLOWED_HOSTS = ['0.0.0.0', '127.0.0.1']
# 'DJANGO_ALLOWED_HOSTS' should be a single string of hosts with a space between each.
# For example: 'DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1]'
ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS").split(" ")

ALLOWED_HOSTS = ['django', '0.0.0.0', '127.0.0.1']

# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
Exemplo n.º 16
0
RESOURCE_DIR = 'resources'
RESOURCES_PATH = join(REPO_PATH, RESOURCE_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(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('ADMIN_EMAIL', default='admin@%s.com' % PROJECT_NAME)
ADMIN_NAME = env('ADMIN_NAME', default=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
Exemplo n.º 17
0
    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")

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

ALLOWED_HOSTS = ["*"]
APP_HOST = ENV.str("APP_HOST", "localhost")

# Application definition

INSTALLED_APPS = [
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
    "django.contrib.messages",
    "django.contrib.staticfiles",
    "django.contrib.humanize",
    "rest_framework",
    "rest_framework.authtoken",
Exemplo n.º 18
0
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
SESSION_COOKIE_SECURE: bool = False
X_FRAME_OPTIONS: str = 'DENY'
Exemplo n.º 19
0
# 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("SECRET_KEY")

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

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

ELASTIC_APM_ENABLED = env("ELASTIC_APM_ENABLED", default=not DEBUG)

PRIORITISATION_STRATEGIC_ASSESSMENTS = env.bool(
    "PRIORITISATION_STRATEGIC_ASSESSMENTS", default=False)

if ELASTIC_APM_ENABLED:
    ELASTIC_APM = {
        "SERVICE_NAME": "market-access-pyfe",
        "SECRET_TOKEN": env("ELASTIC_APM_SECRET_TOKEN"),
        "SERVER_URL": env("ELASTIC_APM_URL"),
        "ENVIRONMENT": env("ENVIRONMENT", default="dev"),
    }

BASE_APPS = [
    # apps that need to load first
    "whitenoise.runserver_nostatic",
]

DJANGO_APPS = [
Exemplo n.º 20
0
from raven import fetch_git_sha
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)
Exemplo n.º 21
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',
"""
Django settings for application project.
"""
from os.path import abspath, dirname, join
from environ import Env
BASE_DIR = dirname(dirname(abspath(__file__)))

env = Env()  # pylint: disable=invalid-name
Env.read_env(join(BASE_DIR, '.env'))

DEBUG = env.bool('DJANGO_DEBUG', default=True)

SECRET_KEY = 'dummy-secret' if DEBUG else env('DJANGO_SECRET_KEY')

ALLOWED_HOSTS = [] if DEBUG else [
    'example.com',
]

# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    {%- if cookiecutter.monitoring == 'Sentry' %}
    'raven.contrib.django.raven_compat',
    {%- endif %}
]
Exemplo n.º 23
0
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",
    "django.contrib.contenttypes",
    "django.contrib.auth",
    "django.contrib.humanize",
Exemplo n.º 24
0
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, "templates")],
        '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',
            ],
        },
    },
]

SESSION_ENGINE = 'django.contrib.sessions.backends.signed_cookies'
SESSION_COOKIE_SECURE = env.bool("SESSION_COOKIE_SECURE", True)
SESSION_COOKIE_NAME = env("SESSION_COOKIE_NAME", default="internal")

WSGI_APPLICATION = 'internal_fe.wsgi.application'

LOGIN_REDIRECT_URL = reverse_lazy("home")

# Authbroker config
AUTHBROKER_URL = env("AUTHBROKER_URL")
AUTHBROKER_CLIENT_ID = env("AUTHBROKER_CLIENT_ID")
AUTHBROKER_CLIENT_SECRET = env("AUTHBROKER_CLIENT_SECRET")

# requests_oauthlib
OAUTHLIB_INSECURE_TRANSPORT = env("OAUTHLIB_INSECURE_TRANSPORT", default=0)

AUTHENTICATION_BACKENDS = [
Exemplo n.º 25
0
import dotenv
from environ import 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__)))
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",
Exemplo n.º 26
0
TIME_ZONE = "US/Eastern"

# If you set this to True, Django will use timezone-aware datetimes.
USE_TZ = True

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = "en-us"

# Supported languages
LANGUAGES = (("en-us", _("English")), )

# A boolean that turns on/off debug mode. When set to ``True``, stack traces
# are displayed for error pages. Should always be set to ``False`` in
# production. Best set to ``True`` in local_settings.py
DEBUG = ENV.bool("DEBUG", default=False)

# Whether a user's session cookie expires when the Web browser is closed.
SESSION_EXPIRE_AT_BROWSER_CLOSE = True

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = False
USE_L10N = False

AUTHENTICATION_BACKENDS = ("mezzanine.core.auth_backends.MezzanineBackend", )

STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
# Media Files Storage
Exemplo n.º 27
0
from raven import fetch_git_sha
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)
Exemplo n.º 28
0
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",
    "django.contrib.staticfiles",
    # Vendor
Exemplo n.º 29
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',
Exemplo n.º 30
0
from raven import fetch_git_sha
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):
Exemplo n.º 31
0
from environ import Env
from core.settings.settings import *

env = Env()

DEBUG = env.bool('DEBUG')

SECRET_KEY = env('SECRET_KEY')

ALLOWED_HOSTS = env.list('ALLOWED_HOSTS')

DATABASES = {
    'default': env.db(),
}
Exemplo n.º 32
0
from environ import Env

from .env import *  # noqa: F401, F403

env = Env()

# SECURITY
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-proxy-ssl-header
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-ssl-redirect
SECURE_SSL_REDIRECT = env.bool("DJANGO_SECURE_SSL_REDIRECT", default=True)
# https://docs.djangoproject.com/en/dev/ref/settings/#session-cookie-secure
SESSION_COOKIE_SECURE = True
# https://docs.djangoproject.com/en/dev/ref/settings/#csrf-cookie-secure
CSRF_COOKIE_SECURE = True
# https://docs.djangoproject.com/en/dev/topics/security/#ssl-https
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-hsts-seconds
# NOTICE: set this to 60 seconds first and then to 518400 once you prove the former works
SECURE_HSTS_SECONDS = env.int("DJANGO_SECURE_HSTS_SECONDS", default=60)
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-hsts-include-subdomains
SECURE_HSTS_INCLUDE_SUBDOMAINS = env.bool(
    "DJANGO_SECURE_HSTS_INCLUDE_SUBDOMAINS", default=True)
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-hsts-preload
SECURE_HSTS_PRELOAD = env.bool("DJANGO_SECURE_HSTS_PRELOAD", default=True)
# https://docs.djangoproject.com/en/dev/ref/middleware/#x-content-type-options-nosniff
SECURE_CONTENT_TYPE_NOSNIFF = env.bool("DJANGO_SECURE_CONTENT_TYPE_NOSNIFF",
                                       default=True)

# STATIC
# ------------------------
Exemplo n.º 33
0
# 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 = "America/El_Salvador"

# If you set this to True, Django will use timezone-aware datetimes.
USE_TZ = True

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = "es"

# A boolean that turns on/off debug mode. When set to ``True``, stack traces
# are displayed for error pages. Should always be set to ``False`` in
# production. Best set to ``True`` in local_settings.py
DEBUG = env.bool("DEBUG", default=False)

# Whether a user's session cookie expires when the Web browser is closed.
SESSION_EXPIRE_AT_BROWSER_CLOSE = True

# This is just a default value. You can manually set it to the site you want
# by passing the flag --site=ID to any manage.py command.
SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

# Tuple of IP addresses, as strings, that:
#   * See debug comments, when DEBUG is true
#   * Receive x-headers
Exemplo n.º 34
0
RESOURCE_DIR = 'resources'
RESOURCES_PATH = join(REPO_PATH, RESOURCE_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(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),
)
Exemplo n.º 35
0
# 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')

# If you set this to True, Django will use timezone-aware datetimes.
USE_TZ = env.bool('USE_TZ', default=True)

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = "en"

# Supported languages
LANGUAGES = (
    ('en', _('English')),
)

# A boolean that turns on/off debug mode. When set to ``True``, stack traces
# are displayed for error pages. Should always be set to ``False`` in
# production. Best set to ``True`` in local_settings.py
DEBUG = env.bool('DEBUG', default=False)
Exemplo n.º 36
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
Exemplo n.º 37
0
#####################################
# LOCAL VARS
#####################################

ROOT_DIR = Path(__file__) - 2
APPS_DIR = ROOT_DIR.path('apps')
environ = Env()

#####################################
# SECURITY SETTINGS
#####################################

SECRET_KEY = environ('DJANGO_SECRET_KEY', default='CHANGEME!!!')

DEBUG = environ.bool('DJANGO_DEBUG', False)

ALLOWED_HOSTS = environ.list('DJANGO_ALLOWED_HOSTS',
                             default=['www.yourdomain.com'])

#####################################
# INSTALLED APPS
#####################################

DJANGO_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
Exemplo n.º 38
0
from environ import Env

from inloop.accounts import constance as accounts_constance
from inloop.gitload import constance as gitload_constance
from inloop.solutions import constance as solutions_constance

if sys.getfilesystemencoding() != "utf-8":
    raise ImproperlyConfigured("LANG must be a utf-8 locale")

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

env = Env()

SECRET_KEY = env("SECRET_KEY")
DEBUG = env.bool("DEBUG", default=False)
ALLOWED_HOSTS = [host.strip() for host in env.list("ALLOWED_HOSTS")]
INTERNAL_IPS = [ip.strip() for ip in env.list("INTERNAL_IPS", default="")]

SITE_ID = 1

INSTALLED_APPS = [
    "inloop.accounts",
    "inloop.common",
    "inloop.grading",
    "inloop.solutions",
    "inloop.tasks",
    "inloop.testrunner",
    "inloop.gitload",

    "django.contrib.admin",
Exemplo n.º 39
0
RESOURCE_DIR = 'resources'
RESOURCES_PATH = join(REPO_PATH, RESOURCE_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(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)
DEBUG_TOOLBAR = env.bool('DEBUG_TOOLBAR', DEBUG)
########## END DEBUG CONFIGURATION


########## MANAGER CONFIGURATION
ADMIN_EMAIL = env('ADMIN_EMAIL', default='admin@%s.com' % PROJECT_NAME)
ADMIN_NAME = env('ADMIN_NAME', default=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