-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
record files: enable file modifications depending on external DOi #2264
Closed
anikachurilova
wants to merge
1
commit into
inveniosoftware:master
from
anikachurilova:don't-lock-file-edition-for-external-DOIs
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
from invenio_previewer.proxies import current_previewer | ||
from invenio_rdm_records.proxies import current_rdm_records | ||
from invenio_rdm_records.resources.serializers import UIJSONSerializer | ||
from invenio_records.dictutils import dict_lookup | ||
from invenio_stats.proxies import current_stats | ||
from marshmallow import ValidationError | ||
|
||
|
@@ -140,19 +141,38 @@ def record_detail(pid_value, record, files, is_preview=False): | |
emitter(current_app, record=record._record, via_api=False) | ||
|
||
resolved_community, _ = get_record_community(record_ui) | ||
|
||
try: | ||
externalDOI = ( | ||
not current_app.config["RDM_LOCK_FILES_FOR_EXTERNAL_DOI"] | ||
and dict_lookup(record, "pids.doi.provider") | ||
== current_app.config["RDM_EXTERNAL_DOI_PROVIDER_KEY"] | ||
) | ||
except KeyError: | ||
externalDOI = False | ||
|
||
return render_template( | ||
current_app.config.get("APP_RDM_RECORD_LANDING_PAGE_TEMPLATE"), | ||
record=record_ui, | ||
files=files_dict, | ||
user_communities_memberships=get_user_communities_memberships(), | ||
permissions=record.has_permissions_to( | ||
["edit", "new_version", "manage", "update_draft", "read_files", "review"] | ||
[ | ||
"edit", | ||
"new_version", | ||
"manage", | ||
"update_draft", | ||
"read_files", | ||
"review", | ||
# "draft_modify_files", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd call this "show_version_button". Though I'd check what the "new_version" permission does to see if that might be duplicative. |
||
] | ||
), | ||
custom_fields_ui=custom_fields["ui"], | ||
is_preview=is_preview, | ||
is_draft=is_draft, | ||
community=resolved_community, | ||
external_resources=get_external_resources(record_ui), | ||
externalDOI=externalDOI, | ||
) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: commented line through the PR - the approach using permissions.
Question for the reviewers: which approach seems better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion permissions with
IfConfig
generator takingRDM_LOCK_FILES_FOR_EXTERNAL_DOI
as parameter would be cleaner. ping @slintThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think permissions make this cleaner, but with two separate permissions for the deposit form and landing page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second thought, I don't think we need to rely on permissions, the record status (published or draft) or even the DOI provider (external or DataCite) for this (at least for display purposes).
The reason is that at the end of the day, the one that controls if one can modify files of a deposit is the bucket (i.e.
RDMDraft.bucket
), and more specifically, if it's locked/unlocked. And the one that controls the draft bucket is theDraftFilesComponent.edit
component method.As a consequence, the active/inactive/hidden state of the files upload section in the form should be controlled by passing something like
filesEditable=draft.bucket.locked
. This also goes a bit in the direction of making React components "dumb presentation containers" and not aware of business-logic rules (like e.g. if the record is published or has an external DOI).Of course, we will still use config flags to control the features, and the defaults will not break the current behaviour, i.e. by default: