-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinvenio.cfg
450 lines (359 loc) · 15.6 KB
/
invenio.cfg
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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
import os
from datetime import datetime
from dotenv import load_dotenv
from invenio_communities.views import communities
from invenio_rdm_records.records.systemfields.access.embargo import Embargo
from invenio_rdm_records.records.systemfields.access.field.record import (
RecordAccess, RecordAccessField)
from invenio_rdm_records.requests.community_submission import \
CommunitySubmission
from big_map_archive.api import (BMAEmbargo, BMARecordAccess,
BMARecordAccessField)
from big_map_archive.permissions import (
BMARecordPermissionPolicy, BMARequestsPermissionPolicy, BMACommunityPermissionPolicy)
def _(x): # needed to avoid start time failure with lazy strings
return x
# Create environment variables from .env
# Make sure that invenio.env appears in the virtual environment, in the same directory as invenio.cfg
basedir = os.path.abspath(os.path.dirname(__file__))
# load_dotenv(os.path.join(basedir, 'invenio.env'))
load_dotenv(os.path.join(basedir, '.env'))
# Site
# =====
SITE_DEMO=os.getenv('INVENIO_SITE_DEMO')
# Flask
# =====
# See https://flask.palletsprojects.com/en/1.1.x/config/
# Define the value of the cache control header `max-age` returned by the server when serving
# public files. Files will be cached by the browser for the provided number of seconds.
# See flask documentation for more information:
# https://flask.palletsprojects.com/en/2.1.x/config/#SEND_FILE_MAX_AGE_DEFAULT
SEND_FILE_MAX_AGE_DEFAULT = 300
# Flask-SQLAlchemy
# ================
# See https://flask-sqlalchemy.palletsprojects.com/en/2.x/config/
SQLALCHEMY_DATABASE_URI=os.getenv('INVENIO_SQLALCHEMY_DATABASE_URI')
SQL_DB = os.getenv('INVENIO_SQL_DB')
SQL_PASSWORD = os.getenv('INVENIO_SQL_PASSWORD')
SQL_USER = os.getenv('INVENIO_SQL_USER')
# Invenio-App
# ===========
# See https://invenio-app.readthedocs.io/en/latest/configuration.html
APP_DEFAULT_SECURE_HEADERS = {
'content_security_policy': {
'default-src': [
"'self'",
'data:', # for fonts
"'unsafe-inline'", # for inline scripts and styles
"blob:", # for pdf preview
# Add your own policies here (e.g. analytics)
],
},
'content_security_policy_report_only': False,
'content_security_policy_report_uri': None,
'force_file_save': False,
'force_https': True,
'force_https_permanent': False,
'frame_options': 'sameorigin',
'frame_options_allow_from': None,
'session_cookie_http_only': True,
'session_cookie_secure': True,
'strict_transport_security': True,
'strict_transport_security_include_subdomains': True,
'strict_transport_security_max_age': 31556926, # One year in seconds
'strict_transport_security_preload': False,
}
# Flask-Babel
# ===========
# See https://python-babel.github.io/flask-babel/#configuration
# Default locale (language)
BABEL_DEFAULT_LOCALE = 'en'
# Default time zone
BABEL_DEFAULT_TIMEZONE = 'Europe/Zurich'
# Invenio-I18N
# ============
# See https://invenio-i18n.readthedocs.io/en/latest/configuration.html
# Other supported languages (do not include BABEL_DEFAULT_LOCALE in list).
I18N_LANGUAGES = []
# Invenio-Theme
# =============
# See https://invenio-theme.readthedocs.io/en/latest/configuration.html
# Frontpage title
THEME_FRONTPAGE_TITLE = 'Welcome to BIG-MAP Archive'
THEME_FRONTPAGE_TITLE_DEMO = 'Welcome to BIG-MAP Archive demo'
# Header logos
THEME_LOGO_LEFT = 'images/battery2030.png'
THEME_LOGO_RIGHT = 'images/big-map.png'
THEME_LOGO = 'images/battery2030.png'
# Site name
THEME_SITENAME = 'BIG-MAP Archive'
THEME_SITENAME_DEMO = 'BIG-MAP Archive demo'
# Invenio-Files-Rest
# ==================
FILES_REST_STORAGE_FACTORY='invenio_s3.s3fs_storage_factory'
FILES_REST_DEFAULT_QUOTA_SIZE = 1.00001 * 10**11 # ~100 GB
FILES_REST_DEFAULT_MAX_FILE_SIZE = FILES_REST_DEFAULT_QUOTA_SIZE
# Invenio-App-RDM
# ===============
# See https://invenio-app-rdm.readthedocs.io/en/latest/configuration.html
# Instance's theme entrypoint file. Path relative to the ``assets/`` folder.
INSTANCE_THEME_FILE = './less/theme.less'
APP_RDM_DEPOSIT_FORM_QUOTA = {
"maxFiles": 100,
"maxStorage": FILES_REST_DEFAULT_QUOTA_SIZE,
}
# Customize shared record page
APP_RDM_DETAIL_SIDE_BAR_TEMPLATES = [
"invenio_app_rdm/records/details/side_bar/manage_menu.html",
"invenio_app_rdm/records/details/side_bar/versions.html",
"invenio_app_rdm/records/details/side_bar/export.html",
"invenio_app_rdm/records/details/side_bar/licenses.html",
"invenio_app_rdm/records/details/side_bar/disclaimer.html",
]
# Invenio-Records-Resources
# =========================
# See https://github.com/inveniosoftware/invenio-records-resources/blob/master/invenio_records_resources/config.py
SITE_UI_URL = os.getenv('INVENIO_SITE_UI_URL')
SITE_API_URL = os.getenv('INVENIO_SITE_API_URL')
APP_RDM_DEPOSIT_FORM_DEFAULTS = {
"publication_date": lambda: datetime.now().strftime("%Y-%m-%d"),
"rights": [
{
"id": "bm-1.0",
"title": "BATTERY2030+ License",
"description": ("The BATTERY2030+ License allows re-distribution"
" and re-use of work within the communities"
" of the BATTERY2030+ consortium."),
"link": "/licenses/nonexclusive-distrib/1.1",
}
],
"publisher": "BIG-MAP Archive"
}
# See https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/config.py
APP_RDM_DEPOSIT_FORM_AUTOCOMPLETE_NAMES = 'search' # "search_only" or "off"
# Invenio-RDM-Records
# ===================
# See https://inveniordm.docs.cern.ch/customize/dois/
DATACITE_ENABLED = False
DATACITE_USERNAME = ""
DATACITE_PASSWORD = ""
DATACITE_PREFIX = ""
DATACITE_TEST_MODE = True
DATACITE_DATACENTER_SYMBOL = ""
# Disable metadata-only records
RDM_ALLOW_METADATA_ONLY_RECORDS = False
# Remove the Download All button
RDM_ARCHIVE_DOWNLOAD_ENABLED = False
# Options for reference schemes in the upload form
import idutils
RDM_RECORDS_IDENTIFIERS_SCHEMES = {
"arxiv": {"label": _("arXiv"), "validator": idutils.is_arxiv, "datacite": "arXiv"},
"doi": {"label": _("DOI"), "validator": idutils.is_doi, "datacite": "DOI"},
"isbn": {"label": _("ISBN"), "validator": idutils.is_isbn, "datacite": "ISBN"},
"url": {"label": _("URL"), "validator": idutils.is_url, "datacite": "URL"},
}
RDM_SEARCH_DRAFTS = {
'facets': [],
'sort': ['bestmatch', 'updated-desc', 'updated-asc', 'newest', 'oldest',
'version'],
}
# Authentication - Invenio-Accounts and Invenio-OAuthclient
# =========================================================
# See: https://inveniordm.docs.cern.ch/customize/authentication/
# Invenio-Accounts
# ================
# See https://github.com/inveniosoftware/invenio-accounts/blob/master/invenio_accounts/config.py
ACCOUNTS_LOCAL_LOGIN_ENABLED = True # enable local login
SECURITY_REGISTERABLE = False # local login: deny users to register
SECURITY_RECOVERABLE = True # local login: allow users to reset the password
SECURITY_CHANGEABLE = True # local login: allow users to change psw
SECURITY_CONFIRMABLE = True # local login: users can confirm e-mail address
SECURITY_LOGIN_WITHOUT_CONFIRMATION = False # require users to confirm email before being able to login
# Invenio-OAuthclient
# ===================
# See https://github.com/inveniosoftware/invenio-oauthclient/blob/master/invenio_oauthclient/config.py
OAUTHCLIENT_REMOTE_APPS = {} # configure external login providers
from invenio_oauthclient.views.client import auto_redirect_login
ACCOUNTS_LOGIN_VIEW_FUNCTION = auto_redirect_login # autoredirect to external login if enabled
OAUTHCLIENT_AUTO_REDIRECT_TO_EXTERNAL_LOGIN = False # autoredirect to external login
# Invenio-UserProfiles
# ====================
USERPROFILES_READ_ONLY = False # allow users to change profile info (name, email, etc...)
# OAI-PMH
# =======
# See https://github.com/inveniosoftware/invenio-oaiserver/blob/master/invenio_oaiserver/config.py
OAISERVER_ID_PREFIX = "big-map-archive.com"
"""The prefix that will be applied to the generated OAI-PMH ids."""
# Invenio-Search
# ==============
SEARCH_INDEX_PREFIX = "big-map-archive-"
# Flask-Mail
# ==========
# Mail configuration
# =======================
MAIL_ADDRESS = os.getenv('INVENIO_MAIL_ADDRESS')
MAIL_PASSWORD = os.getenv('INVENIO_MAIL_PASSWORD')
MAIL_SERVER = os.getenv('INVENIO_MAIL_SERVER')
MAIL_PORT = os.getenv('INVENIO_MAIL_PORT')
MAIL_USE_TLS = os.getenv('INVENIO_MAIL_USE_TLS')
MAIL_USE_SSL = os.getenv('INVENIO_MAIL_USE_SSL')
MAIL_MAX_EMAILS = os.getenv('INVENIO_MAIL_MAX_EMAILS')
MAIL_ASCII_ATTACHMENTS = os.getenv('INVENIO_MAIL_ASCII_ATTACHMENTS')
MAIL_USERNAME = os.getenv('INVENIO_MAIL_ADDRESS')
MAIL_DEFAULT_SENDER = os.getenv('INVENIO_MAIL_ADDRESS')
SUPPORT_EMAIL = os.getenv('INVENIO_MAIL_ADDRESS')
SECURITY_EMAIL_SENDER = os.getenv('INVENIO_MAIL_ADDRESS')
OAISERVER_ADMIN_EMAILS = [os.getenv('INVENIO_MAIL_ADDRESS')]
APP_RDM_ADMIN_EMAIL_RECIPIENT = os.getenv('INVENIO_MAIL_ADDRESS')
NOREPLY_EMAIL = os.getenv('INVENIO_MAIL_ADDRESS') # this is not working
# Disable email sending by default.
# if set False will send email
# if set True will NOT send email
MAIL_SUPPRESS_SEND = False
# Email subject for account registration emails.
SECURITY_EMAIL_SUBJECT_REGISTER = "Welcome to the BIG MAP Archive"
# Invenio-S3
# ==========
S3_ENDPOINT_URL = os.getenv('INVENIO_S3_ENDPOINT_URL')
S3_ACCESS_KEY_ID = os.getenv('INVENIO_S3_ACCESS_KEY_ID')
S3_SECRET_ACCESS_KEY = os.getenv('INVENIO_S3_SECRET_ACCESS_KEY')
S3_SIGNATURE_VERSION = os.getenv('INVENIO_S3_SIGNATURE_VERSION')
S3_CONTAINER = os.getenv('INVENIO_S3_CONTAINER')
#SWIFT_PROJECT_ID = os.getenv('INVENIO_SWIFT_PROJECT_ID')
#SWIFT_TEMP_URL_KEY = os.getenv('INVENIO_SWIFT_TEMP_URL_KEY')
# Allow S3 endpoint in the CSP rules
APP_DEFAULT_SECURE_HEADERS['content_security_policy']['default-src'].append(S3_ENDPOINT_URL)
# Override default block size value used for multipart uploads to S3 (object store)
S3_DEFAULT_BLOCK_SIZE = 100 * 2**20 # ~100 MB
# Hide notifications view /account/settings/notifications/
NOTIFICATIONS_SETTINGS_VIEW_FUNCTION = None
# Remove pdfjs and csv_papaparsejs from previewer because they do not work
PREVIEWER_PREFERENCE = [
"iiif_simple",
"simple_image",
"json_prismjs",
"xml_prismjs",
"mistune",
"video_videojs",
"audio_videojs",
"ipynb",
"zip",
"txt",
]
# Functions overrides
# ==================
# Set access of new records to restricted
from invenio_app_rdm.records_ui.views import deposits
from big_map_archive.ext import new_record
deposits.new_record = new_record
# Override Embargo, RecordAccess and RecordAccessField
Embargo.__init__ = BMAEmbargo.__init__
RecordAccess.__init__ = BMARecordAccess.__init__
RecordAccessField.__init__ = BMARecordAccessField.__init__
# Do not send an email to the community owner(s) when a record is directly published to that community.
# Raise exception when a user with a secretlink for a record in a community to which the user does not belong
# tries to create a new record in that community using the link upload/new?community=slug
from invenio_rdm_records.services.review.service import ReviewService
from big_map_archive.ext import BMAReviewService
ReviewService.submit = BMAReviewService.submit
# Validate related_identifiers (references)
from big_map_archive.ext import BMARelatedIdentifierSchema
from invenio_rdm_records.services.schemas.metadata import RelatedIdentifierSchema
RelatedIdentifierSchema.validate_related_identifier = BMARelatedIdentifierSchema.validate_related_identifier
# Make upload form's description required
from invenio_rdm_records.services.schemas.metadata import MetadataSchema
from big_map_archive.ext import BMAMetadataSchema
MetadataSchema = BMAMetadataSchema
# Add publication date
from invenio_rdm_records.services.schemas import RDMRecordSchema
from big_map_archive.ext import BMARecordSchema
RDMRecordSchema.default_nested = BMARecordSchema.default_nested
# Allow multipart file upload
from invenio_s3.ext import InvenioS3
from big_map_archive.ext import init_s3fs_info
InvenioS3.init_s3fs_info = init_s3fs_info
# Always files download as attachment
from invenio_records_resources.resources.files.resource import FileResource
from big_map_archive.ext import BMA_RDMFileResource
FileResource.read_content = BMA_RDMFileResource.read_content
# When trying to publish a draft, raise an exception if no community has been selected for the draft
from invenio_drafts_resources.services.records.service import RecordService
from big_map_archive.ext import BMARecordService
RecordService.publish = BMARecordService.publish
# Views overrides
# ===============
from big_map_archive.views import (invenio_communities_create_ui_blueprint,
invenio_app_rdm_communities_ui_create_ui_blueprint,
invenio_app_rdm_requests_ui_create_ui_blueprint)
# Community views overrides
from invenio_app_rdm.communities_ui import views as invenio_app_rdm_communities_ui_views
invenio_app_rdm_communities_ui_views.create_ui_blueprint = invenio_app_rdm_communities_ui_create_ui_blueprint
from invenio_communities import views as invenio_communities_views
invenio_communities_views.create_ui_blueprint = invenio_communities_create_ui_blueprint
# Requests views overrides
from invenio_app_rdm.requests_ui import views as invenio_app_rdm_requests_ui_views
invenio_app_rdm_requests_ui_views.create_ui_blueprint = invenio_app_rdm_requests_ui_create_ui_blueprint
# Record permissions
# ==================
RDM_PERMISSION_POLICY = BMARecordPermissionPolicy
# Requests permissions
# ==================
REQUESTS_PERMISSION_POLICY = BMARequestsPermissionPolicy
# Community permissions
# =================
# Override text of REVIEW_POLICY_FIELDS to allow readers for direct publication
communities.REVIEW_POLICY_FIELDS = [
{
"text": "Review all submissions",
"value": "closed",
"icon": "lock",
"helpText": _("All submissions to the community must be reviewed."),
},
{
"text": "Allow readers, curators, managers, and owners to publish without review",
"value": "open",
"icon": "group",
"helpText": _(
"Submissions to the community by default requires review, but readers, curators, managers, and owners can publish directly without review."
),
},
]
# Allow readers to publish without review
CommunitySubmission.needs_context = {
"community_roles": ["owner", "manager", "curator", "reader"],
}
COMMUNITIES_PERMISSION_POLICY = BMACommunityPermissionPolicy
# Celery tasks
# ==================
from invenio_app_rdm.config import CELERY_BEAT_SCHEDULE
# remove file integrity report task
if 'file-integrity-report' in CELERY_BEAT_SCHEDULE:
CELERY_BEAT_SCHEDULE.pop('file-integrity-report')
# remove update_expired_embargos task
if 'rdm_records' in CELERY_BEAT_SCHEDULE:
CELERY_BEAT_SCHEDULE.pop('rdm_records')
# Statistics (only for testing, override celery beat)
# set the celery beat to store the hits in the
# events-stats, stats and rdmrecords-records indices
# ==========================
# from datetime import timedelta
# CELERY_BEAT_SCHEDULE['stats-process-events'] = {
# 'task': 'invenio_stats.tasks.process_events',
# 'schedule': timedelta(seconds=2),
# 'args': [('record-view', 'file-download')]
# }
# CELERY_BEAT_SCHEDULE['stats-aggregate-events'] = {
# 'task': 'invenio_stats.tasks.aggregate_events',
# 'schedule': timedelta(seconds=3),
# 'args': [('record-view-agg', 'file-download-agg')]
# }
# CELERY_BEAT_SCHEDULE['reindex-stats'] = {
# "task": "invenio_rdm_records.services.tasks.reindex_stats",
# "schedule": timedelta(seconds=4),
# "args": [
# (
# "stats-record-view",
# "stats-file-download",
# )
# ],
# }