Exemple #1
0
    def _validate_database_url(self, question, url):
        # Ensure django is setup
        django.setup()

        try:
            db = dj_database_url.parse(url)
        except KeyError:
            return False, 'Failed to parse database URL.\n'

        options = {}

        if 'sqlite' not in db['ENGINE']:
            options['connect_timeout'] = 3

        db['OPTIONS'] = options

        # These are django defaults - the cursor() call craps out if these are missing.
        db['AUTOCOMMIT'] = True
        db['TIME_ZONE'] = None

        try:
            engine = load_backend(db['ENGINE']).DatabaseWrapper(db)
            engine.cursor()
        except KeyError:
            return False, 'Invalid database URL provided.\n'
        except Exception as e:
            return False, '{0}\n'.format(str(e))
        return True, ''
    def test_options_sqlite_url(self):
        url = 'sqlite://?OPTIONS={"timeout":30}'
        url = dj_database_url.parse(url)

        assert url['ENGINE'] == 'django.db.backends.sqlite3'
        assert url['NAME'] == ':memory:'
        assert url['OPTIONS'] == {'timeout':30}
Exemple #3
0
def import_db(dump_file=None):
    """
    Restore the given database dump.

    The dump must be a gzipped SQL dump. If the dump_file parameter is not set,
    the database will be dumped and retrieved from the remote host.
    """
    with open('envdir/DATABASE_URL', 'r') as db_credentials_file:
        db_credentials = db_credentials_file.read()
    db_credentials_dict = dj_database_url.parse(db_credentials)

    if not is_supported_db_engine(db_credentials_dict['ENGINE']):
        raise NotImplementedError(
            "The import_db task only supports postgresql databases"
        )

    if dump_file is None:
        dump_file = fetch_db()

    db_info = {
        'host': db_credentials_dict['HOST'],
        'user': db_credentials_dict['USER'],
        'db': db_credentials_dict['NAME'],
        'db_dump': dump_file
    }

    with shell_env(PGPASSWORD=db_credentials_dict['PASSWORD']):
        with settings(warn_only=True):
            local('dropdb -h {host} -U {user} {db}'.format(**db_info))

        local('createdb -h {host} -U {user} {db}'.format(**db_info))
        local('gunzip -c {db_dump}|psql -h {host} -U {user} {db}'.format(
            **db_info
        ))
Exemple #4
0
    def parse_database_url(self, database_url):
        def parse_postgres(database_dict):
            database = dict(database_dict)
            return {
                'provider': 'postgres',
                'database': database.get('NAME'),
                'user': database.get('USER'),
                'password': database.get('PASSWORD'),
                'host': database.get('HOST'),
                'port': database.get('PORT'),
            }

        def parse_sqlite(database_dict):
            return {
                'provider': 'sqlite',
                'filename': database_dict['PATH'],
            }

        try:
            dj_engine_to_pony_provider = {
                'django.db.backends.postgresql_psycopg2': parse_postgres,
                'django.db.backends.sqlite3': parse_sqlite,
            }
            parsed = dj_database_url.parse(database_url)
            return dj_engine_to_pony_provider[parsed['ENGINE']](parsed)
        except KeyError:
            raise Exception('There was an error parsing the database_url configuration.')
Exemple #5
0
def fetch_db(destination='.'):
    """
    Dump the database on the remote host and retrieve it locally.

    The destination parameter controls where the dump should be stored locally.
    """
    with nested(cd(env.project_root), quiet()):
        db_credentials = run('cat envdir/DATABASE_URL')
    db_credentials_dict = dj_database_url.parse(db_credentials)

    if not is_supported_db_engine(db_credentials_dict['ENGINE']):
        raise NotImplementedError(
            "The fetch_db task only supports postgresql databases"
        )

    outfile = datetime.now().strftime('%Y-%m-%d_%H%M%S.sql.gz')
    outfile_remote = os.path.join('~', outfile)

    with shell_env(PGPASSWORD=db_credentials_dict['PASSWORD'].replace('$', '\$')):
        run('pg_dump -O -x -h {host} -U {user} {db}|gzip > {outfile}'.format(
            host=db_credentials_dict['HOST'],
            user=db_credentials_dict['USER'],
            db=db_credentials_dict['NAME'],
            outfile=outfile_remote))

    get(outfile_remote, destination)
    run('rm %s' % outfile_remote)

    return outfile
Exemple #6
0
def load(url, verbose=False):
    dj_details = dj_database_url.parse(url)
    database_cls = DJANGO_ENGINE_TO_DBCONN_MAP.get(dj_details['ENGINE'])
    if database_cls is None:
        raise DatabaseUrlError(
            'Unable to determine the database from the URL')
    return database_cls.create_from_django_database(dj_details, verbose)
Exemple #7
0
def drop_postgis_shard(db_name):
    """
    Drop a PostGIS shard database by name.
    """
    Database.objects.filter(name=db_name).delete()
    logger.info("Dropping PostGIS datatase shard: %s" % db_name)
    try:
        datastore_db = dj_database_url.parse(settings.DATASTORE_URL)
        user = datastore_db['USER']
        host = datastore_db['HOST']
        port = datastore_db['PORT']
        password = datastore_db['PASSWORD']
        conn = connect(dbname='template1', user=user, host=host, port=port, password=password)
        conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
        cur = conn.cursor()
        cur.execute('DROP DATABASE %s;' % db_name)
        cur.close()
        conn.close()
    except Exception as e:
        print str(e)
        logger.error(
            "Error dropping PostGIS database shard %s: %s" % (db_name, str(e)))
    finally:
        try:
            if conn:
                conn.close()
        except Exception as e:
            logger.error("Error closing PostGIS conn %s", str(e))
Exemple #8
0
 def setUp(self):
     super(CreateLayerCoreTest, self).setUp()
     # createlayer must use postgis as a datastore
     # set temporary settings to use a postgis datastore
     DATASTORE_URL = 'postgis://*****:*****@localhost:5432/datastore'
     postgis_db = dj_database_url.parse(DATASTORE_URL, conn_max_age=600)
     settings.DATABASES['datastore'] = postgis_db
     settings.OGC_SERVER['default']['DATASTORE'] = 'datastore'
Exemple #9
0
def _dj_db_url_parser(value, **kwargs):
    try:
        import dj_database_url
    except ImportError:
        raise RuntimeError(
            "The dj_db_url parser requires the dj-database-url package. "
            "You can install it with: pip install dj-database-url"
        )
    return dj_database_url.parse(value, **kwargs)
    def test_mysql_gis_parsing(self):
        url = 'mysqlgis://*****:*****@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722r2kuvn'
        url = dj_database_url.parse(url)

        assert url['ENGINE'] == 'django.contrib.gis.db.backends.mysql'
        assert url['NAME'] == 'd8r82722r2kuvn'
        assert url['HOST'] == 'ec2-107-21-253-135.compute-1.amazonaws.com'
        assert url['USER'] == 'uf07k1i6d8ia0v'
        assert url['PASSWORD'] == 'wegauwhgeuioweg'
        assert url['PORT'] == 5431
    def test_redshift_parsing(self):
        url = 'redshift://*****:*****@ec2-107-21-253-135.compute-1.amazonaws.com:5439/d8r82722r2kuvn'
        url = dj_database_url.parse(url)

        assert url['ENGINE'] == 'django_redshift_backend'
        assert url['NAME'] == 'd8r82722r2kuvn'
        assert url['HOST'] == 'ec2-107-21-253-135.compute-1.amazonaws.com'
        assert url['USER'] == 'uf07k1i6d8ia0v'
        assert url['PASSWORD'] == 'wegauwhgeuioweg'
        assert url['PORT'] == 5439
    def test_postgres_unix_socket_parsing(self):
        url = "postgres://%2Fvar%2Frun%2Fpostgresql/d8r82722r2kuvn"
        url = dj_database_url.parse(url)

        assert url["ENGINE"] == "django.db.backends.postgresql_psycopg2"
        assert url["NAME"] == "d8r82722r2kuvn"
        assert url["HOST"] == "/var/run/postgresql"
        assert url["USER"] == ""
        assert url["PASSWORD"] == ""
        assert url["PORT"] == ""
Exemple #13
0
 def setUp(self):
     super(DatastoreShardsCoreTest, self).setUp()
     # set temporary settings to use a postgis datastore
     settings.DATASTORE_URL = 'postgis://*****:*****@localhost:5432/datastore'
     postgis_db = dj_database_url.parse(settings.DATASTORE_URL, conn_max_age=600)
     settings.DATABASES['datastore'] = postgis_db
     settings.OGC_SERVER['default']['DATASTORE'] = 'datastore'
     settings.SHARD_STRATEGY = 'layercount'
     settings.SHARD_LAYER_COUNT = SHARD_LAYER_COUNT
     settings.SHARD_PREFIX = SHARD_PREFIX
    def test_cleardb_parsing(self):
        url = "mysql://*****:*****@us-cdbr-east.cleardb.com/heroku_97681db3eff7580?reconnect=true"
        url = dj_database_url.parse(url)

        assert url["ENGINE"] == "django.db.backends.mysql"
        assert url["NAME"] == "heroku_97681db3eff7580"
        assert url["HOST"] == "us-cdbr-east.cleardb.com"
        assert url["USER"] == "bea6eb025ca0d8"
        assert url["PASSWORD"] == "69772142"
        assert url["PORT"] == ""
    def test_mysql_gis_parsing(self):
        url = "mysqlgis://*****:*****@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722r2kuvn"
        url = dj_database_url.parse(url)

        assert url["ENGINE"] == "django.contrib.gis.db.backends.mysql"
        assert url["NAME"] == "d8r82722r2kuvn"
        assert url["HOST"] == "ec2-107-21-253-135.compute-1.amazonaws.com"
        assert url["USER"] == "uf07k1i6d8ia0v"
        assert url["PASSWORD"] == "wegauwhgeuioweg"
        assert url["PORT"] == 5431
    def test_postgres_parsing(self):
        url = 'postgres://*****:*****@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722r2kuvn'
        url = dj_database_url.parse(url)

        assert url['ENGINE'] == EXPECTED_POSTGRES_ENGINE
        assert url['NAME'] == 'd8r82722r2kuvn'
        assert url['HOST'] == 'ec2-107-21-253-135.compute-1.amazonaws.com'
        assert url['USER'] == 'uf07k1i6d8ia0v'
        assert url['PASSWORD'] == 'wegauwhgeuioweg'
        assert url['PORT'] == 5431
    def test_mysql_connector_parsing(self):
        url = 'mysql-connector://uf07k1i6d8ia0v:[email protected]:5431/d8r82722r2kuvn'
        url = dj_database_url.parse(url)

        assert url['ENGINE'] == 'mysql.connector.django'
        assert url['NAME'] == 'd8r82722r2kuvn'
        assert url['HOST'] == 'ec2-107-21-253-135.compute-1.amazonaws.com'
        assert url['USER'] == 'uf07k1i6d8ia0v'
        assert url['PASSWORD'] == 'wegauwhgeuioweg'
        assert url['PORT'] == 5431
    def test_oracle_tns_parsing(self):
        url = 'oracle://*****:*****@/tnsname'
        url = dj_database_url.parse(url)

        assert url['ENGINE'] == 'django.db.backends.oracle'
        assert url['USER'] == 'scott'
        assert url['PASSWORD'] == 'tiger'
        assert url['NAME'] == 'tnsname'
        assert url['HOST'] == ''
        assert url['PORT'] == ''
    def test_cleardb_parsing(self):
        url = 'mysql://*****:*****@us-cdbr-east.cleardb.com/heroku_97681db3eff7580?reconnect=true'
        url = dj_database_url.parse(url)

        assert url['ENGINE'] == 'django.db.backends.mysql'
        assert url['NAME'] == 'heroku_97681db3eff7580'
        assert url['HOST'] == 'us-cdbr-east.cleardb.com'
        assert url['USER'] == 'bea6eb025ca0d8'
        assert url['PASSWORD'] == '69772142'
        assert url['PORT'] == ''
    def test_ipv6_parsing(self):
        url = 'postgres://*****:*****@[2001:db8:1234::1234:5678:90af]:5431/d8r82722r2kuvn'
        url = dj_database_url.parse(url)

        assert url['ENGINE'] == EXPECTED_POSTGRES_ENGINE
        assert url['NAME'] == 'd8r82722r2kuvn'
        assert url['HOST'] == '2001:db8:1234::1234:5678:90af'
        assert url['USER'] == 'ieRaekei9wilaim7'
        assert url['PASSWORD'] == 'wegauwhgeuioweg'
        assert url['PORT'] == 5431
    def test_postgres_unix_socket_parsing(self):
        url = 'postgres://%2Fvar%2Frun%2Fpostgresql/d8r82722r2kuvn'
        url = dj_database_url.parse(url)

        assert url['ENGINE'] == EXPECTED_POSTGRES_ENGINE
        assert url['NAME'] == 'd8r82722r2kuvn'
        assert url['HOST'] == '/var/run/postgresql'
        assert url['USER'] == ''
        assert url['PASSWORD'] == ''
        assert url['PORT'] == ''

        url = 'postgres://%2FUsers%2Fpostgres%2FRuN/d8r82722r2kuvn'
        url = dj_database_url.parse(url)

        assert url['ENGINE'] == EXPECTED_POSTGRES_ENGINE
        assert url['HOST'] == '/Users/postgres/RuN'
        assert url['USER'] == ''
        assert url['PASSWORD'] == ''
        assert url['PORT'] == ''
    def test_postgres_parsing_with_special_characters(self):
        url = 'postgres://%23user:%[email protected]:5431/%23database'
        url = dj_database_url.parse(url)

        assert url['ENGINE'] == EXPECTED_POSTGRES_ENGINE
        assert url['NAME'] == '#database'
        assert url['HOST'] == 'ec2-107-21-253-135.compute-1.amazonaws.com'
        assert url['USER'] == '#user'
        assert url['PASSWORD'] == '#password'
        assert url['PORT'] == 5431
    def test_postgres_unix_socket_parsing(self):
        url = 'postgres://%2Fvar%2Frun%2Fpostgresql/d8r82722r2kuvn'
        url = dj_database_url.parse(url)

        assert url['ENGINE'] == 'django.db.backends.postgresql_psycopg2'
        assert url['NAME'] == 'd8r82722r2kuvn'
        assert url['HOST'] == '/var/run/postgresql'
        assert url['USER'] == ''
        assert url['PASSWORD'] == ''
        assert url['PORT'] == ''
 def test_postgres_search_path_parsing(self):
     url = 'postgres://*****:*****@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722r2kuvn?currentSchema=otherschema'
     url = dj_database_url.parse(url)
     assert url['ENGINE'] == 'django.db.backends.postgresql_psycopg2'
     assert url['NAME'] == 'd8r82722r2kuvn'
     assert url['HOST'] == 'ec2-107-21-253-135.compute-1.amazonaws.com'
     assert url['USER'] == 'uf07k1i6d8ia0v'
     assert url['PASSWORD'] == 'wegauwhgeuioweg'
     assert url['PORT'] == 5431
     assert url['OPTIONS'] == {'options': '-c search_path=otherschema'}
 def __call__(self, parser, namespace, values, option_string):
     parsed = dj_database_url.parse(values)
     if parsed.get('ENGINE', None):
         if DRIVERS[parsed['ENGINE']] == 'postgis':
             sys.stdout.write("postgis installation is not supported at the moment.\nYou need to install and configure the backend.\n")
         setattr(namespace, self.dest, values)
         setattr(namespace, "%s_parsed" % self.dest, parsed)
         setattr(namespace, "%s_driver" % self.dest, DRIVERS[parsed['ENGINE']])
     else:
         raise ValueError("Database URL not recognized, try again")
    def test_oracle_gis_parsing(self):
        url = 'oraclegis://*****:*****@oraclehost:1521/hr'
        url = dj_database_url.parse(url)

        assert url['ENGINE'] == 'django.contrib.gis.db.backends.oracle'
        assert url['NAME'] == 'hr'
        assert url['HOST'] == 'oraclehost'
        assert url['USER'] == 'scott'
        assert url['PASSWORD'] == 'tiger'
        assert url['PORT'] == 1521
    def test_special_chars_parsing_2(self):
        url = 'mysql://*****:*****@ec2-107-21-253-135.compute-1.amazonaws.com:5431/PATH_WITH_QUERY?abc=True'
        url = dj_database_url.parse(url)

        assert url['ENGINE'] == 'django.db.backends.mysql'
        assert url['NAME'] == 'PATH_WITH_QUERY'
        assert url['HOST'] == 'ec2-107-21-253-135.compute-1.amazonaws.com'
        assert url['USER'] == 'you-case-wx123'
        assert url['PASSWORD'] == 'N.>Pp12&!$#%^*();\'[]\''
        assert url['PORT'] == 5431
    def test_special_chars_parsing_1(self):
        url = 'postgres://*****:*****@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722r2kuvn'
        url = dj_database_url.parse(url)

        assert url['ENGINE'] == 'django.db.backends.postgresql_psycopg2'
        assert url['NAME'] == 'd8r82722r2kuvn'
        assert url['HOST'] == 'ec2-107-21-253-135.compute-1.amazonaws.com'
        assert url['USER'] == '1uf07k1i6d8ia0v_'
        assert url['PASSWORD'] == 'wegauwhgeu!$%#&io#&^%weg'
        assert url['PORT'] == 5431
    def test_options_parsing(self):
        url = 'mongodb://*****:*****@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722r2kuvn'
        url = dj_database_url.parse(url, options='TEST_OPTION')

        assert url['ENGINE'] == 'django_mongodb_engine'
        assert url['NAME'] == 'd8r82722r2kuvn'
        assert url['HOST'] == 'ec2-107-21-253-135.compute-1.amazonaws.com'
        assert url['USER'] == 'uf07k1i6d8ia0v'
        assert url['PASSWORD'] == 'wegauwhgeuioweg'
        assert url['PORT'] == 5431
        assert url['OPTIONS'] == 'TEST_OPTION'
 def test_postgres_search_path_parsing(self):
     url = 'postgres://*****:*****@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722r2kuvn?currentSchema=otherschema'
     url = dj_database_url.parse(url)
     assert url['ENGINE'] == EXPECTED_POSTGRES_ENGINE
     assert url['NAME'] == 'd8r82722r2kuvn'
     assert url['HOST'] == 'ec2-107-21-253-135.compute-1.amazonaws.com'
     assert url['USER'] == 'uf07k1i6d8ia0v'
     assert url['PASSWORD'] == 'wegauwhgeuioweg'
     assert url['PORT'] == 5431
     assert url['OPTIONS']['options'] == '-c search_path=otherschema'
     assert 'currentSchema' not in url['OPTIONS']
# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases

if DEVELOPMENT_MODE is True:
    DATABASES = {
        "default": {
            "ENGINE": "django.db.backends.sqlite3",
            "NAME": os.path.join(BASE_DIR, "db.sqlite3"),
        }
    }
elif len(sys.argv) > 0 and sys.argv[1] != 'collectstatic':
    if os.getenv("DATABASE_URL", None) is None:
        raise Exception("DATABASE_URL environment variable not defined")
    DATABASES = {
        "default": dj_database_url.parse(os.environ.get("DATABASE_URL")),
    }


# Password validation
# https://docs.djangoproject.com/en/3.1/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',
Exemple #32
0
DOCKER = os.getenv('DOCKER', False)
CARTOVIEW_CONTEXT_PROCESSORS = (
    'cartoview.app_manager.context_processors.cartoview_processor',
    'cartoview.app_manager.context_processors.site_logo')
TEMPLATES[0]["OPTIONS"]['context_processors'] += CARTOVIEW_CONTEXT_PROCESSORS
# django Media Section
# uncomment the following if you want your files out of geonode folder
MEDIA_ROOT = os.path.join(BASE_DIR, "uploaded")
MEDIA_URL = "/uploaded/"
LOCAL_MEDIA_URL = "/uploaded/"
# static section
STATIC_ROOT = os.path.join(BASE_DIR, "static")
DATABASE_URL = os.getenv('DATABASE_URL', None)
DATASTORE_DATABASE_URL = os.getenv('DATASTORE_DATABASE_URL', None)
if DATABASE_URL:
    DATABASES['default'] = dj_database_url.parse(DATABASE_URL,
                                                 conn_max_age=600)
if DATASTORE_DATABASE_URL:
    DATABASES['datastore'] = dj_database_url.parse(DATASTORE_DATABASE_URL,
                                                   conn_max_age=600)
try:
    # try to parse python notation, default in dockerized env
    ALLOWED_HOSTS = ast.literal_eval(os.getenv('ALLOWED_HOSTS'))
except ValueError:
    # fallback to regular list of values separated with misc chars
    ALLOWED_HOSTS = ['*'] if os.getenv('ALLOWED_HOSTS') is None \
        else re.split(r' *[,|:|;] *', os.getenv('ALLOWED_HOSTS'))
try:
    from .local_settings import *
except Exception as e:
    pass
if 'test' in sys.argv:
        'NAME': 'accencisdb',
        'USER': '******',
        'PASSWORD': '******',
        'HOST': 'localhost',
        'PORT': '',
    }
}
# DATABASES = {
#     'default': {
#         'ENGINE': 'django.db.backends.sqlite3',
#         'NAME': os.path.join(PROJECT_ROOT, 'db.sqlite3'),
#     }
# }
DATABASES_URL = os.environ['DATABASE_URL']
#
DATABASES['default'] = dj_database_url.parse(DATABASES_URL, conn_max_age=600)

STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles')
STATIC_URL = '/accencisstatic/'
# Extra places for collectstatic to find static files.
STATICFILES_DIRS = (os.path.join(PROJECT_ROOT, 'static'), )
MEDIA_URL = '/accencismedia/'
MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media')

HOST = "https://accencis.biz"

# Google cloud for images
DEFAULT_FILE_STORAGE = 'storages.backends.gcloud.GoogleCloudStorage'
GS_PROJECT_ID = 'accencis'
GS_BUCKET_NAME = 'accencis'
GS_FILE_OVERWRITE = True
Exemple #34
0
    },
]

