blob: 9cdb9913cceb9317a5c82e19e00556ffa594dfb2 [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
73TEMPLATES = [
74 {
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +020075 "BACKEND": "django.template.backends.django.DjangoTemplates",
76 "DIRS": [os.path.join(BASE_DIR, "hiccup", "templates")],
77 "APP_DIRS": True,
78 "OPTIONS": {
79 "context_processors": [
80 "django.template.context_processors.debug",
81 "django.template.context_processors.request",
82 "django.contrib.auth.context_processors.auth",
83 "django.contrib.messages.context_processors.messages",
Dirk Vogt57a615d2017-05-04 22:29:54 +020084 # `allauth` needs this from django
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +020085 "django.template.context_processors.request",
86 ]
Dirk Vogtf130c752016-08-23 14:45:01 +020087 },
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +020088 }
Dirk Vogtf130c752016-08-23 14:45:01 +020089]
90
Dirk Vogt57a615d2017-05-04 22:29:54 +020091AUTHENTICATION_BACKENDS = (
92 # Needed to login by username in Django admin, regardless of `allauth`
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +020093 "django.contrib.auth.backends.ModelBackend",
Dirk Vogt57a615d2017-05-04 22:29:54 +020094 # `allauth` specific authentication methods, such as login by e-mail
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +020095 "allauth.account.auth_backends.AuthenticationBackend",
Dirk Vogt57a615d2017-05-04 22:29:54 +020096)
97
Mitja Nikolaus5c3e0572018-07-30 13:36:14 +020098# WSGI_APPLICATION = 'hiccup_server.wsgi.application'
Dirk Vogtf130c752016-08-23 14:45:01 +020099
100
101# Database
102# https://docs.djangoproject.com/en/1.9/ref/settings/#databases
103
104DATABASES = {
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +0200105 "default": {
106 "ENGINE": "django.db.backends.sqlite3",
107 "NAME": os.path.join(BASE_DIR, "db.sqlite3"),
Dirk Vogtf130c752016-08-23 14:45:01 +0200108 }
109}
110
111
112# Password validation
113# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
114
115AUTH_PASSWORD_VALIDATORS = [
116 {
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +0200117 "NAME": "django.contrib.auth.password_validation"
118 ".UserAttributeSimilarityValidator"
Dirk Vogtf130c752016-08-23 14:45:01 +0200119 },
120 {
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +0200121 "NAME": "django.contrib.auth.password_validation"
122 ".MinimumLengthValidator"
Dirk Vogtf130c752016-08-23 14:45:01 +0200123 },
124 {
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +0200125 "NAME": "django.contrib.auth.password_validation"
126 ".CommonPasswordValidator"
Dirk Vogtf130c752016-08-23 14:45:01 +0200127 },
128 {
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +0200129 "NAME": "django.contrib.auth.password_validation"
130 ".NumericPasswordValidator"
Dirk Vogtf130c752016-08-23 14:45:01 +0200131 },
132]
133
Dirk Vogtf130c752016-08-23 14:45:01 +0200134# Internationalization
135# https://docs.djangoproject.com/en/1.9/topics/i18n/
136
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +0200137LANGUAGE_CODE = "en-us"
138TIME_ZONE = "Europe/Amsterdam"
Dirk Vogtf130c752016-08-23 14:45:01 +0200139USE_I18N = True
140USE_L10N = True
141USE_TZ = True
142
Dirk Vogt47d80ba2016-08-26 09:31:39 +0200143REST_FRAMEWORK = {
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +0200144 "DEFAULT_AUTHENTICATION_CLASSES": (
145 "rest_framework.authentication.BasicAuthentication",
146 "rest_framework.authentication.SessionAuthentication",
147 "rest_framework.authentication.TokenAuthentication",
Dirk Vogtf2a33422016-10-11 17:17:26 +0200148 ),
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +0200149 "DEFAULT_PERMISSION_CLASSES": (
150 "rest_framework.permissions.IsAuthenticated",
Dirk Vogtd1345212016-09-14 14:31:45 +0200151 ),
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +0200152 "DEFAULT_FILTER_BACKENDS": (
153 "django_filters.rest_framework.DjangoFilterBackend",
154 ),
Mitja Nikolaus21075cf2018-08-30 16:53:21 +0200155 "DEFAULT_PAGINATION_CLASS": (
156 "rest_framework.pagination.LimitOffsetPagination"
157 ),
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +0200158 "PAGE_SIZE": 100,
Dirk Vogt57a615d2017-05-04 22:29:54 +0200159}
160
161SITE_ID = 1
162
Mitja Nikolaus5c3e0572018-07-30 13:36:14 +0200163SOCIALACCOUNT_ADAPTER = "hiccup.allauth_adapters.FairphoneAccountAdapter"
164LOGIN_REDIRECT_URL = "/hiccup_stats/"
Dirk Vogt57a615d2017-05-04 22:29:54 +0200165# disable form signups
Mitja Nikolaus5c3e0572018-07-30 13:36:14 +0200166ACCOUNT_ADAPTER = "hiccup.allauth_adapters.FormAccountAdapter"
167ACCOUNT_EMAIL_REQUIRED = True
168ACCOUNT_LOGOUT_REDIRECT_URL = "/accounts/login/"
Dirk Vogt57a615d2017-05-04 22:29:54 +0200169
170SOCIALACCOUNT_PROVIDERS = {
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +0200171 "google": {
172 "SCOPE": ["profile", "email"],
173 "AUTH_PARAMS": {"access_type": "online"},
Dirk Vogt57a615d2017-05-04 22:29:54 +0200174 }
Dirk Vogt47d80ba2016-08-26 09:31:39 +0200175}
176
Dirk Vogtf130c752016-08-23 14:45:01 +0200177# Static files (CSS, JavaScript, Images)
178# https://docs.djangoproject.com/en/1.9/howto/static-files/
179
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +0200180STATIC_URL = "/static/"
Dirk Vogt20539e52016-08-26 11:17:35 +0200181
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +0200182STATIC_ROOT = os.path.join(BASE_DIR, "static")
Dirk Vogtd8b956b2016-11-22 15:03:21 +0100183
Franz-Xaver Geiger69909c92018-02-27 17:02:38 +0100184
185# Logging
186# https://docs.djangoproject.com/en/2.0/topics/logging/#examples
187
188LOGGING = {
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +0200189 "version": 1,
190 "disable_existing_loggers": False,
191 "handlers": {
192 "file": {
193 "level": "DEBUG",
194 "class": "logging.FileHandler",
195 "filename": os.path.join(BASE_DIR, "debug.log"),
196 }
Franz-Xaver Geiger69909c92018-02-27 17:02:38 +0100197 },
Mitja Nikolauscb50f2c2018-08-24 13:54:48 +0200198 "loggers": {
199 "django": {"handlers": ["file"], "level": "DEBUG", "propagate": True}
Franz-Xaver Geiger69909c92018-02-27 17:02:38 +0100200 },
201}
202
Mitja Nikolausd1995062018-07-30 14:10:27 +0200203
204# Automatic documentation generation
205# https://drf-yasg.readthedocs.io/en/stable/index.html
206
Mitja Nikolaus4d759da2018-08-28 15:31:29 +0200207SWAGGER_SETTINGS = {
208 "DEFAULT_INFO": "hiccup.urls.api_info",
209 "SECURITY_DEFINITIONS": {
210 "Device token authentication": {
211 "type": "apiKey",
212 "name": "Authorization",
213 "in": "header",
214 "description": (
215 "Authenticate using a token that was returned on successful "
216 "registration of a new device. The token can only be used to "
217 "authenticate requests that target the device with the "
218 "matching UUID. The token has to be put in the request header: "
219 "'Authorization: Token <AUTH_TOKEN>'"
220 ),
221 },
222 "Google OAuth": {
223 "type": "oauth2",
224 "flow": "implicit",
225 "authorizationUrl": "/accounts/google/login/callback/",
226 "scopes": {},
227 "description": (
228 "Authenticate using a Google account. Only E-mail addresses "
229 "in the @fairphone.com domain are allowed."
230 ),
231 },
232 },
233}
Mitja Nikolausd1995062018-07-30 14:10:27 +0200234
Dirk Vogtd8b956b2016-11-22 15:03:21 +0100235try:
Mitja Nikolausbcaf5022018-08-30 16:40:38 +0200236 from local_settings import * # noqa: F403,F401 pylint: disable=W0401,W0614
Mitja Nikolause7d3c762018-08-30 17:29:27 +0200237except ImportError:
Dirk Vogtd8b956b2016-11-22 15:03:21 +0100238 pass