blob: a401d0493b27bdd57fa93bd0c86d0065d9efbe23 [file] [log] [blame]
Dirk Vogtf130c752016-08-23 14:45:01 +02001"""
2Django settings for hiccup_server project.
3
4Generated by 'django-admin startproject' using Django 1.9.7.
5
6For more information on this file, see
7https://docs.djangoproject.com/en/1.9/topics/settings/
8
9For the full list of settings and their values, see
10https://docs.djangoproject.com/en/1.9/ref/settings/
11"""
12
13import os
14
15# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
16BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
17
18
19# Quick-start development settings - unsuitable for production
20# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
21
22# SECURITY WARNING: keep the secret key used in production secret!
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +020023SECRET_KEY = "7u+#ha3hk!x+*)clhs46%n*)w1q+5s4+yoc#1!nm0b%fwwrud@"
Dirk Vogtf130c752016-08-23 14:45:01 +020024
25# SECURITY WARNING: don't run with debug turned on in production!
Dirk Vogtf2a33422016-10-11 17:17:26 +020026DEBUG = True
Dirk Vogtf130c752016-08-23 14:45:01 +020027
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +020028ALLOWED_HOSTS = ["*"]
Dirk Vogtf130c752016-08-23 14:45:01 +020029
30
31# Application definition
32
33INSTALLED_APPS = [
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +020034 "django.contrib.admin",
35 "django.contrib.auth",
36 "django.contrib.contenttypes",
37 "django.contrib.sessions",
38 "django.contrib.sites",
39 "django.contrib.messages",
40 "django.contrib.staticfiles",
41 "rest_framework",
42 "rest_framework.authtoken",
43 "crashreports",
44 "crashreport_stats",
45 "taggit",
46 "crispy_forms",
47 "bootstrap3",
48 "bootstrapform",
49 "django_extensions",
50 "django_filters",
51 "djfrontend",
52 "djfrontend.skeleton",
53 "allauth",
54 "allauth.account",
55 "allauth.socialaccount",
56 "allauth.socialaccount.providers.google",
57 "drf_yasg",
Dirk Vogtf130c752016-08-23 14:45:01 +020058]
59
60MIDDLEWARE_CLASSES = [
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +020061 "django.middleware.security.SecurityMiddleware",
62 "django.contrib.sessions.middleware.SessionMiddleware",
63 "django.middleware.common.CommonMiddleware",
64 "django.middleware.csrf.CsrfViewMiddleware",
65 "django.contrib.auth.middleware.AuthenticationMiddleware",
66 "django.contrib.auth.middleware.SessionAuthenticationMiddleware",
67 "django.contrib.messages.middleware.MessageMiddleware",
68 "django.middleware.clickjacking.XFrameOptionsMiddleware",
Dirk Vogtf130c752016-08-23 14:45:01 +020069]
70
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +020071ROOT_URLCONF = "hiccup.urls"
Dirk Vogtf130c752016-08-23 14:45:01 +020072
Dirk Vogt57a615d2017-05-04 22:29:54 +020073TEMPLATE_LOADERS = (
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +020074 "django.template.loaders.filesystem.Loader",
75 "django.template.loaders.app_directories.Loader",
Dirk Vogt57a615d2017-05-04 22:29:54 +020076)
77
Dirk Vogtf130c752016-08-23 14:45:01 +020078TEMPLATES = [
79 {
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +020080 "BACKEND": "django.template.backends.django.DjangoTemplates",
81 "DIRS": [os.path.join(BASE_DIR, "hiccup", "templates")],
82 "APP_DIRS": True,
83 "OPTIONS": {
84 "context_processors": [
85 "django.template.context_processors.debug",
86 "django.template.context_processors.request",
87 "django.contrib.auth.context_processors.auth",
88 "django.contrib.messages.context_processors.messages",
Dirk Vogt57a615d2017-05-04 22:29:54 +020089 # `allauth` needs this from django
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +020090 "django.template.context_processors.request",
91 ]
Dirk Vogtf130c752016-08-23 14:45:01 +020092 },
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +020093 }
Dirk Vogtf130c752016-08-23 14:45:01 +020094]
95
Dirk Vogt57a615d2017-05-04 22:29:54 +020096AUTHENTICATION_BACKENDS = (
97 # Needed to login by username in Django admin, regardless of `allauth`
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +020098 "django.contrib.auth.backends.ModelBackend",
Dirk Vogt57a615d2017-05-04 22:29:54 +020099 # `allauth` specific authentication methods, such as login by e-mail
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +0200100 "allauth.account.auth_backends.AuthenticationBackend",
Dirk Vogt57a615d2017-05-04 22:29:54 +0200101)
102
Mitja Nikolaus5c3e0572018-07-30 13:36:14 +0200103# WSGI_APPLICATION = 'hiccup_server.wsgi.application'
Dirk Vogtf130c752016-08-23 14:45:01 +0200104
105
106# Database
107# https://docs.djangoproject.com/en/1.9/ref/settings/#databases
108
109DATABASES = {
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +0200110 "default": {
111 "ENGINE": "django.db.backends.sqlite3",
112 "NAME": os.path.join(BASE_DIR, "db.sqlite3"),
Dirk Vogtf130c752016-08-23 14:45:01 +0200113 }
114}
115
116
117# Password validation
118# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
119
120AUTH_PASSWORD_VALIDATORS = [
121 {
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +0200122 "NAME": "django.contrib.auth.password_validation"
123 ".UserAttributeSimilarityValidator"
Dirk Vogtf130c752016-08-23 14:45:01 +0200124 },
125 {
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +0200126 "NAME": "django.contrib.auth.password_validation"
127 ".MinimumLengthValidator"
Dirk Vogtf130c752016-08-23 14:45:01 +0200128 },
129 {
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +0200130 "NAME": "django.contrib.auth.password_validation"
131 ".CommonPasswordValidator"
Dirk Vogtf130c752016-08-23 14:45:01 +0200132 },
133 {
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +0200134 "NAME": "django.contrib.auth.password_validation"
135 ".NumericPasswordValidator"
Dirk Vogtf130c752016-08-23 14:45:01 +0200136 },
137]
138
Dirk Vogtf130c752016-08-23 14:45:01 +0200139# Internationalization
140# https://docs.djangoproject.com/en/1.9/topics/i18n/
141
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +0200142LANGUAGE_CODE = "en-us"
143TIME_ZONE = "Europe/Amsterdam"
Dirk Vogtf130c752016-08-23 14:45:01 +0200144USE_I18N = True
145USE_L10N = True
146USE_TZ = True
147
Dirk Vogt47d80ba2016-08-26 09:31:39 +0200148REST_FRAMEWORK = {
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +0200149 "DEFAULT_AUTHENTICATION_CLASSES": (
150 "rest_framework.authentication.BasicAuthentication",
151 "rest_framework.authentication.SessionAuthentication",
152 "rest_framework.authentication.TokenAuthentication",
Dirk Vogtf2a33422016-10-11 17:17:26 +0200153 ),
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +0200154 "DEFAULT_PERMISSION_CLASSES": (
155 "rest_framework.permissions.IsAuthenticated",
Dirk Vogtd1345212016-09-14 14:31:45 +0200156 ),
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +0200157 "DEFAULT_FILTER_BACKENDS": (
158 "django_filters.rest_framework.DjangoFilterBackend",
159 ),
160 "DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.LimitOffsetPagination",
161 "PAGE_SIZE": 100,
Dirk Vogt57a615d2017-05-04 22:29:54 +0200162}
163
164SITE_ID = 1
165
Mitja Nikolaus5c3e0572018-07-30 13:36:14 +0200166SOCIALACCOUNT_ADAPTER = "hiccup.allauth_adapters.FairphoneAccountAdapter"
167LOGIN_REDIRECT_URL = "/hiccup_stats/"
Dirk Vogt57a615d2017-05-04 22:29:54 +0200168# disable form signups
Mitja Nikolaus5c3e0572018-07-30 13:36:14 +0200169ACCOUNT_ADAPTER = "hiccup.allauth_adapters.FormAccountAdapter"
170ACCOUNT_EMAIL_REQUIRED = True
171ACCOUNT_LOGOUT_REDIRECT_URL = "/accounts/login/"
Dirk Vogt57a615d2017-05-04 22:29:54 +0200172
173SOCIALACCOUNT_PROVIDERS = {
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +0200174 "google": {
175 "SCOPE": ["profile", "email"],
176 "AUTH_PARAMS": {"access_type": "online"},
Dirk Vogt57a615d2017-05-04 22:29:54 +0200177 }
Dirk Vogt47d80ba2016-08-26 09:31:39 +0200178}
179
Dirk Vogtf130c752016-08-23 14:45:01 +0200180# Static files (CSS, JavaScript, Images)
181# https://docs.djangoproject.com/en/1.9/howto/static-files/
182
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +0200183STATIC_URL = "/static/"
Dirk Vogt20539e52016-08-26 11:17:35 +0200184
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +0200185STATIC_ROOT = os.path.join(BASE_DIR, "static")
Dirk Vogtd8b956b2016-11-22 15:03:21 +0100186
Franz-Xaver Geiger69909c92018-02-27 17:02:38 +0100187
188# Logging
189# https://docs.djangoproject.com/en/2.0/topics/logging/#examples
190
191LOGGING = {
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +0200192 "version": 1,
193 "disable_existing_loggers": False,
194 "handlers": {
195 "file": {
196 "level": "DEBUG",
197 "class": "logging.FileHandler",
198 "filename": os.path.join(BASE_DIR, "debug.log"),
199 }
Franz-Xaver Geiger69909c92018-02-27 17:02:38 +0100200 },
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +0200201 "loggers": {
202 "django": {"handlers": ["file"], "level": "DEBUG", "propagate": True}
Franz-Xaver Geiger69909c92018-02-27 17:02:38 +0100203 },
204}
205
Mitja Nikolausd1995062018-07-30 14:10:27 +0200206
207# Automatic documentation generation
208# https://drf-yasg.readthedocs.io/en/stable/index.html
209
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +0200210SWAGGER_SETTINGS = {"DEFAULT_INFO": "hiccup.urls.api_info"}
Mitja Nikolausd1995062018-07-30 14:10:27 +0200211
Dirk Vogtd8b956b2016-11-22 15:03:21 +0100212try:
Mitja Nikolaus5c3e0572018-07-30 13:36:14 +0200213 from local_settings import * # noqa: F403, F401
Dirk Vogtd8b956b2016-11-22 15:03:21 +0100214except ImportError as e:
215 pass