-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinvenio.cfg
1543 lines (1381 loc) · 44 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
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
InvenioRDM settings for Rogue Scholar.
This file was automatically generated by 'invenio-cli init'.
For the full list of settings and their values, see
https://inveniordm.docs.cern.ch/reference/configuration/.
"""
from copy import deepcopy
from typing import Any
from datetime import datetime, timedelta
import re
from flask import request, url_for
import idutils
from marshmallow import validate, fields
from marshmallow_utils.fields import SanitizedUnicode
from invenio_rdm_records.services.pids import providers
from invenio_rdm_records.services import facets
from invenio_rdm_records.contrib.journal import (
JOURNAL_CUSTOM_FIELDS,
JOURNAL_CUSTOM_FIELDS_UI,
JOURNAL_NAMESPACE,
)
from invenio_records_resources.services.custom_fields import (
TextCF,
KeywordCF,
BaseListCF,
)
from invenio_records_resources.services.records.queryparser import (
FieldValueMapper,
QueryParser,
SearchFieldTransformer,
)
from invenio_search.engine import dsl
from invenio_records_resources.services.records.facets.facets import (
LabelledFacetMixin,
TermsFacet,
CFTermsFacet,
)
from invenio_communities.communities.records.models import CommunityMetadata
from invenio_db import db
from luqum.tree import Phrase
from invenio_access import action_factory
from invenio_records.dictutils import dict_lookup
from invenio_records_permissions.generators import (
ConditionalGenerator,
Generator,
)
from invenio_communities.permissions import CommunityPermissionPolicy
from invenio_rdm_records.services.generators import (
AccessGrant,
IfRestricted,
RecordOwners,
)
from invenio_rdm_records.services.permissions import RDMRecordPermissionPolicy
from invenio_records_permissions.generators import (
SystemProcess,
)
def _(x): # needed to avoid start time failure with lazy strings
return x
RATELIMIT_ENABLED = True
RATELIMIT_AUTHENTICATED_USER = "50000 per hour;900 per minute"
RATELIMIT_GUEST_USER = "30000 per hour;500 per minute"
# 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
# Set via env variable
# SECRET_KEY=
# Since HAProxy and Nginx route all requests no matter the host header
# provided, the allowed hosts variable is set to localhost. In production it
# should be set to the correct host and it is strongly recommended to only
# route correct hosts to the application.
APP_ALLOWED_HOSTS = ["localhost", "127.0.0.1"]
# Flask-SQLAlchemy
# ================
# See https://flask-sqlalchemy.palletsprojects.com/en/2.x/config/
# Set via env variable
# SQLALCHEMY_DATABASE_URI=
# 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
"fly.storage.tigris.dev", # for S3 object storage
# Add your own policies here (e.g. analytics)
],
"img-src": [
"*",
],
},
"force_https": True,
"force_https_permanent": False,
"force_file_save": False,
"frame_options": "sameorigin",
"frame_options_allow_from": None,
"strict_transport_security": True,
"strict_transport_security_preload": False,
"strict_transport_security_max_age": 31556926, # One year in seconds
"strict_transport_security_include_subdomains": True,
"content_security_policy_report_uri": None,
"content_security_policy_report_only": False,
"session_cookie_secure": True,
"session_cookie_http_only": True,
}
# Flask-Babel
# ===========
# See https://python-babel.github.io/flask-babel/#configuration
# Default locale (language)
BABEL_DEFAULT_LOCALE = "en"
# Default time zone
BABEL_DEFAULT_TIMEZONE = "UTC"
# 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 = [
("de", _("German")),
("es", _("Spanish")),
("fr", _("French")),
("it", _("Italian")),
("pt", _("Portuguese")),
("sl", _("Slovenian")),
("tr", _("Turkish")),
]
# Invenio-Mail
# ===========
# See https://invenio-mail.readthedocs.io/en/latest/configuration.html
# Set this to False when enable email sending.
MAIL_SUPPRESS_SEND = True
# Invenio-Theme
# =============
# See https://invenio-theme.readthedocs.io/en/latest/configuration.html
# The name of the site to be used on the header and as a title.
THEME_SITENAME = "Rogue Scholar"
# Frontpage title
THEME_FRONTPAGE_TITLE = "Rogue Scholar"
# Frontpage subtitle
THEME_FRONTPAGE_SUBTITLE = (
"A starter project for the turn-key research data management repository."
)
# Header logo
THEME_LOGO = "images/starter.svg"
# Invenio-logging Sentry
# ----------------------
LOGGING_SENTRY_INIT_KWARGS = {
# Add Sentry SDK configuration options here, e.g.:
# Instruct Sentry to send user data attached to the event
"send_default_pii": True,
}
# 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"
# Invenio-Files-Rest
# ==================
FILES_REST_STORAGE_FACTORY = "invenio_s3.s3fs_storage_factory"
# Invenio-S3
# ==========
S3_ENDPOINT_URL = "http://localhost:9000/"
S3_ACCESS_KEY_ID = "CHANGE_ME"
S3_SECRET_ACCESS_KEY = "CHANGE_ME"
# Invenio-Records-Resources
# =========================
# See https://github.com/inveniosoftware/invenio-records-resources/blob/master/invenio_records_resources/config.py
SITE_UI_URL = "https://localhost"
SITE_API_URL = "https://localhost/api"
APP_RDM_DEPOSIT_FORM_DEFAULTS = {
"publication_date": lambda: datetime.now().strftime("%Y-%m-%d"),
"creators": [
{"person_or_org": {"name": "No author", "type": "organizational"}}
],
"rights": [
{
"id": "cc-by-4.0",
"title": "Creative Commons Attribution 4.0 International",
"description": (
"The Creative Commons Attribution license allows "
"re-distribution and re-use of a licensed work "
"on the condition that the creator is "
"appropriately credited."
),
"link": "https://creativecommons.org/licenses/by/4.0/legalcode",
}
],
"resource_type": {
"id": "publication-blogpost",
},
"title": "No title",
}
# 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
#
# Persistent identifiers configuration
#
RDM_PERSISTENT_IDENTIFIER_PROVIDERS = [
# DOI provider for externally managed DOIs
providers.ExternalPIDProvider(
"external",
"doi",
validators=[
providers.BlockedPrefixes(config_names=["DATACITE_PREFIX"])
],
label=_("DOI"),
),
# OAI identifier
providers.OAIPIDProvider(
"oai",
label=_("OAI ID"),
),
]
"""A list of configured persistent identifier providers."""
RDM_PERSISTENT_IDENTIFIERS = {
"doi": {
"providers": ["external"],
"required": False,
"label": _("DOI"),
"validator": idutils.is_doi,
"normalizer": idutils.normalize_doi,
"is_enabled": providers.ExternalPIDProvider.is_enabled,
},
"oai": {
"providers": ["oai"],
"required": True,
"label": _("OAI"),
"is_enabled": providers.OAIPIDProvider.is_enabled,
},
}
"""The configured persistent identifiers for records."""
RDM_PARENT_PERSISTENT_IDENTIFIERS = {}
def always_valid(identifier):
"""Gives every identifier as valid."""
return True
RDM_RECORDS_IDENTIFIERS_SCHEMES = {
"ark": {"label": _("ARK"), "validator": idutils.is_ark, "datacite": "ARK"},
"arxiv": {
"label": _("arXiv"),
"validator": idutils.is_arxiv,
"datacite": "arXiv",
},
"ads": {
"label": _("Bibcode"),
"validator": idutils.is_ads,
"datacite": "bibcode",
},
"crossreffunderid": {
"label": _("Crossref Funder ID"),
"validator": always_valid,
"datacite": "Crossref Funder ID",
},
"doi": {"label": _("DOI"), "validator": idutils.is_doi, "datacite": "DOI"},
"ean13": {
"label": _("EAN13"),
"validator": idutils.is_ean13,
"datacite": "EAN13",
},
"eissn": {
"label": _("EISSN"),
"validator": idutils.is_issn,
"datacite": "EISSN",
},
"grid": {
"label": _("GRID"),
"validator": always_valid,
"datacite": "GRID",
},
"handle": {
"label": _("Handle"),
"validator": idutils.is_handle,
"datacite": "Handle",
},
"igsn": {
"label": _("IGSN"),
"validator": always_valid,
"datacite": "IGSN",
},
"isbn": {
"label": _("ISBN"),
"validator": idutils.is_isbn,
"datacite": "ISBN",
},
"isni": {
"label": _("ISNI"),
"validator": idutils.is_isni,
"datacite": "ISNI",
},
"issn": {
"label": _("ISSN"),
"validator": idutils.is_issn,
"datacite": "ISSN",
},
"istc": {
"label": _("ISTC"),
"validator": idutils.is_istc,
"datacite": "ISTC",
},
"lissn": {
"label": _("LISSN"),
"validator": idutils.is_issn,
"datacite": "LISSN",
},
"lsid": {
"label": _("LSID"),
"validator": idutils.is_lsid,
"datacite": "LSID",
},
"pmid": {
"label": _("PMID"),
"validator": idutils.is_pmid,
"datacite": "PMID",
},
"purl": {
"label": _("PURL"),
"validator": idutils.is_purl,
"datacite": "PURL",
},
"upc": {"label": _("UPC"), "validator": always_valid, "datacite": "UPC"},
"url": {"label": _("URL"), "validator": idutils.is_url, "datacite": "URL"},
"urn": {"label": _("URN"), "validator": idutils.is_urn, "datacite": "URN"},
"w3id": {
"label": _("W3ID"),
"validator": always_valid,
"datacite": "w3id",
},
# Custom identifiers added for Rogue Scholar
"uuid": {
"label": _("UUID"),
"validator": always_valid,
"datacite": "UUID",
},
"guid": {
"label": _("GUID"),
"validator": always_valid,
"datacite": "GUID",
},
"other": {
"label": _("Other"),
"validator": always_valid,
"datacite": "Other",
},
}
"""These are used for references, main, alternate and related identifiers."""
# 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
ACCOUNTS_DEFAULT_USER_VISIBILITY = "public"
SECURITY_REGISTERABLE = True # local login: allow 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 # don't allow users to login without confirming
)
# Static pages
APP_RDM_PAGES = {
"board": "/board",
}
# Enable optional custom fields
RDM_NAMESPACES = {
**JOURNAL_NAMESPACE,
"rs": None,
}
class CitationsCF(BaseListCF):
"""Citations with identifier, scheme and reference."""
def __init__(self, name, **kwargs):
"""Constructor."""
super().__init__(
name,
field_cls=fields.Nested,
field_args=dict(
nested=dict(
identifier=SanitizedUnicode(),
scheme=SanitizedUnicode(),
reference=SanitizedUnicode(),
)
),
multiple=True,
**kwargs,
)
@property
def mapping(self):
"""Return the mapping."""
return {
"properties": {
"identifier": {"type": "text"},
"scheme": {"type": "text"},
"reference": {"type": "text"},
}
}
RDM_CUSTOM_FIELDS = [
*JOURNAL_CUSTOM_FIELDS,
TextCF( # content in markdown format
name="rs:content_text",
),
TextCF( # feature image url
name="rs:image",
field_args={
"validate": validate.URL(),
},
multiple=False,
),
KeywordCF( # blogging platform
name="rs:generator"
),
CitationsCF( # citations
name="rs:citations"
),
]
RDM_CUSTOM_FIELDS_UI = [
{
"section": _("Publishing information"),
"hide_from_landing_page": True,
"fields": [
# journal
*JOURNAL_CUSTOM_FIELDS_UI["fields"],
],
},
{
"section": _("Images"),
"hide_from_landing_page": True,
"fields": [
dict(
field="rs:image",
ui_widget="Input",
props=dict(
label="Feature Image URL",
icon="image",
required=False,
),
),
],
},
]
COMMUNITIES_CUSTOM_FIELDS = [
TextCF(name="rs:issn"),
TextCF(name="rs:feed_url"),
KeywordCF(name="rs:feed_format"),
KeywordCF(name="rs:generator"),
KeywordCF(name="rs:prefix"),
KeywordCF(name="rs:license"),
TextCF(name="rs:joined"),
KeywordCF(name="rs:language"),
KeywordCF(name="rs:category"),
]
COMMUNITIES_CUSTOM_FIELDS_UI = [
{
"section": _("Feed information"),
"fields": [
dict(
field="rs:feed_url",
ui_widget="Input",
props=dict(
label=_("Feed URL"),
placeholder="",
icon="rss",
description=_("The feed URL for this community."),
required=False,
),
),
dict(
field="rs:feed_format",
ui_widget="Input",
props=dict(
label=_("Feed Format"),
placeholder="",
icon="compass",
description=_(
"The format of the feed for this community."
),
required=False,
),
),
dict(
field="rs:generator",
ui_widget="Input",
props=dict(
label=_("Generator"),
placeholder="",
icon="keyboard",
description=_(
"The feed generator software for this community."
),
required=False,
),
),
],
},
{
"section": _("Detailed Information"),
"fields": [
dict(
field="rs:license",
ui_widget="Input",
props=dict(
label=_("License"),
placeholder="",
icon="creative commons",
description=_(
"The License for content in this community."
),
required=False,
),
),
dict(
field="rs:issn",
ui_widget="Input",
props=dict(
label=_("ISSN"),
placeholder="",
icon="globe",
description=_("The ISSN for this community."),
required=False,
),
),
dict(
field="rs:prefix",
ui_widget="Input",
props=dict(
label=_("DOI Prefix"),
placeholder="",
icon="barcode",
description=_("The DOI prefix for this community."),
required=False,
),
),
dict(
field="rs:joined",
ui_widget="Input",
props=dict(
label=_("Date Joined"),
placeholder="",
icon="calendar plus",
description=_("The date this community has joined."),
required=False,
),
),
dict(
field="rs:language",
ui_widget="Input",
props=dict(
label=_("Language"),
placeholder="",
icon="language",
description=_("The language of this community."),
required=False,
),
),
dict(
field="rs:category",
ui_widget="Input",
props=dict(
label=_("Subject Area"),
placeholder="",
icon="chart pie",
description=_("The subject area for this community."),
required=False,
),
),
],
},
]
COMMUNITIES_SORT_OPTIONS = {
"bestmatch": dict(
title=_("Best match"),
fields=["_score"], # ES defaults to desc on `_score` field
),
"newest": dict(
title=_("Newest"),
fields=["-created"],
),
"oldest": dict(
title=_("Oldest"),
fields=["created"],
),
"version": dict(
title=_("Version"),
fields=["-versions.index"],
),
"updated-desc": dict(
title=_("Recently updated"),
fields=["-updated"],
),
"updated-asc": dict(
title=_("Least recently updated"),
fields=["updated"],
),
}
"""Definitions of available record sort options."""
RDM_SORT_OPTIONS = {
"bestmatch": dict(
title=_("Best match"),
fields=["_score"],
),
"newest": dict(
title=_("Newest"),
fields=["-metadata.publication_date", "-metadata.dates.date"],
),
"oldest": dict(
title=_("Oldest"),
fields=["metadata.publication_date", "metadata.dates.date"],
),
"version": dict(
title=_("Version"),
fields=["-versions.index"],
),
"updated-desc": dict(
title=_("Recently updated"),
fields=["-updated"],
),
"updated-asc": dict(
title=_("Least recently updated"),
fields=["updated"],
),
"created-desc": dict(
title=_("Recently added"),
fields=["-created"],
),
"created-asc": dict(
title=_("Least recently added"),
fields=["created"],
),
"mostviewed": dict(
title=_("Most viewed"),
fields=["-stats.all_versions.unique_views"],
),
}
class DateHistogramFacet(LabelledFacetMixin, dsl.DateHistogramFacet):
"""Facet for date histogram aggregations."""
def __init__(self, field=None, subfield=None, splitchar="::", **kwargs):
"""Initialize the date histogram facet."""
self._field = field
self._subfield = subfield
self._splitchar = splitchar
super().__init__(**kwargs)
def _date_interval_year(d: Any) -> Any:
return d.replace(
year=d.year + 1,
day=(28 if d.month == 2 and d.day == 29 else d.day),
)
def _date_interval_month(d: Any) -> Any:
return (d + timedelta(days=32)).replace(day=1)
def _date_interval_week(d: Any) -> Any:
return d + timedelta(days=7)
def _date_interval_day(d: Any) -> Any:
return d + timedelta(days=1)
def _date_interval_hour(d: Any) -> Any:
return d + timedelta(hours=1)
DATE_INTERVALS = {
"year": _date_interval_year,
"1Y": _date_interval_year,
"month": _date_interval_month,
"1M": _date_interval_month,
"week": _date_interval_week,
"1w": _date_interval_week,
"day": _date_interval_day,
"1d": _date_interval_day,
"hour": _date_interval_hour,
"1h": _date_interval_hour,
}
def get_value(self, bucket: Any) -> Any:
if not isinstance(bucket["key"], datetime):
# OpenSearch returns key=None instead of 0 for date 1970-01-01,
# so we need to set key to 0 to avoid TypeError exception
if bucket["key"] is None:
bucket["key"] = 0
# Preserve milliseconds in the datetime
return datetime.utcfromtimestamp(int(bucket["key"]) / 1000.0) # type: ignore
else:
return bucket["key"]
def get_value_filter(self, filter_value: Any) -> Any:
for interval_type in ("calendar_interval", "fixed_interval"):
if interval_type in self._params:
break
else:
interval_type = "interval"
return Range(
_expand__to_dot=False,
**{
self._params["field"]: {
"gte": filter_value,
"lt": self.DATE_INTERVALS[self._params[interval_type]](
filter_value
),
}
},
)
# Note, LabelledFacetMixin must be first class instantiated. This ensures
# that we overwrite the Facet.get_values() method in the Facet base class.
RDM_FACETS = {
"access_status": {
"facet": facets.access_status,
"ui": {
"field": "access.status",
},
},
"is_published": {
"facet": facets.is_published,
"ui": {
"field": "is_published",
},
},
"file_type": {
"facet": facets.filetype,
"ui": {
"field": "files.types",
},
},
"affiliations": {
"facet": TermsFacet(
field="metadata.creators.affiliations.id",
label=_("Affiliations"),
),
"ui": {
"field": "metadata.creators.affiliations.name",
},
},
"funders": {
"facet": TermsFacet(
field="metadata.funding.funder.name",
label=_("Funders"),
),
"ui": {
"field": "metadata.funding.funder.name",
},
},
"author_identifiers": {
"facet": TermsFacet(
field="metadata.creators.person_or_org.identifiers.scheme",
label=_("Author Identifiers"),
value_labels={"orcid": _("ORCID")},
),
"ui": {
"field": "metadata.creators.person_or_org.identifiers.scheme",
},
},
"references": {
"facet": TermsFacet(
field="metadata.references.scheme",
label=_("References"),
value_labels={
"doi": _("DOI"),
"url": _("URL"),
"": _("No identifier"),
},
),
"ui": {
"field": "metadata.references.scheme",
},
},
"citations": {
"facet": CFTermsFacet(
field="rs:citations.scheme",
label=_("Citations"),
value_labels={"doi": _("DOI")},
),
"ui": {
"field": CFTermsFacet.field("rs:citations.scheme"),
},
},
"platforms": {
"facet": CFTermsFacet(
field="rs:generator",
label=_("Platforms"),
),
"ui": {
"field": CFTermsFacet.field("rs:generator"),
},
},
"language": {
"facet": facets.language,
"ui": {
"field": "languages",
},
},
"resource_type": {
"facet": facets.resource_type,
"ui": {
"field": "resource_type.type",
"childAgg": {
"field": "resource_type.subtype",
},
},
},
"subject": {
"facet": facets.subject,
"ui": {
"field": "subjects.subject",
},
},
"publication_year": {
"facet": DateHistogramFacet(
field="metadata.publication_date",
interval="year",
label=_("Publication Year"),
),
"ui": {
"field": "metadata.publication_date",
},
},
}
# from https://github.com/zenodo/zenodo-rdm/blob/master/site/zenodo_rdm/queryparser.py
def word_doi(node):
"""Quote DOIs."""
if not node.value.startswith("10."):
return node
return Phrase(f'"{node.value}"')
def word_communities(node):
"""Resolve community slugs to IDs."""
slug = node.value
uuid = (
db.session.query(CommunityMetadata.id)
.filter(CommunityMetadata.slug == slug)
.scalar()
)
return Phrase(f'"{uuid}"')
RDM_SEARCH = {
# Supported values from RDM_FACETS
"facets": [
"language",
"subject",
"author_identifiers",
"references",
],
# Supported values from RDM_SORT_OPTIONS
"sort": [
"bestmatch",
"newest",
"oldest",
"updated-desc",
"updated-asc",
"created-desc",
"created-asc",
"mostviewed",
],
"query_parser_cls": QueryParser.factory(
mapping={
# shortcuts
"title": "metadata.title",
"subject": "metadata.subjects.subject",
"contributor": "metadata.creators.person_or_org.name",
"funder": "metadata.funding.funder.name",
"funding": "metadata.funding.award.number",
"references": FieldValueMapper(
"metadata.references.identifier", word=word_doi
),
"citations": FieldValueMapper(
"custom_fields.rs\:citations.identifier", word=word_doi
),
# taken from Zenodo
"doi": FieldValueMapper("pids.doi.identifier", word=word_doi),
"communities": FieldValueMapper(
"parent.communities.ids", word=word_communities
),
# Persistent identifiers
"orcid": "metadata.creators.person_or_org.identifiers.identifier",
"ror": "metadata.creators.affiliations.id",
"issn": "custom_fields.journal\:journal.issn",
# Specific to Rogue Scholar
"content": "custom_fields.rs\:content_text",
"platform": "custom_fields.rs\:generator",
},
tree_transformer_cls=SearchFieldTransformer,
),
}
COMMUNITIES_ALLOW_MEMBERSHIP_REQUESTS = True
COMMUNITIES_RECORDS_SEARCH = deepcopy(RDM_SEARCH)
"""Communities record search config is the same as the main record search."""
RDM_SEARCH_DRAFTS = {
"facets": [
"is_published",
"language",
"subject",
"author_identifiers",
"references",
],
"sort": [
"bestmatch",
"newest",
"oldest",
"updated-desc",
"updated-asc",
"created-desc",
"created-asc",
],
}
"""User records search configuration (i.e. list of uploads)."""
# Toggle to show or hide the 'Browse' menu entry for communities.
COMMUNITIES_SHOW_BROWSE_MENU_ENTRY = True
# Enable featured communities
COMMUNITIES_ADMINISTRATION_DISABLED = False
# Invenio-OAuthclient
# -------------------
# See https://github.com/inveniosoftware/invenio-oauthclient/blob/master/invenio_oauthclient/config.py
from invenio_oauthclient.contrib.orcid import ORCIDOAuthSettingsHelper