invenio-app-rdm 13.0.0b1.dev27__py2.py3-none-any.whl → 13.0.0b1.dev28__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,6 +17,6 @@
17
17
  #
18
18
  # See PEP 0440 for details - https://www.python.org/dev/peps/pep-0440
19
19
 
20
- __version__ = "13.0.0b1.dev27"
20
+ __version__ = "13.0.0b1.dev28"
21
21
 
22
22
  __all__ = ("__version__",)
@@ -403,3 +403,24 @@ def secret_link_or_login_required():
403
403
  return view
404
404
 
405
405
  return decorator
406
+
407
+
408
+ def no_cache_response(f):
409
+ """Add appropriate response headers to force no caching.
410
+
411
+ This decorator is used to prevent caching of the response in the browser. This is needed
412
+ in the deposit form as we initialize the form with the record metadata included in the html page
413
+ and we don't want the browser to cache this page so that the user always gets the latest version of the record.
414
+ """
415
+
416
+ @wraps(f)
417
+ def view(*args, **kwargs):
418
+ response = make_response(f(*args, **kwargs))
419
+
420
+ response.cache_control.no_cache = True
421
+ response.cache_control.no_store = True
422
+ response.cache_control.must_revalidate = True
423
+
424
+ return response
425
+
426
+ return view
@@ -23,6 +23,7 @@ from invenio_i18n.ext import current_i18n
23
23
  from invenio_rdm_records.proxies import current_rdm_records
24
24
  from invenio_rdm_records.records.api import get_files_quota
25
25
  from invenio_rdm_records.resources.serializers import UIJSONSerializer
26
+ from invenio_rdm_records.services.components.pids import _get_optional_doi_transitions
26
27
  from invenio_rdm_records.services.schemas import RDMRecordSchema
27
28
  from invenio_rdm_records.services.schemas.utils import dump_empty
28
29
  from invenio_records_resources.services.errors import PermissionDeniedError
@@ -34,6 +35,7 @@ from sqlalchemy.orm import load_only
34
35
 
35
36
  from ..utils import set_default_value
