This repository has been archived by the owner on Jul 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
settings.py
229 lines (188 loc) · 7.24 KB
/
settings.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
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
#!/usr/bin/env python
# -*- coding: utf-8; -*-
#
# This file is part of Superdesk.
#
# Copyright 2013, 2014, 2015 Sourcefabric z.u. and contributors.
#
# For the full copyright and license information, please see the
# AUTHORS and LICENSE files distributed with this source code, or
# at https://www.sourcefabric.org/superdesk/license
import os
import json
from datetime import timedelta
from celery.schedules import crontab
try:
from urllib.parse import urlparse
except ImportError:
from urlparse import urlparse
def env(variable, fallback_value=None):
env_value = os.environ.get(variable, '')
if len(env_value) == 0:
return fallback_value
else:
if env_value == "__EMPTY__":
return ''
else:
return env_value
XML = False
IF_MATCH = True
BANDWIDTH_SAVER = False
DATE_FORMAT = '%Y-%m-%dT%H:%M:%S+0000'
PAGINATION_LIMIT = 200
APPLICATION_NAME = env('APP_NAME', 'Superdesk')
server_url = urlparse(env('SUPERDESK_URL', 'http://localhost:5000/api'))
CLIENT_URL = env('SUPERDESK_CLIENT_URL', 'http://localhost:9000')
URL_PROTOCOL = server_url.scheme or None
SERVER_NAME = server_url.netloc or None
URL_PREFIX = server_url.path.lstrip('/') or ''
VALIDATION_ERROR_STATUS = 400
JSON_SORT_KEYS = True
CACHE_CONTROL = 'max-age=0, no-cache'
X_DOMAINS = '*'
X_MAX_AGE = 24 * 3600
X_HEADERS = ['Content-Type', 'Authorization', 'If-Match']
MONGO_DBNAME = env('MONGO_DBNAME', 'superdesk')
if env('MONGOLAB_URI'):
MONGO_URI = env('MONGOLAB_URI')
elif env('MONGODB_PORT'):
MONGO_URI = '{0}/{1}'.format(env('MONGODB_PORT').replace('tcp:', 'mongodb:'), MONGO_DBNAME)
LEGAL_ARCHIVE_DBNAME = env('LEGAL_ARCHIVE_DBNAME', 'legal_archive')
if env('LEGAL_ARCHIVE_URI'):
LEGAL_ARCHIVE_URI = env('LEGAL_ARCHIVE_URI')
elif env('LEGAL_ARCHIVEDB_PORT'):
LEGAL_ARCHIVE_URI = '{0}/{1}'.format(env('LEGAL_ARCHIVEDB_PORT').replace('tcp:', 'mongodb:'),
LEGAL_ARCHIVE_DBNAME)
ELASTICSEARCH_URL = env('ELASTICSEARCH_URL', 'http://localhost:9200')
ELASTICSEARCH_INDEX = env('ELASTICSEARCH_INDEX', 'superdesk')
if env('ELASTIC_PORT'):
ELASTICSEARCH_URL = env('ELASTIC_PORT').replace('tcp:', 'http:')
REDIS_URL = env('REDIS_URL', 'redis://localhost:6379')
if env('REDIS_PORT'):
REDIS_URL = env('REDIS_PORT').replace('tcp:', 'redis:')
BROKER_URL = env('CELERY_BROKER_URL', REDIS_URL)
CELERY_ALWAYS_EAGER = (env('CELERY_ALWAYS_EAGER', False) == 'True')
CELERY_TASK_SERIALIZER = 'json'
CELERY_ACCEPT_CONTENT = ['pickle', 'json'] # it's using pickle when in eager mode
CELERY_IGNORE_RESULT = True
CELERY_DISABLE_RATE_LIMITS = True
CELERYBEAT_SCHEDULE_FILENAME = env('CELERYBEAT_SCHEDULE_FILENAME', './celerybeatschedule.db')
CELERYBEAT_SCHEDULE = {
'ingest:update': {
'task': 'superdesk.io.update_ingest',
# there is internal schedule for updates per provider,
# so this is mininal interval when an update can occur
'schedule': timedelta(seconds=30),
'options': {'expires': 59}
},
'ingest:gc': {
'task': 'superdesk.io.gc_ingest',
'schedule': crontab(minute=10),
},
'session:gc': {
'task': 'apps.auth.session_purge',
'schedule': crontab(minute=20)
},
'spike:gc': {
'task': 'apps.archive.content_purge',
'schedule': crontab(minute=30)
}
}
SENTRY_DSN = env('SENTRY_DSN')
SENTRY_INCLUDE_PATHS = ['superdesk']
INSTALLED_APPS = [
'apps.auth',
'apps.users',
'superdesk.upload',
'superdesk.notification',
'superdesk.activity',
'superdesk.comments',
'superdesk.storage.amazon.import_from_amazon',
'superdesk.io',
'superdesk.io.subjectcodes',
'superdesk.io.reuters',
'superdesk.io.aap',
'superdesk.io.afp',
'superdesk.io.ftp',
'apps.archive',
'apps.stages',
'apps.desks',
'apps.planning',
'apps.coverages',
'apps.tasks',
'apps.preferences',
'apps.spikes',
'apps.groups',
'apps.prepopulate',
'apps.vocabularies',
'apps.legal_archive',
'apps.search',
'apps.packages',
'apps.privilege',
'apps.rule_sets',
'apps.highlights'
]
RESOURCE_METHODS = ['GET', 'POST']
ITEM_METHODS = ['GET', 'PATCH', 'PUT', 'DELETE']
EXTENDED_MEDIA_INFO = ['content_type', 'name', 'length']
RETURN_MEDIA_AS_BASE64_STRING = False
AMAZON_CONTAINER_NAME = env('AMAZON_CONTAINER_NAME', '')
AMAZON_ACCESS_KEY_ID = env('AMAZON_ACCESS_KEY_ID', '')
AMAZON_SECRET_ACCESS_KEY = env('AMAZON_SECRET_ACCESS_KEY', '')
AMAZON_REGION = env('AMAZON_REGION', '')
RENDITIONS = {
'picture': {
'thumbnail': {'width': 220, 'height': 120},
'viewImage': {'width': 640, 'height': 640},
'baseImage': {'width': 1400, 'height': 1400},
},
'avatar': {
'thumbnail': {'width': 60, 'height': 60},
'viewImage': {'width': 200, 'height': 200},
}
}
SERVER_DOMAIN = 'localhost'
BCRYPT_GENSALT_WORK_FACTOR = 12
RESET_PASSWORD_TOKEN_TIME_TO_LIVE = int(env('RESET_PASS_TTL', 1)) # The number of days a token is valid
# The number of days an activation token is valid
ACTIVATE_ACCOUNT_TOKEN_TIME_TO_LIVE = int(env('ACTIVATE_TTL', 7))
# email server
MAIL_SERVER = env('MAIL_SERVER', 'smtp.googlemail.com')
MAIL_PORT = int(env('MAIL_PORT', 465))
MAIL_USE_TLS = json.loads(env('MAIL_USE_TLS', 'False').lower())
MAIL_USE_SSL = json.loads(env('MAIL_USE_SSL', 'False').lower())
MAIL_USERNAME = env('MAIL_USERNAME', '[email protected]')
MAIL_PASSWORD = env('MAIL_PASSWORD', '')
ADMINS = [MAIL_USERNAME]
# LDAP settings
LDAP_SERVER = env('LDAP_SERVER', '') # Ex: ldap://sourcefabric.org
LDAP_SERVER_PORT = env('LDAP_SERVER_PORT', 389)
# Fully Qualified Domain Name. Ex: sourcefabric.org
LDAP_FQDN = env('LDAP_FQDN', '')
# LDAP_BASE_FILTER limit the base filter to the security group. Ex: OU=Superdesk Users,dc=sourcefabric,dc=org
LDAP_BASE_FILTER = env('LDAP_BASE_FILTER', '')
# change the user depending on the LDAP directory structure
LDAP_USER_FILTER = env('LDAP_USER_FILTER', "(&(objectCategory=user)(objectClass=user)(sAMAccountName={}))")
# LDAP User Attributes to fetch. Keys would be LDAP Attribute Name and Value would be Supderdesk Model Attribute Name
LDAP_USER_ATTRIBUTES = {'givenName': 'first_name', 'sn': 'last_name', 'displayName': 'display_name',
'mail': 'email', 'ipPhone': 'phone'}
if LDAP_SERVER:
INSTALLED_APPS.append('apps.auth.ldap')
else:
INSTALLED_APPS.append('apps.auth.db')
SUPERDESK_TESTING = (env('SUPERDESK_TESTING', 'false').lower() == 'true')
# The number of minutes since the last update of the Mongo auth object after which it will be deleted
SESSION_EXPIRY_MINUTES = 240
# The number of minutes before spiked items purged
SPIKE_EXPIRY_MINUTES = 300
# The number of minutes before content items purged
# akin.tolga 06/01/2014: using a large value (30 days) for the time being
CONTENT_EXPIRY_MINUTES = 43200
# This setting can be used to apply a limit on the elastic search queries, it is a limit per shard.
# A value of -1 indicates that no limit will be applied.
# If for example the elastic has 5 shards and you wish to limit the number of search results to 1000 then set the value
# to 200 (1000/5).
MAX_SEARCH_DEPTH = -1
# Defines the maximum value of Ingest Sequence Number after which the value will start from 1
MAX_VALUE_OF_INGEST_SEQUENCE = 9999
DAYS_TO_KEEP = int(env('INGEST_ARTICLES_TTL', '2'))