<reponame>ge0rg/django-tree-queries
import os
import sys

import django


DATABASES = {
    "default": {
        "ENGINE": (
            "django.db.backends.postgresql"
            if django.VERSION > (2,)
            else "django.db.backends.postgresql_psycopg2"
        ),
        "NAME": "tree_queries",
    }
}

if os.environ.get("DB") in {"mysql", "mariadb"}:
    DATABASES = {
        "default": {
            "ENGINE": "django.db.backends.mysql",
            "NAME": "tree_queries",
            "OPTIONS": {
                "init_command": "SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));"  # noqa
            },
        }
    }
elif os.environ.get("DB") == "sqlite3":
    try:
        import pysqlite3.dbapi2
    except ImportError:
        import sqlite3

        sys.stdout.write("Running with pysqlite3 %s\n" % (sqlite3.sqlite_version_info,))
    else:
        sys.modules["sqlite3"] = pysqlite3
        sys.modules["sqlite3.dbapi2"] = pysqlite3.dbapi2

        sys.stdout.write(
            "Running with pysqlite3 %s\n" % (pysqlite3.sqlite_version_info,)
        )

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

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

MEDIA_ROOT = "/media/"
STATIC_URL = "/static/"
BASEDIR = os.path.dirname(__file__)
MEDIA_ROOT = os.path.join(BASEDIR, "media/")
STATIC_ROOT = os.path.join(BASEDIR, "static/")
SECRET_KEY = "supersikret"
LOGIN_REDIRECT_URL = "/?login=1"

ROOT_URLCONF = "testapp.urls"
LANGUAGES = (("en", "English"), ("de", "German"))

TEMPLATES = [
    {
        "BACKEND": "django.template.backends.django.DjangoTemplates",
        "DIRS": [],
        "APP_DIRS": True,
        "OPTIONS": {
            "context_processors": [
                "django.template.context_processors.debug",
                "django.template.context_processors.request",
                "django.contrib.auth.context_processors.auth",
                "django.contrib.messages.context_processors.messages",
            ]
        },
    }
]

MIDDLEWARE = [
    "django.middleware.security.SecurityMiddleware",
    "django.contrib.sessions.middleware.SessionMiddleware",
    "django.middleware.common.CommonMiddleware",
    "django.middleware.locale.LocaleMiddleware",
    "django.middleware.csrf.CsrfViewMiddleware",
    "django.contrib.auth.middleware.AuthenticationMiddleware",
    "django.contrib.messages.middleware.MessageMiddleware",
    "django.middleware.clickjacking.XFrameOptionsMiddleware",
]

import os
import sys

import django


DATABASES = {
    "default": {
        "ENGINE": (
            "django.db.backends.postgresql"
            if django.VERSION > (2,)
            else "django.db.backends.postgresql_psycopg2"
        ),
        "NAME": "tree_queries",
    }
}

if os.environ.get("DB") in {"mysql", "mariadb"}:
    DATABASES = {
        "default": {
            "ENGINE": "django.db.backends.mysql",
            "NAME": "tree_queries",
            "OPTIONS": {
                "init_command": "SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));"  # noqa
            },
        }
    }
elif os.environ.get("DB") == "sqlite3":
    try:
        import pysqlite3.dbapi2
    except ImportError:
        import sqlite3

        sys.stdout.write("Running with pysqlite3 %s\n" % (sqlite3.sqlite_version_info,))
    else:
        sys.modules["sqlite3"] = pysqlite3
        sys.modules["sqlite3.dbapi2"] = pysqlite3.dbapi2

        sys.stdout.write(
            "Running with pysqlite3 %s\n" % (pysqlite3.sqlite_version_info,)
        )

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

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

MEDIA_ROOT = "/media/"
STATIC_URL = "/static/"
BASEDIR = os.path.dirname(__file__)
MEDIA_ROOT = os.path.join(BASEDIR, "media/")
STATIC_ROOT = os.path.join(BASEDIR, "static/")
SECRET_KEY = "supersikret"
LOGIN_REDIRECT_URL = "/?login=1"

ROOT_URLCONF = "testapp.urls"
LANGUAGES = (("en", "English"), ("de", "German"))

TEMPLATES = [
    {
        "BACKEND": "django.template.backends.django.DjangoTemplates",
        "DIRS": [],
        "APP_DIRS": True,
        "OPTIONS": {
            "context_processors": [
                "django.template.context_processors.debug",
                "django.template.context_processors.request",
                "django.contrib.auth.context_processors.auth",
                "django.contrib.messages.context_processors.messages",
            ]
        },
    }
]

MIDDLEWARE = [
    "django.middleware.security.SecurityMiddleware",
    "django.contrib.sessions.middleware.SessionMiddleware",
    "django.middleware.common.CommonMiddleware",
    "django.middleware.locale.LocaleMiddleware",
    "django.middleware.csrf.CsrfViewMiddleware",
    "django.contrib.auth.middleware.AuthenticationMiddleware",
    "django.contrib.messages.middleware.MessageMiddleware",
    "django.middleware.clickjacking.XFrameOptionsMiddleware",
]
# noqa # "django.contrib.auth", # "django.contrib.admin", # "django.contrib.contenttypes", # "django.contrib.sessions", # "django.contrib.staticfiles", # "django.contrib.messages", # "tree_queries",