forked from juntagrico/juntagrico
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testsettings.py
executable file
·188 lines (152 loc) · 5.3 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# test_settings.py
import os
from juntagrico.util.settings import tinymce_lang
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',
'fontawesomefree',
'impersonate',
'juntagrico',
'crispy_forms',
'adminsortable2',
'djrichtextfield',
'polymorphic',
'import_export',
# enable only to test addon stuff
# 'juntagrico_test_addon',
]
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'yourdatabasename.db',
}
}
# settings for CI
if os.environ.get('GITHUB_WORKFLOW'):
if os.environ.get('GITHUB_MYSQL'):
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'mysql',
'USER': 'root',
'PASSWORD': 'mysql',
'HOST': '127.0.0.1',
'PORT': '3306',
}
}
else:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'testdb',
'USER': 'postgres',
'PASSWORD': 'postgres',
'HOST': '127.0.0.1',
'PORT': '5432',
}
}
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',
'django.contrib.sites.middleware.CurrentSiteMiddleware',
'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
DJRICHTEXTFIELD_CONFIG = {
'js': ['juntagrico/external/tinymce/tinymce.min.js'],
'init_template': 'djrichtextfield/init/tinymce.js',
'settings': {
'menubar': False,
'plugins': 'link lists',
'toolbar': 'undo redo | bold italic | alignleft aligncenter alignright alignjustify | outdent indent | bullist numlist | link',
'language': tinymce_lang(LANGUAGE_CODE)
}
}
CONTACTS = {
'general': "[email protected]",
'for_members': "[email protected]",
'for_subscriptions': "[email protected]",
'for_shares': "[email protected]",
'technical': "[email protected]",
}
IMPORT_EXPORT_EXPORT_PERMISSION_CODE = 'view'