WSGI_APPLICATION = 'config.wsgi.application'

# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

DATABASES = {'default': dj_database_url.parse(config('DATABASE_URL'))}

# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)
Exemple #35
0
from app.settings.common import *
import os

import dj_database_url

DATABASES['default'] = dj_database_url.parse(os.environ['DATABASE_URL'])

DEBUG = False

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'verbose': {
            'format':
            '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
        },
        'simple': {
            'format': '%(levelname)s %(message)s'
        },
    },
    'handlers': {
        'console': {
            'class': 'logging.StreamHandler',
            'formatter': 'verbose'
        },
    },
    'loggers': {
        'django': {
            'handlers': ['console'],
            'propagate': True,
Exemple #36
0
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'mulheres_palestrantes.wsgi.application'

# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases

DATABASES = {
    'default':
    dj_database_url.parse(
        config('DATABASE_URL',
               default='sqlite:///mulheres_palestrantes.sqlite'))
}

# Password validation
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = []

# Internationalization
# https://docs.djangoproject.com/en/1.10/topics/i18n/

LANGUAGE_CODE = config('LANGUAGE_CODE', default='en-us')

TIME_ZONE = config('LANGUAGE_CODE', default='UTC')
Exemple #37
0
import os
import dj_database_url

from environs import Env

env = Env()
env.read_env()

DATABASES = {'default': dj_database_url.parse(env.str('DB_SETTINGS'))}

INSTALLED_APPS = ['datacenter']

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

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

ROOT_URLCONF = "project.urls"

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

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        'APP_DIRS': True,
    },
]

USE_L10N = True
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
                'django.template.context_processors.media',
                'cart.contexts.cart_contents',
            ],
        },
    },
]

WSGI_APPLICATION = 'golfvouchers.wsgi.application'

# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases

if "DATABASE_URL" in os.environ:
    DATABASES = {"default": dj_database_url.parse(os.getenv("DATABASE_URL"))}
else:
    print("Postgres URL not found, using sqlite3 instead")
    DATABASES = {
        "default": {
            "ENGINE": "django.db.backends.sqlite3",
            "NAME": os.path.join(BASE_DIR, "db.sqlite3"),
        }
    }

# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME':
Exemple #39
0
ENGAGE_ROBOTS = False

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = private.EMAIL_HOST

DEBUG = False
TEMPLATE_DEBUG = DEBUG
DEBUG_PROPAGATE_EXCEPTIONS = False
SESSION_COOKIE_SECURE = True
REDIRECT_SECRET_KEY = private.REDIRECT_SECRET_KEY

ADMINS = ()

DATABASES = {}
DATABASES['default'] = dj_database_url.parse(private.DATABASES_DEFAULT_URL)
DATABASES['default']['ENGINE'] = 'mysql_pool'
DATABASES['default']['OPTIONS'] = {'init_command': 'SET storage_engine=InnoDB'}

DATABASES['slave'] = dj_database_url.parse(private.DATABASES_SLAVE_URL)
DATABASES['slave']['ENGINE'] = 'mysql_pool'
DATABASES['slave']['OPTIONS'] = {'init_command': 'SET storage_engine=InnoDB'}

SERVICES_DATABASE = dj_database_url.parse(private.SERVICES_DATABASE_URL)

DATABASE_POOL_ARGS = {'max_overflow': 10, 'pool_size': 5, 'recycle': 30}

SLAVE_DATABASES = ['slave']

CACHES = {
    'default': {
# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases

if 'DEVELOPMENT' in os.environ:
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': BASE_DIR / 'db.sqlite3',
        }
    }
    print("I am Connected to sqlite")
else:
    if 'JACXX_DATABASE_URL' in os.environ:
        DATABASES = {
            'default':
            dj_database_url.parse(os.environ.get('JACXX_DATABASE_URL'))
        }

        print("I am Connected to Postgress")

# Password validation
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME':
        'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME':
        'django.contrib.auth.password_validation.MinimumLengthValidator',
Exemple #41
0
                '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_url = os.getenv("DATABASE_URL", _ds.DATABASE_URL)

DATABASES = {
    "default": dj_database_url.parse(database_url),
}


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',
Exemple #42
0
ACCOUNT_AUTHENTICATION_METHOD = 'username_email'
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
ACCOUNT_SIGNUP_EMAIL_ENTER_TWICE = True
ACCOUNT_USERNAME_MIN_LENGTH = 4
LOGIN_URL = '/accounts/login/'
LOGIN_REDIRECT_URL = '/'

WSGI_APPLICATION = 'winenation.wsgi.application'

# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases

if 'DATABASE_URL' in os.environ:
    DATABASES = {
        'default': dj_database_url.parse(os.environ.get('DATABASE_URL'))
    }
else:
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
        }
    }

# Password validation
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME':
Exemple #43
0
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'telephone_calls.wsgi.application'

# Database
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases

DATABASES = {
    'default':
    dj_database_url.parse(os.environ.get("DATABASE_URL"), conn_max_age=600)
}

# Password validation
# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME':
        'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME':
        'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
