blob: 42b15bbdb27d7772301a256aa47708046bf9dd3d [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',
Dirk Vogtf130c752016-08-23 14:45:01 +020057]
58
59MIDDLEWARE_CLASSES = [
60 'django.middleware.security.SecurityMiddleware',
61 'django.contrib.sessions.middleware.SessionMiddleware',
62 'django.middleware.common.CommonMiddleware',
63 'django.middleware.csrf.CsrfViewMiddleware',
64 'django.contrib.auth.middleware.AuthenticationMiddleware',
65 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
66 'django.contrib.messages.middleware.MessageMiddleware',
67 'django.middleware.clickjacking.XFrameOptionsMiddleware',
68]
69
70ROOT_URLCONF = 'hiccup.urls'
71
Dirk Vogt57a615d2017-05-04 22:29:54 +020072TEMPLATE_LOADERS = (
73 'django.template.loaders.filesystem.Loader',
74 'django.template.loaders.app_directories.Loader',
Dirk Vogt57a615d2017-05-04 22:29:54 +020075)
76
Dirk Vogtf130c752016-08-23 14:45:01 +020077TEMPLATES = [
78 {
79 'BACKEND': 'django.template.backends.django.DjangoTemplates',
Mitja Nikolaus5c3e0572018-07-30 13:36:14 +020080 'DIRS': [os.path.join(BASE_DIR, 'hiccup', 'templates')],
Dirk Vogtf130c752016-08-23 14:45:01 +020081 'APP_DIRS': True,
82 'OPTIONS': {
83 'context_processors': [
84 'django.template.context_processors.debug',
85 'django.template.context_processors.request',
86 'django.contrib.auth.context_processors.auth',
87 'django.contrib.messages.context_processors.messages',
Dirk Vogt57a615d2017-05-04 22:29:54 +020088 # `allauth` needs this from django
89 'django.template.context_processors.request',
Dirk Vogtf130c752016-08-23 14:45:01 +020090 ],
91 },
92 },
93]
94
Dirk Vogt57a615d2017-05-04 22:29:54 +020095AUTHENTICATION_BACKENDS = (
96 # Needed to login by username in Django admin, regardless of `allauth`
97 'django.contrib.auth.backends.ModelBackend',
98
99 # `allauth` specific authentication methods, such as login by e-mail
100 'allauth.account.auth_backends.AuthenticationBackend',
101)
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 = {
110 'default': {
111 'ENGINE': 'django.db.backends.sqlite3',
112 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
113 }
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 Nikolaus5c3e0572018-07-30 13:36:14 +0200122 'NAME': 'django.contrib.auth.password_validation'
123 '.UserAttributeSimilarityValidator',
Dirk Vogtf130c752016-08-23 14:45:01 +0200124 },
125 {
Mitja Nikolaus5c3e0572018-07-30 13:36:14 +0200126 'NAME': 'django.contrib.auth.password_validation'
127 '.MinimumLengthValidator',
Dirk Vogtf130c752016-08-23 14:45:01 +0200128 },
129 {
Mitja Nikolaus5c3e0572018-07-30 13:36:14 +0200130 'NAME': 'django.contrib.auth.password_validation'
131 '.CommonPasswordValidator',
Dirk Vogtf130c752016-08-23 14:45:01 +0200132 },
133 {
Mitja Nikolaus5c3e0572018-07-30 13:36:14 +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
142LANGUAGE_CODE = 'en-us'
143TIME_ZONE = 'Europe/Amsterdam'
144USE_I18N = True
145USE_L10N = True
146USE_TZ = True
147
Dirk Vogt47d80ba2016-08-26 09:31:39 +0200148REST_FRAMEWORK = {
Dirk Vogtf2a33422016-10-11 17:17:26 +0200149 'DEFAULT_AUTHENTICATION_CLASSES': (
150 'rest_framework.authentication.BasicAuthentication',
151 'rest_framework.authentication.SessionAuthentication',
152 'rest_framework.authentication.TokenAuthentication',
153 ),
Dirk Vogt47d80ba2016-08-26 09:31:39 +0200154 'DEFAULT_PERMISSION_CLASSES': (
155 'rest_framework.permissions.IsAuthenticated',
Dirk Vogtd1345212016-09-14 14:31:45 +0200156 ),
Mitja Nikolaus5c3e0572018-07-30 13:36:14 +0200157 'DEFAULT_FILTER_BACKENDS':
158 ('django_filters.rest_framework.DjangoFilterBackend',),
159 'DEFAULT_PAGINATION_CLASS':
160 'rest_framework.pagination.LimitOffsetPagination',
Dirk Vogt57a615d2017-05-04 22:29:54 +0200161 'PAGE_SIZE': 100
162}
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 = {
174 'google': {
175 'SCOPE': [
176 'profile',
177 'email',
178 ],
179 'AUTH_PARAMS': {
180 'access_type': 'online',
181 }
182 }
Dirk Vogt47d80ba2016-08-26 09:31:39 +0200183}
184
Dirk Vogtf130c752016-08-23 14:45:01 +0200185# Static files (CSS, JavaScript, Images)
186# https://docs.djangoproject.com/en/1.9/howto/static-files/
187
188STATIC_URL = '/static/'
Dirk Vogt20539e52016-08-26 11:17:35 +0200189
Mitja Nikolausc6c2ef92018-07-20 10:02:18 +0200190STATIC_ROOT = os.path.join(BASE_DIR, 'static')
Dirk Vogtd8b956b2016-11-22 15:03:21 +0100191
Franz-Xaver Geiger69909c92018-02-27 17:02:38 +0100192
193# Logging
194# https://docs.djangoproject.com/en/2.0/topics/logging/#examples
195
196LOGGING = {
197 'version': 1,
198 'disable_existing_loggers': False,
199 'handlers': {
200 'file': {
201 'level': 'DEBUG',
202 'class': 'logging.FileHandler',
Mitja Nikolausc6c2ef92018-07-20 10:02:18 +0200203 'filename': os.path.join(BASE_DIR, 'debug.log'),
Franz-Xaver Geiger69909c92018-02-27 17:02:38 +0100204 },
205 },
206 'loggers': {
207 'django': {
208 'handlers': ['file'],
209 'level': 'DEBUG',
210 'propagate': True,
211 },
212 },
213}
214
Dirk Vogtd8b956b2016-11-22 15:03:21 +0100215try:
Mitja Nikolaus5c3e0572018-07-30 13:36:14 +0200216 from local_settings import * # noqa: F403, F401
Dirk Vogtd8b956b2016-11-22 15:03:21 +0100217except ImportError as e:
218 pass