36
37
  from .decorators import (
38
+ no_cache_response,
37
39
  pass_draft,
38
40
  pass_draft_community,
39
41
  pass_draft_files,
@@ -45,7 +47,7 @@ from .filters import get_scheme_label
45
47
  #
46
48
  # Helpers
47
49
  #
48
- def get_form_pids_config():
50
+ def get_form_pids_config(record=None):
49
51
  """Prepare configuration for the pids field.
50
52
 
51
53
  Currently supporting only doi.
@@ -55,17 +57,45 @@ def get_form_pids_config():
55
57
  # FIXME: User provider.is_managed() requires tiny fix in config
56
58
  can_be_managed = True
57
59
  can_be_unmanaged = True
60
+ # We initialize the optional doi to empty to indicate that there is no restriction on the transitions
61
+ # This is valid for new uploads and when the DOI is required in an instance
62
+ optional_doi_transitions = []
58
63
  for scheme in service.config.pids_providers.keys():
59
64
  if not scheme == "doi":
60
65
  continue
66
+
61
67
  record_pid_config = current_app.config["RDM_PERSISTENT_IDENTIFIERS"]
62
68
  scheme_label = record_pid_config.get(scheme, {}).get("label", scheme)
63
69
  is_doi_required = record_pid_config.get(scheme, {}).get("required")
64
70
  default_selected = (
65
71
  record_pid_config.get(scheme, {}).get("ui", {}).get("default_selected")
66
72
  )
73
+ if record is not None and not is_doi_required:
74
+ sitename = current_app.config.get("THEME_SITENAME", "this repository")
75
+ previous_published_record = (
76
+ service.record_cls.get_latest_published_by_parent(record.parent)
77
+ )
78
+ optional_doi_transitions = _get_optional_doi_transitions(
79
+ previous_published_record
80
+ )
81
+ if optional_doi_transitions:
82
+ optional_doi_transitions["message"] = optional_doi_transitions.get(
83
+ "message"
84
+ ).format(sitename=sitename)
85
+ if set(optional_doi_transitions.get("allowed_providers", [])) - set(
86
+ ["external", "not_needed"]
87
+ ):
88
+ # In case we have locally managed provider as an allowed one, we need to
89
+ # select it by default. That is relevant for the case when the
90
+ # user creates a new version of the record and the previous version
91
+ # had a datacite DOI.
92
+ default_selected = "no"
93
+
94
+ # if the DOI is required but the default selected is not_needed then we set it to yes
95
+ # to force the user to mint a DOI
67
96
  if is_doi_required and default_selected == "not_needed":
68
97
  default_selected = "yes"
98
+
69
99
  pids_provider = {
70
100
  "scheme": scheme,
71
101
  "field_label": "Digital Object Identifier",
@@ -89,6 +119,7 @@ def get_form_pids_config():
89
119
  "unambiguously cited. Example: 10.1234/foo.bar"
90
120
  ).format(scheme_label=scheme_label),
91
121
  "default_selected": default_selected,
122
+ "optional_doi_transitions": optional_doi_transitions,
92
123
  }
93
124
  pids_providers.append(pids_provider)
94
125
 
@@ -332,6 +363,8 @@ def get_form_config(**kwargs):
332
363
  if record_quota:
333
364
  quota["maxStorage"] = record_quota["quota_size"]
334
365
 
366
+ record = kwargs.pop("record", None)
367
+
335
368
  return dict(
336
369
  vocabularies=VocabulariesOptions().dump(),
337
370
  autocomplete_names=conf.get(
@@ -339,7 +372,7 @@ def get_form_config(**kwargs):
339
372
  ),
340
373
  current_locale=str(current_i18n.locale),
341
374
  default_locale=conf.get("BABEL_DEFAULT_LOCALE", "en"),
342
- pids=get_form_pids_config(),
375
+ pids=get_form_pids_config(record=record),
343
376
  quota=quota,
344
377
  decimal_size_display=conf.get("APP_RDM_DISPLAY_DECIMAL_FILE_SIZES", True),
345
378
  links=dict(
@@ -390,6 +423,7 @@ def new_record():
390
423
  # Views
391
424
  #
392
425
  @login_required
426
+ @no_cache_response
393
427
  @pass_draft_community
394
428
  def deposit_create(community=None):
395
429
  """Create a new deposit."""
@@ -441,6 +475,7 @@ def deposit_create(community=None):
441
475
  @secret_link_or_login_required()
442
476
  @pass_draft(expand=True)
443
477
  @pass_draft_files
478
+ @no_cache_response
444
479
  def deposit_edit(pid_value, draft=None, draft_files=None, files_locked=True):
445
480
  """Edit an existing deposit."""
446
481
  # don't show draft's deposit form if the user can't edit it
@@ -490,6 +525,7 @@ def deposit_edit(pid_value, draft=None, draft_files=None, files_locked=True):
490
525
  # hide react community component
491
526
  hide_community_selection=community_use_jinja_header,
492
527
  is_doi_required=is_doi_required,
528
+ record=draft._record,
493
529
  )
494
530
 
495
531
  if is_doi_required and not record.get("pids", {}).get("doi"):
@@ -211,6 +211,7 @@ export class RDMDepositForm extends Component {
211
211
  btnLabelGetPID={pid.btn_label_get_pid}
212
212
  canBeManaged={pid.can_be_managed}
213
213
  canBeUnmanaged={pid.can_be_unmanaged}
214
+ optionalDOItransitions={pid.optional_doi_transitions}
214
215
  fieldPath={`pids.${pid.scheme}`}
215
216
  fieldLabel={pid.field_label}
216
217
  isEditingPublishedRecord={
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: invenio-app-rdm
3
- Version: 13.0.0b1.dev27
3
+ Version: 13.0.0b1.dev28
4
4
  Summary: Invenio Research Data Management.
5
5
  Home-page: https://github.com/inveniosoftware/invenio-app-rdm
6
6
  Author: CERN
@@ -1,4 +1,4 @@
1
- invenio_app_rdm/__init__.py,sha256=3elnS9VtcHsQ4M7ZRFrjQGSNiWRk1S21ENs8rGFwtjw,700
1
+ invenio_app_rdm/__init__.py,sha256=7HyqB4G_tTbpxQtOpkBwfja70Zk-A_5X9H2lYM8V5UE,700
2
2
  invenio_app_rdm/cli.py,sha256=G6QqNU2W6n6ICtTMnpeKFXIsdorncDmVXwwwsGH5F2k,2746
3
3
  invenio_app_rdm/config.py,sha256=huHWP7FzjvRb7r_VOL33A9LQWKdmkUVJyEJaibKp3d4,50265
4
4
  invenio_app_rdm/ext.py,sha256=PkZhATGJDgYqBJQh41NdvBZWR83mgI3Eej6rj10UVJE,5278
@@ -80,8 +80,8 @@ invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/
80
80
  invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/stats_popup.html,sha256=5SVzfIS15Aro2Itd2BiaLbMXm0cvvwk6ZCdYjuSwhBw,625
81
81
  invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/version.html,sha256=JpE4e6RpbSR2pQD1rOsfvzD2ur584aRfBWUUap2IMBA,688
82
82
  invenio_app_rdm/records_ui/views/__init__.py,sha256=4NxQNADuvMsblEsGd3zkKXSNR5_4eLMcFEFYvc6NxVc,5718
83
- invenio_app_rdm/records_ui/views/decorators.py,sha256=eEBxGr0QPDNTXMumqymkoV_MLG0B3UhHgjOvR4e5eok,12673
84
- invenio_app_rdm/records_ui/views/deposits.py,sha256=4qEffCx0CL-qcWZ5nxV487IbSMDUwD05ILe4NXEozQs,19568
83
+ invenio_app_rdm/records_ui/views/decorators.py,sha256=_TYUGedQAHvEugusIG8xk8xPWHxfw9v4HZR_0dL-tH0,13371
84
+ invenio_app_rdm/records_ui/views/deposits.py,sha256=ZQSlYugqZX1jnS0GFNtJQVq2_KyDS_ECzp1S26qDGAs,21337
85
85
  invenio_app_rdm/records_ui/views/filters.py,sha256=Rm55fXJv97cqq8B_6KCe-3PxxHUH4VRu-jd9fTea6r4,6994
86
86
  invenio_app_rdm/records_ui/views/records.py,sha256=60pWASXnJS6t6yisq3QqnsNGCOaMDFPgCgErxXPUKuE,15455
87
87
  invenio_app_rdm/redirector/__init__.py,sha256=AYCTGmfbmkHW3YJXMqXlWBXcBrUsta-QmL9ULX2bjwA,243
@@ -156,7 +156,7 @@ invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/components/CopyButto
156
156
  invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/components/DisplayPartOfCommunities.js,sha256=bSmhuwSWk4CW80mqa4ZZbjfa-_NsiJ1IxQ9veDy6sAM,2751
157
157
  invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/components/DisplayVerifiedCommunity.js,sha256=m3rT8jJ3440ZX22zZog8bHatWltYXwvmw_tu6tJUM9k,1506
158
158
  invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/components/RecordsResultsListItem.js,sha256=H_3OJBlknDGsk4zJXUv1Ow9ZYpcL_yQZHsX4WM4yuCY,6344
159
- invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/deposit/RDMDepositForm.js,sha256=UlfRF935tRVAf2rfcEidBv_BOrnCz2M8tOdYRz9_Eb4,29057
159
+ invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/deposit/RDMDepositForm.js,sha256=7Sotq28SBmJE6j59Z7K786LRQxld-dVSmebaFKwhaok,29139
160
160
  invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/deposit/ShareDraftButton.js,sha256=ICMV4Ixe-nTe6q7COZ0oyAQf2nVp2cez_-iUZobwUD0,1998
161
161
  invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/deposit/index.js,sha256=gA0BaUFpaJr9nkmHSWoxuwKDfSD3JUTPcadj2TKHN24,1587
162
162
  invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/frontpage/RecordsList.js,sha256=PkLpiCl7sNSlQoCo7xxZ_H6QvWqK_TydoseIiKvtuMw,4176
@@ -519,9 +519,9 @@ invenio_app_rdm/users_ui/views/__init__.py,sha256=SMdY2NJj9GICfr3Xuok7qdNYVtA2bJ
519
519
  invenio_app_rdm/users_ui/views/dashboard.py,sha256=iUn2PrODAwb8ugmMosJKAjPhUzjCiWiAWoXQr9RUFuc,1793
520
520
  invenio_app_rdm/users_ui/views/ui.py,sha256=W_eXM8dLVIrNHQB2UEh37C9BYoHauft6RyvcDNFHovA,1742
521
521
  invenio_app_rdm/utils/files.py,sha256=CruDyO2gDVadSlWEJD-WHpWHeOQ0juh-Ei9jz3D9yjc,3923
522
- invenio_app_rdm-13.0.0b1.dev27.dist-info/LICENSE,sha256=AZXFHRrZa5s4m9DV7zZr4bPGTMUvcEPCodeV_AmFI8k,1204
523
- invenio_app_rdm-13.0.0b1.dev27.dist-info/METADATA,sha256=7o7ejauUNinc7T-e4HlkdyT-1JzcQE1eVOyPs7fYxmw,9272
524
- invenio_app_rdm-13.0.0b1.dev27.dist-info/WHEEL,sha256=9Hm2OB-j1QcCUq9Jguht7ayGIIZBRTdOXD1qg9cCgPM,109
525
- invenio_app_rdm-13.0.0b1.dev27.dist-info/entry_points.txt,sha256=r1vTqYNABeWqRMWitzyR9FnBsAy-KYZKZCp95IziyLY,2070
526
- invenio_app_rdm-13.0.0b1.dev27.dist-info/top_level.txt,sha256=quZejDUw2vLfKQboNIuVLJ9fxZifdnCT_s2PNf1dfmk,16
527
- invenio_app_rdm-13.0.0b1.dev27.dist-info/RECORD,,
522
+ invenio_app_rdm-13.0.0b1.dev28.dist-info/LICENSE,sha256=AZXFHRrZa5s4m9DV7zZr4bPGTMUvcEPCodeV_AmFI8k,1204
523
+ invenio_app_rdm-13.0.0b1.dev28.dist-info/METADATA,sha256=ZeW18bcqUAiGhh73TMovpEsFGQLXuUrUrA2GtTpPSp8,9272
524
+ invenio_app_rdm-13.0.0b1.dev28.dist-info/WHEEL,sha256=9Hm2OB-j1QcCUq9Jguht7ayGIIZBRTdOXD1qg9cCgPM,109
525
+ invenio_app_rdm-13.0.0b1.dev28.dist-info/entry_points.txt,sha256=r1vTqYNABeWqRMWitzyR9FnBsAy-KYZKZCp95IziyLY,2070
526
+ invenio_app_rdm-13.0.0b1.dev28.dist-info/top_level.txt,sha256=quZejDUw2vLfKQboNIuVLJ9fxZifdnCT_s2PNf1dfmk,16
527
+ invenio_app_rdm-13.0.0b1.dev28.dist-info/RECORD,,