blob: f20c3c898be71be081d714ecabd69704adae656f [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!
23SECRET_KEY = '7u+#ha3hk!x+*)clhs46%n*)w1q+5s4+yoc#1!nm0b%fwwrud@'
24
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
Dirk Vogt20539e52016-08-26 11:17:35 +020028ALLOWED_HOSTS = ['*']
Dirk Vogtf130c752016-08-23 14:45:01 +020029
30
31# Application definition
32
33INSTALLED_APPS = [
34 'django.contrib.admin',
35 'django.contrib.auth',
36 'django.contrib.contenttypes',
37 'django.contrib.sessions',
Dirk Vogt57a615d2017-05-04 22:29:54 +020038 'django.contrib.sites',
Dirk Vogtf130c752016-08-23 14:45:01 +020039 'django.contrib.messages',
40 'django.contrib.staticfiles',
Dirk Vogt47d80ba2016-08-26 09:31:39 +020041 'rest_framework',
Dirk Vogtf2a33422016-10-11 17:17:26 +020042 'rest_framework.authtoken',
Dirk Vogtf130c752016-08-23 14:45:01 +020043 'crashreports',
Dirk Vogt62ff7f22017-05-04 16:07:21 +020044 'crashreport_stats',
Dirk Vogtf2a33422016-10-11 17:17:26 +020045 'taggit',
Dirk Vogtd1345212016-09-14 14:31:45 +020046 'crispy_forms',
Dirk Vogtf5a15532016-09-26 15:52:24 +020047 'bootstrap3',
Dirk Vogt57a615d2017-05-04 22:29:54 +020048 'bootstrapform',
Dirk Vogtf2a33422016-10-11 17:17:26 +020049 'django_extensions',
Mitja Nikolaus5c3e0572018-07-30 13:36:14 +020050 'django_filters',
Dirk Vogt62ff7f22017-05-04 16:07:21 +020051 'djfrontend',
Dirk Vogt57a615d2017-05-04 22:29:54 +020052 'djfrontend.skeleton',
53 'allauth',
54 'allauth.account',
55 'allauth.socialaccount',
56 'allauth.socialaccount.providers.google',
Mitja Nikolausd1995062018-07-30 14:10:27 +020057 'drf_yasg'
Dirk Vogtf130c752016-08-23 14:45:01 +020058]
59
60MIDDLEWARE_CLASSES = [
61 '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',
69]
70
71ROOT_URLCONF = 'hiccup.urls'
72
Dirk Vogt57a615d2017-05-04 22:29:54 +020073TEMPLATE_LOADERS = (
74 '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 {
80 'BACKEND': 'django.template.backends.django.DjangoTemplates',
Mitja Nikolaus5c3e0572018-07-30 13:36:14 +020081 'DIRS': [os.path.join(BASE_DIR, 'hiccup', 'templates')],
Dirk Vogtf130c752016-08-23 14:45:01 +020082 '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
90 'django.template.context_processors.request',
Dirk Vogtf130c752016-08-23 14:45:01 +020091 ],
92 },
93 },
94]
95
Dirk Vogt57a615d2017-05-04 22:29:54 +020096AUTHENTICATION_BACKENDS = (
97 # Needed to login by username in Django admin, regardless of `allauth`
98 'django.contrib.auth.backends.ModelBackend',
99
100 # `allauth` specific authentication methods, such as login by e-mail
101 'allauth.account.auth_backends.AuthenticationBackend',
102)
103
Mitja Nikolaus5c3e0572018-07-30 13:36:14 +0200104# WSGI_APPLICATION = 'hiccup_server.wsgi.application'
Dirk Vogtf130c752016-08-23 14:45:01 +0200105
106
107# Database
108# https://docs.djangoproject.com/en/1.9/ref/settings/#databases
109
110DATABASES = {
111 'default': {
112 'ENGINE': 'django.db.backends.sqlite3',
113 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
114 }
115}
116
117
118# Password validation
119# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
120
121AUTH_PASSWORD_VALIDATORS = [
122 {
Mitja Nikolaus5c3e0572018-07-30 13:36:14 +0200123 'NAME': 'django.contrib.auth.password_validation'
124 '.UserAttributeSimilarityValidator',
Dirk Vogtf130c752016-08-23 14:45:01 +0200125 },
126 {
Mitja Nikolaus5c3e0572018-07-30 13:36:14 +0200127 'NAME': 'django.contrib.auth.password_validation'
128 '.MinimumLengthValidator',
Dirk Vogtf130c752016-08-23 14:45:01 +0200129 },
130 {
Mitja Nikolaus5c3e0572018-07-30 13:36:14 +0200131 'NAME': 'django.contrib.auth.password_validation'
132 '.CommonPasswordValidator',
Dirk Vogtf130c752016-08-23 14:45:01 +0200133 },
134 {
Mitja Nikolaus5c3e0572018-07-30 13:36:14 +0200135 'NAME': 'django.contrib.auth.password_validation'
136 '.NumericPasswordValidator',
Dirk Vogtf130c752016-08-23 14:45:01 +0200137 },
138]
139
Dirk Vogtf130c752016-08-23 14:45:01 +0200140# Internationalization
141# https://docs.djangoproject.com/en/1.9/topics/i18n/
142
143LANGUAGE_CODE = 'en-us'
144TIME_ZONE = 'Europe/Amsterdam'
145USE_I18N = True
146USE_L10N = True
147USE_TZ = True
148
Dirk Vogt47d80ba2016-08-26 09:31:39 +0200149REST_FRAMEWORK = {
Dirk Vogtf2a33422016-10-11 17:17:26 +0200150 'DEFAULT_AUTHENTICATION_CLASSES': (
151 'rest_framework.authentication.BasicAuthentication',
152 'rest_framework.authentication.SessionAuthentication',
153 'rest_framework.authentication.TokenAuthentication',
154 ),
Dirk Vogt47d80ba2016-08-26 09:31:39 +0200155 'DEFAULT_PERMISSION_CLASSES': (
156 'rest_framework.permissions.IsAuthenticated',
Dirk Vogtd1345212016-09-14 14:31:45 +0200157 ),
Mitja Nikolaus5c3e0572018-07-30 13:36:14 +0200158 'DEFAULT_FILTER_BACKENDS':
159 ('django_filters.rest_framework.DjangoFilterBackend',),
160 'DEFAULT_PAGINATION_CLASS':
161 'rest_framework.pagination.LimitOffsetPagination',
Dirk Vogt57a615d2017-05-04 22:29:54 +0200162 'PAGE_SIZE': 100
163}
164
165SITE_ID = 1
166
Mitja Nikolaus5c3e0572018-07-30 13:36:14 +0200167SOCIALACCOUNT_ADAPTER = "hiccup.allauth_adapters.FairphoneAccountAdapter"
168LOGIN_REDIRECT_URL = "/hiccup_stats/"
Dirk Vogt57a615d2017-05-04 22:29:54 +0200169# disable form signups
Mitja Nikolaus5c3e0572018-07-30 13:36:14 +0200170ACCOUNT_ADAPTER = "hiccup.allauth_adapters.FormAccountAdapter"
171ACCOUNT_EMAIL_REQUIRED = True
172ACCOUNT_LOGOUT_REDIRECT_URL = "/accounts/login/"
Dirk Vogt57a615d2017-05-04 22:29:54 +0200173
174SOCIALACCOUNT_PROVIDERS = {
175 'google': {
176 'SCOPE': [
177 'profile',
178 'email',
179 ],
180 'AUTH_PARAMS': {
181 'access_type': 'online',
182 }
183 }
Dirk Vogt47d80ba2016-08-26 09:31:39 +0200184}
185
Dirk Vogtf130c752016-08-23 14:45:01 +0200186# Static files (CSS, JavaScript, Images)
187# https://docs.djangoproject.com/en/1.9/howto/static-files/
188
189STATIC_URL = '/static/'
Dirk Vogt20539e52016-08-26 11:17:35 +0200190
Mitja Nikolausc6c2ef92018-07-20 10:02:18 +0200191STATIC_ROOT = os.path.join(BASE_DIR, 'static')
Dirk Vogtd8b956b2016-11-22 15:03:21 +0100192
Franz-Xaver Geiger69909c92018-02-27 17:02:38 +0100193
194# Logging
195# https://docs.djangoproject.com/en/2.0/topics/logging/#examples
196
197LOGGING = {
198 'version': 1,
199 'disable_existing_loggers': False,
200 'handlers': {
201 'file': {
202 'level': 'DEBUG',
203 'class': 'logging.FileHandler',
Mitja Nikolausc6c2ef92018-07-20 10:02:18 +0200204 'filename': os.path.join(BASE_DIR, 'debug.log'),
Franz-Xaver Geiger69909c92018-02-27 17:02:38 +0100205 },
206 },
207 'loggers': {
208 'django': {
209 'handlers': ['file'],
210 'level': 'DEBUG',
211 'propagate': True,
212 },
213 },
214}
215
Mitja Nikolausd1995062018-07-30 14:10:27 +0200216
217# Automatic documentation generation
218# https://drf-yasg.readthedocs.io/en/stable/index.html
219
220SWAGGER_SETTINGS = {
221 'DEFAULT_INFO': 'hiccup.urls.api_info',
222}
223
Dirk Vogtd8b956b2016-11-22 15:03:21 +0100224try:
Mitja Nikolaus5c3e0572018-07-30 13:36:14 +0200225 from local_settings import * # noqa: F403, F401
Dirk Vogtd8b956b2016-11-22 15:03:21 +0100226except ImportError as e:
227 pass