-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathcommon.py
More file actions
272 lines (217 loc) · 9.17 KB
/
Copy pathcommon.py
File metadata and controls
272 lines (217 loc) · 9.17 KB
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
import os
import datetime
from django.contrib.messages import constants as messages
from django.core.validators import FileExtensionValidator
"""
Iguana (c) by Marc Ammon, Moritz Fickenscher, Lukas Fridolin, Michael Gunselmann, Katrin Raab, Christian Strate
Iguana is licensed under BSD-2-Clause License.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""
"""
The common settings file.
"""
# The base path of the project (where the manage.py lies)
BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", ".."))
# The root path of the project (one directory up)
ROOT_DIR = os.path.dirname(BASE_DIR)
# In this path files created by Iguana are stored
FILES_DIR = os.path.join(ROOT_DIR, "files")
# All emails send by Iguana are saved in this directory if no email server is provided
EMAIL_DIR = os.path.join(FILES_DIR, "emails")
# Disable debugging by default
DEBUG = False
# Disable admin interface by default
ADMIN_ENABLED = False
# Application definition
INSTALLED_APPS = [
'bootstrap3',
'bootstrap_datepicker_plus',
'rest_framework',
'django_filters',
'pagedown.apps.PagedownConfig',
'cuser',
'dal',
'dal_select2',
'event.apps.EventConfig',
'gitintegration.apps.GitintegrationConfig',
'api.apps.ApiConfig',
'archive.apps.ArchiveConfig',
'backlog.apps.BacklogConfig',
'integration.apps.IntegrationConfig',
'invite_users.apps.InviteUsersConfig',
'issue.apps.IssueConfig',
'kanbancol.apps.KanbanColConfig',
'landing_page.apps.LandingPageConfig',
'project.apps.ProjectConfig',
'search.apps.SearchConfig',
'sprint.apps.SprintConfig',
'tag.apps.TagConfig',
'timelog.apps.TimelogConfig',
'olea.apps.OleaConfig',
'user_management.apps.UserManagementConfig',
'user_profile.apps.UserProfileConfig',
'captcha', # django-simple-captcha
'common.apps.CommonConfig',
# NOTE: to get the activity stream plugim working under django 1.10 the following fix has to be applied:
# NOTE: https://github.com/justquick/django-activity-stream/pull/311
# NOTE: it has been fixed in master, but the latest release of the plugin is from summer last year
'actstream',
'discussion.apps.DiscussionConfig',
# NOTE: it's important that django-pages are below our own ones, because otherwise django routes to their
# NOTE: own auth-pages, and not through magic not to ours
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'sendfile'
]
MIDDLEWARE = [
'lib.csrf_update.csrfUpdateMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.security.SecurityMiddleware',
'cuser.middleware.CuserMiddleware',
'lib.timezone_middleware.TimezoneMiddleware',
]
# the root file for the URL routing
ROOT_URLCONF = 'common.urls'
# where to find the templates
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, "common", "templates")],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'common.wsgi.application'
# Password validation
AUTH_PASSWORD_VALIDATORS = [
{
# minimum of eight characters (default)
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
'OPTIONS': {
'user_attributes': ['username', 'first_name', 'last_name', 'email'],
'max_similarity': 0.5,
}
},
{
# NOTE: you might wanna adjust the password list once again but please zip it after you did that
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
'OPTIONS': {
'password_list_path': os.path.join(ROOT_DIR, "common_passwords", "bigger_common_password_file.txt.gz"),
}
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# used validator for image Uploads in CustomImageField
# NOTE: DO NOT add svg without a proper sanitize implementation for it in image_strip
# svg is the only image type that is not recreated but the original file is stored
ALLOWED_IMG_EXTENSIONS = ['bmp', 'jpe', 'jpeg', 'jpg', 'gif', 'png']
ALLOWED_IMG_EXTENSION_VALIDATOR = [FileExtensionValidator(ALLOWED_IMG_EXTENSIONS)]
# The following ones have been removed because even though they can be stored successfully
# they won't get delivered successfully in all browser: pbm, pgm, ppm, tif, tiff
# maximum file size for an image to be uploaded: 7 MiB
MAX_IMG_SIZE_BASE = 7
MAXIMUM_IMG_SIZE = MAX_IMG_SIZE_BASE*1024**2
# maximum file size for a file to be uploaded: 15 MiB
MAX_FILE_SIZE_BASE = 15
MAXIMUM_FILE_SIZE = MAX_FILE_SIZE_BASE*1024**2
AUTHENTICATION_BACKENDS = ['user_management.auth_backend.AuthBackend', ]
# Static files (CSS, JavaScript, Images)
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(ROOT_DIR, "static_files")
# the directory were all media is stored
MEDIA_ROOT = os.path.join(FILES_DIR, "media")
MEDIA_URL = '/media/'
# the directory where checked out repositories are stored
REPOSITORY_ROOT = os.path.join(MEDIA_ROOT, 'repos')
# Path to login page
LOGIN_URL = '/login/'
# Use the custom model-user-class instead of the default one
AUTH_USER_MODEL = 'user_management.CustomUser'
# change tag of error message to work with bootstrap 3
MESSAGE_TAGS = {
messages.ERROR: 'danger'
}
# use local bootstrap and jQuery files
BOOTSTRAP3 = {
"css_url": os.path.join(STATIC_URL, "css", "bootstrap_custom", "custom_bootstrap.css"),
"javascript_url": os.path.join(STATIC_URL, "js", "bootstrap", "bootstrap.min.js"),
"jquery_url": os.path.join(STATIC_URL, "js", "jquery", "jquery.min.js"),
}
# name of the platform
PLATFORM = "iguana-project"
# needed by activity stream plugin
SITE_ID = 1
# settings for the activity stream plugin
ACTSTREAM_SETTINGS = {
'FETCH_RELATIONS': True,
'USE_PREFETCH': True,
'USE_JSONFIELD': False,
}
# for further captcha-settings see https://github.com/mbi/django-simple-captcha/blob/master/docs/advanced.rst
CAPTCHA_LENGTH = 6
REST_FRAMEWORK = {
# added in global_conf so browsable API is activated in development
# 'DEFAULT_RENDERER_CLASSES': (
# 'rest_framework.renderers.JSONRenderer',
# )
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
'PAGE_SIZE': 20,
'DEFAULT_FILTER_BACKENDS': (
'django_filters.rest_framework.DjangoFilterBackend',
),
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework_simplejwt.authentication.JWTAuthentication',
'rest_framework.authentication.BasicAuthentication',
),
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticated',
)
}
SIMPLE_JWT = {
'ACCESS_TOKEN_LIFETIME': datetime.timedelta(minutes=5),
'REFRESH_TOKEN_LIFETIME': datetime.timedelta(days=28*6),
'AUTH_TOKEN_CLASSES': ('api.custom_jwt_auth.AccessTokenWithUserValidation',),
}
# global celery settings
CELERY_TRACK_STARTED = True
CELERY_ENABLE_UTC = True
CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'