Exemple #44
0
def _make_settings(args, application, settings, STATIC_ROOT, MEDIA_ROOT):
    """
    Setup the Django settings
    :param args: docopt arguments
    :param default_settings: default Django settings
    :param settings: Django settings module
    :param STATIC_ROOT: static root directory
    :param MEDIA_ROOT: media root directory
    :return:
    """
    import dj_database_url
    from .default_settings import get_default_settings, get_boilerplates_settings

    try:
        extra_settings_file = args.get('--extra-settings')
        if not extra_settings_file:
            extra_settings_file = HELPER_FILE
        if extra_settings_file[-3:] != '.py':
            filename, __ = os.path.splitext(extra_settings_file)
            extra_settings_file = '{0}.py'.format(filename)
        extra_settings = load_from_file(extra_settings_file).HELPER_SETTINGS
    except (IOError, AttributeError):
        extra_settings = None
    default_name = ':memory:' if args['test'] else 'local.sqlite'
    db_url = os.environ.get('DATABASE_URL', 'sqlite://localhost/%s' % default_name)
    configs = {
        'DATABASES': {'default': dj_database_url.parse(db_url)},
        'STATIC_ROOT': STATIC_ROOT,
        'MEDIA_ROOT': MEDIA_ROOT,
        'USE_TZ': True,
        'USE_CMS': args['--cms'],
        'BASE_APPLICATION': application
    }

    if configs['USE_CMS'] or getattr(extra_settings, 'USE_CMS', False):
        CMS_APPS = [
            'cms',
            'menus',
            'sekizai',
        ]
        CMS_APP_STYLE = [
            'djangocms_admin_style'
        ]
        CMS_PROCESSORS = [
            'cms.context_processors.cms_settings',
            'sekizai.context_processors.sekizai',
        ]
        CMS_MIDDLEWARE = [
            'cms.middleware.language.LanguageCookieMiddleware',
            'cms.middleware.user.CurrentUserMiddleware',
            'cms.middleware.page.CurrentPageMiddleware',
            'cms.middleware.toolbar.ToolbarMiddleware',
        ]
        if not CMS_31 and args['server']:
            CMS_MIDDLEWARE.append('cms.middleware.utils.ApphookReloadMiddleware')
        URLCONF = 'djangocms_helper.urls'
    else:
        CMS_APPS = []
        CMS_APP_STYLE = []
        CMS_MIDDLEWARE = []
        CMS_PROCESSORS = []
        URLCONF = 'djangocms_helper.urls'

    default_settings = get_default_settings(
        CMS_APPS, CMS_PROCESSORS, CMS_MIDDLEWARE, CMS_APP_STYLE, URLCONF, application
    )
    migrate = args.get('--migrate') or not args.get('--no-migrate')
    default_settings.update(configs)

    if extra_settings:
        apps = extra_settings.pop('INSTALLED_APPS', [])
        apps_top = extra_settings.pop('TOP_INSTALLED_APPS', [])
        template_processors = extra_settings.pop('TEMPLATE_CONTEXT_PROCESSORS', [])
        template_loaders = extra_settings.pop('TEMPLATE_LOADERS', [])
        template_dirs = extra_settings.pop('TEMPLATE_DIRS', [])
        middleware = extra_settings.pop('MIDDLEWARE_CLASSES', [])
        middleware_top = extra_settings.pop('TOP_MIDDLEWARE_CLASSES', [])
        default_settings.update(extra_settings)
        for app in apps_top:
            default_settings['INSTALLED_APPS'].insert(0, app)
        default_settings['INSTALLED_APPS'].extend(apps)
        default_settings['TEMPLATE_CONTEXT_PROCESSORS'].extend(template_processors)
        default_settings['TEMPLATE_LOADERS'].extend(template_loaders)
        if 'TEMPLATE_DIRS' not in default_settings:
            default_settings['TEMPLATE_DIRS'] = []
        default_settings['TEMPLATE_DIRS'].extend(template_dirs)
        default_settings['MIDDLEWARE_CLASSES'].extend(middleware)
        for middleware in middleware_top:
            default_settings['MIDDLEWARE_CLASSES'].insert(0, middleware)

    if 'cms' in default_settings['INSTALLED_APPS']:
        if 'treebeard' not in default_settings['INSTALLED_APPS']:
            default_settings['INSTALLED_APPS'].append('treebeard')
    if ('filer' in default_settings['INSTALLED_APPS'] and
            'mptt' not in default_settings['INSTALLED_APPS']):
        default_settings['INSTALLED_APPS'].append('mptt')
    if ('filer' in default_settings['INSTALLED_APPS'] and
            'easy_thumbnails' not in default_settings['INSTALLED_APPS']):
        default_settings['INSTALLED_APPS'].append('easy_thumbnails')

    if args['--boilerplate']:
        boilerplate_settings = get_boilerplates_settings()

        # Do not override helper settings with defaults.
        if 'ALDRYN_BOILERPLATE_NAME' in default_settings.keys():
            del boilerplate_settings['ALDRYN_BOILERPLATE_NAME']

        default_settings = extend_settings(
            default_settings, boilerplate_settings, 'STATICFILES_FINDERS',
            'django.contrib.staticfiles.finders.AppDirectoriesFinder'
        )
        del boilerplate_settings['STATICFILES_FINDERS']

        default_settings = extend_settings(
            default_settings, boilerplate_settings, 'TEMPLATE_LOADERS',
            'django.template.loaders.app_directories.Loader'
        )
        del boilerplate_settings['TEMPLATE_LOADERS']

        for setting in ('INSTALLED_APPS', 'TEMPLATE_CONTEXT_PROCESSORS'):
            default_settings[setting].extend(boilerplate_settings[setting])
            del boilerplate_settings[setting]
        default_settings.update(boilerplate_settings)

    default_settings['TEMPLATES'] = [
        {'NAME': 'django',
         'BACKEND': 'django.template.backends.django.DjangoTemplates',
         'OPTIONS': {
             'context_processors': [
                 template_processor.replace('django.core', 'django.template')
                 for template_processor in default_settings.pop('TEMPLATE_CONTEXT_PROCESSORS')
             ],
             'loaders': default_settings.pop('TEMPLATE_LOADERS')
         }}
    ]
    if 'TEMPLATE_DIRS' in default_settings:
        default_settings['TEMPLATES'][0]['DIRS'] = default_settings.pop('TEMPLATE_DIRS')

    # Support for custom user models
    if 'AUTH_USER_MODEL' in os.environ:
        custom_user_app = os.environ['AUTH_USER_MODEL'].rpartition('.')[0]
        custom_user_model = '.'.join(os.environ['AUTH_USER_MODEL'].split('.')[-2:])
        default_settings['INSTALLED_APPS'].insert(
            default_settings['INSTALLED_APPS'].index('cms'),
            custom_user_app
        )
        default_settings['AUTH_USER_MODEL'] = custom_user_model

    if args['test']:
        default_settings['SESSION_ENGINE'] = 'django.contrib.sessions.backends.cache'
    if application not in default_settings['INSTALLED_APPS']:
        default_settings['INSTALLED_APPS'].append(application)

    if not migrate:
        default_settings['MIGRATION_MODULES'] = DisableMigrations()

    if not DJANGO_1_9 and 'MIDDLEWARE' not in default_settings:
        default_settings['MIDDLEWARE'] = default_settings['MIDDLEWARE_CLASSES']
        del default_settings['MIDDLEWARE_CLASSES']

    _reset_django(settings)
    settings.configure(**default_settings)
    django.setup()
    reload_urls(settings, cms_apps=False)
    return settings
