forked from juntagrico/juntagrico
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestsettings.py
executable file
·134 lines (103 loc) · 3.68 KB
/
testsettings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# test_settings.py
import os
DEBUG = True
SECRET_KEY = 'fake-key'
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
IMPERSONATE = {
'REDIRECT_URL': '/my/profile',
}
INSTALLED_APPS = [
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'impersonate',
'juntagrico',
'crispy_forms',
# enable only to test addon stuff
# 'juntagrico_test_addon',
]
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'yourdatabasename.db',
}
}
ROOT_URLCONF = 'testurls'
AUTHENTICATION_BACKENDS = (
'juntagrico.util.auth.AuthenticateWithEmail',
'django.contrib.auth.backends.ModelBackend'
)
MIDDLEWARE = [
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'impersonate.middleware.ImpersonateMiddleware',
]
EMAIL_HOST = os.environ.get('JUNTAGRICO_EMAIL_HOST')
EMAIL_HOST_USER = os.environ.get('JUNTAGRICO_EMAIL_USER')
EMAIL_HOST_PASSWORD = os.environ.get('JUNTAGRICO_EMAIL_PASSWORD')
EMAIL_PORT = os.environ.get('JUNTAGRICO_EMAIL_PORT', 2525)
EMAIL_USE_TLS = os.environ.get('JUNTAGRICO_EMAIL_TLS', False)
WHITELIST_EMAILS = []
def whitelist_email_from_env(var_env_name):
email = os.environ.get(var_env_name)
if email:
WHITELIST_EMAILS.append(email)
if DEBUG is True:
for key in os.environ.keys():
if key.startswith("JUNTAGRICO_EMAIL_WHITELISTED"):
whitelist_email_from_env(key)
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'
LANGUAGE_CODE = 'de-CH'
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
USE_L10N = True
DATE_INPUT_FORMATS = ['%d.%m.%Y', ]
# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True
class InvalidTemplateVariable(str):
def __mod__(self, other):
raise NameError(f"In template, undefined variable or unknown value for: '{other}'")
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'OPTIONS': {
'context_processors': [
# Insert your TEMPLATE_CONTEXT_PROCESSORS here or use this
# list if you haven't customized them:
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.request',
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.contrib.messages.context_processors.messages',
],
'loaders': [
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader'
],
'string_if_invalid': InvalidTemplateVariable("%s"),
'debug': True
},
},
]
LOGIN_REDIRECT_URL = "/my/home"
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
LOCALE_PATHS = (
os.path.join(BASE_DIR, 'juntagrico/locale'),
)
CRISPY_TEMPLATE_PACK = 'bootstrap4'
CRISPY_FAIL_SILENTLY = not DEBUG