Exemple #45
0
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
                'django.template.context_processors.media',
            ],
        },
    },
]

WSGI_APPLICATION = 'ecomm_cb.wsgi.application'

# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases

db_url = r"sqlite:////" + os.path.join(BASE_DIR, 'db.sqlite3')
DATABASES = {'default': dj_database_url.parse(db_url)}

# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME':
        'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME':
        'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME':
Exemple #46
0
    {
        'NAME':
        'django.contrib.auth.password_validation.CommonPasswordValidator',  # noqa: E501
    },
    {
        'NAME':
        'django.contrib.auth.password_validation.NumericPasswordValidator',  # noqa: E501
    },
]

# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/

LANGUAGE_CODE = 'ru'

TIME_ZONE = 'Europe/Moscow'

USE_I18N = True

USE_THOUSAND_SEPARATOR = True
THOUSAND_SEPARATOR = ' '

USE_TZ = True

STATIC_URL = '/static/'

DATABASES = {
    'default':
    dj_database_url.parse(os.getenv('DATABASE', 'sqlite:///db.sqlite3')),
}
]

WSGI_APPLICATION = 'rugbyblog.wsgi.application'

# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases

DATABASES = {
    'default': {
        # 'ENGINE': 'django.db.backends.sqlite3',
        # 'NAME': os.path.join(BASE_DIR,'db.sqlite3'),
    }
}
CLEAR_DB_URL = os.environ.get("CLEARDB_DATABASE_URL", "")

DATABASES['default'] = dj_database_url.parse(CLEAR_DB_URL)

# Password validation
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME':
        'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME':
        'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME':
Exemple #48
0
 def test_dj_db_url_passes_kwargs(self, env, set_env):
     db_url = "postgresql://localhost:5432/mydb"
     set_env({"DATABASE_URL": db_url})
     res = env.dj_db_url("DATABASE_URL", conn_max_age=600)
     assert res == dj_database_url.parse(db_url, conn_max_age=600)
Exemple #49
0
            ],
        },
    },
]

WSGI_APPLICATION = 'floodrelief.wsgi.application'

# Database
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases

# DATABASES = {
#     # read os.environ['DATABASE_URL'] and raises ImproperlyConfigured exception if not found
#     'default': env.db()
# }
DATABASES = {}
DATABASES['default'] = dj_database_url.parse(env('B_DATABASE_URL'), conn_max_age=600)

CACHES = {
    "default": {
        "BACKEND": "django_redis.cache.RedisCache",
        "LOCATION": env('REDIS_URL'),
        "OPTIONS": {
            "CLIENT_CLASS": "django_redis.client.DefaultClient"
        },
        "KEY_PREFIX": "keralarescue"
    }
}
CACHE_TIMEOUT = env('CACHE_TIMEOUT')

# Password validation
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
Exemple #50
0
 def test_dj_db_url(self, env, set_env):
     db_url = "postgresql://localhost:5432/mydb"
     set_env({"DATABASE_URL": db_url})
     res = env.dj_db_url("DATABASE_URL")
     assert res == dj_database_url.parse(db_url)
Exemple #51
0
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'PenPalDjango.wsgi.application'

# Database
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases

DATABASES = {
    'default': dj_database_url.parse(config('DATABASE_URL'), conn_max_age=600)
}

# Password validation
# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME':
        'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME':
        'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
Exemple #52
0
        'GEOGIG_DATASTORE_DIR': GEOGIG_DATASTORE_DIR,
        'DATASTORE': '',
        'PG_GEOGIG': False,
        'TIMEOUT': 10
    }
}

GEOSERVER_BASE_URL = GEOSERVER_URL
GEOGIG_DATASTORE_NAME = 'geogig-repo'

MAP_BASELAYERS[0]['source']['url'] = OGC_SERVER['default']['LOCATION'] + 'wms'

# database settings
SQLITEDB = "sqlite:///%s" % os.path.join(LOCAL_ROOT, 'development.db')
DATABASE_URL = os.getenv('DATABASE_URL', SQLITEDB)
DATABASES['default'] = dj_database_url.parse(DATABASE_URL, conn_max_age=600)
POSTGIS_URL = os.environ.get('POSTGIS_URL', None)
if POSTGIS_URL is not None:
    DATABASES['exchange_imports'] = dj_database_url.parse(POSTGIS_URL,
                                                          conn_max_age=600)
    OGC_SERVER['default']['DATASTORE'] = 'exchange_imports'

    UPLOADER = {
        'BACKEND': 'geonode.importer',
        'OPTIONS': {
            'TIME_ENABLED': True,
            'GEOGIT_ENABLED': True,
        }
    }

WGS84_MAP_CRS = os.environ.get('WGS84_MAP_CRS', None)
Exemple #53
0
WSGI_APPLICATION = 'django_todo.wsgi.application'

# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases

#DATABASES = {
#    'default': {
#        'ENGINE': 'django.db.backends.sqlite3',
#        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
#    }
#}

DATABASES = {
    'default':
    dj_database_url.parse(
        "postgres://*****:*****@ec2-54-247-78-30.eu-west-1.compute.amazonaws.com:5432/d5rq4n8p6ahbs2"
    )
}

# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME':
        'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME':
        'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
            '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 = 'RunForMe.wsgi.application'

# Database
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases

DATABASES = {'default': dj_database_url.parse(os.environ["DATABASE_URL"])}

# 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':
Exemple #55
0
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'image_collection.wsgi.application'

# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases

DATABASES = {
    # 'default': dj_database_url.config()
    'default':
    dj_database_url.parse(
        'postgres://*****:*****@ec2-34-255-134-200.eu-west-1.compute.amazonaws.com:5432/d4g96o373iokm9'
    )
}

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': config('DATABASE_NAME'),
        'USER': config('DATABASE_USER'),
        'PASSWORD': config('DATABASE_PASSWORD'),
        'HOST': config('HOST'),
        'PORT': '5432',
    }
}

# Password validation
Exemple #56
0
    "'self'",
    'https://*.mapbox.com',
)
CSP_SCRIPT_SRC = (
    "'self'",
    'https://*.google-analytics.com',
)
CSP_IMG_SRC = (
    "'self'",
    'https://*.gravatar.com',
    'https://*.mapbox.com',
    'https://*.google-analytics.com',
)

# Database
DATABASE_URL = getenv('DATABASE_URL', 'sqlite:///db.sqlite3')
DATABASES = {'default': dj_database_url.parse(DATABASE_URL)}

# NETWORK API
NETWORK_API_ENDPOINT = getenv('NETWORK_API_ENDPOINT',
                              'https://network.satnogs.org/api/')
DATA_FETCH_DAYS = getenv('DATA_FETCH_DAYS', 10)
SATELLITE_POSITION_ENDPOINT = getenv(
    'SATELLITE_POSITION_ENDPOINT',
    'https://network.satnogs.org/satellite_position/')

# Mapbox API
MAPBOX_GEOCODE_URL = 'https://api.tiles.mapbox.com/v4/geocode/mapbox.places/'
MAPBOX_MAP_ID = getenv('MAPBOX_MAP_ID', '')
MAPBOX_TOKEN = getenv('MAPBOX_TOKEN', '')
import glob
import os
import tempfile

import django

import selenosis.settings
import dj_database_url

current_dir = os.path.abspath(os.path.dirname(__file__))
temp_dir = tempfile.mkdtemp()

DEBUG = NESTED_ADMIN_DEBUG = True
DATABASES = {
    'default':
    dj_database_url.parse(os.environ.get('DATABASE_URL', 'sqlite://:memory:')),
}
SECRET_KEY = 'z-i*xqqn)r0i7leak^#clq6y5j8&tfslp^a4duaywj2$**s*0_'

if django.VERSION > (2, 0):
    MIGRATION_MODULES = {
        'auth': None,
        'contenttypes': None,
        'sessions': None,
    }

try:
    import grappelli  # noqa
except ImportError:
    try:
        import suit  # noqa
Exemple #58
0
                'cart.contexts.get_items_in_cart_count',
                'wishlist.contexts.get_items_in_wishlist_count',
                'home.contexts.get_menu_items',
            ],
        },
    },
]

WSGI_APPLICATION = 'ecommerce.wsgi.application'

# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases

DATABASES = {
    'default':
    dj_database_url.parse(
        os.environ.get("DATABASE_URL", "sqlite:///db.sqlite3"))
}

# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME':
        'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME':
        'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
Exemple #59
0
            ],
        },
    },
]

WSGI_APPLICATION = "debunkbot.wsgi.application"


# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases

DATABASE_URL = os.getenv(
    "DATABASE_URL",
    "postgres://*****:*****@db:5432/debunkbot",
)
DATABASES = {"default": dj_database_url.parse(DATABASE_URL, conn_max_age=600)}

# 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",
Exemple #60
0
]

WEBPACK_LOADER = {
    'DEFAULT': {
        'CACHE': not DEBUG,
        'BUNDLE_DIR_NAME': 'frontend/',  # must end with slash
        'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats.json'),
        'POLL_INTERVAL': 0.1,
        'TIMEOUT': None,
        'IGNORE': [r'.+\.hot-update.js', r'.+\.map']
    }
}

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

if on_heroku:
    # DEBUG = False
    ALLOWED_HOSTS = ['*']
    SECURE_SSL_REDIRECT = True
    # Activate Django-Heroku without database setup.
    config = locals()
    django_heroku.settings(config, databases=False)
    # Manual configuration of database
    conn_max_age = config.get('CONN_MAX_AGE', 600)  # Used in django-heroku
    config['DATABASES'] = {
        'default': dj_database_url.parse(os.environ['DATABASE_URL'], engine='django_tenants.postgresql_backend',
                                         conn_max_age=conn_max_age, ssl_require=True
                                         )
    }