|
| 1 | +# File modification |
| 2 | + |
| 3 | +_Introduced in vNext_ |
| 4 | + |
| 5 | +Admins can now modify the files of all records on their instance by default and, with configuration, you can also allow users to edit their own published records within a certain time period. |
| 6 | + |
| 7 | +## Disable |
| 8 | + |
| 9 | +If you would like to disable file modification for all users including admins, add the following to your `invenio.cfg`. |
| 10 | + |
| 11 | +``` |
| 12 | +RDM_IMMEDIATE_FILE_MODIFICATION_ENABLED = False |
| 13 | +``` |
| 14 | + |
| 15 | +## User file modification |
| 16 | + |
| 17 | +By default, only admins can modify files. To enable file modification for users, you need to add a relevant policy. Out of the box there is a time-based policy which you can use to allow users to edit their records within a certain period (by default this is 30 days). To enable this, add the following to your config: |
| 18 | + |
| 19 | +```python |
| 20 | +from invenio_rdm_records.services.request_policies import ( |
| 21 | + FileModificationGracePeriodPolicy, |
| 22 | + FileModificationAdminPolicy, |
| 23 | +) |
| 24 | +RDM_IMMEDIATE_FILE_MODIFICATION_POLICIES = [ |
| 25 | + FileModificationGracePeriodPolicy(), |
| 26 | + FileModificationAdminPolicy(), |
| 27 | +] |
| 28 | +``` |
| 29 | + |
| 30 | +To use a custom grace period, pass a custom timedelta like `FileModificationGracePeriodPolicy(grace_period=timedelta(days=7)))` here instead. And if you remove the admin policy then only users will able to edit files of records. |
| 31 | + |
| 32 | +### Configure policies |
| 33 | + |
| 34 | +Using the default grace periods, here is how file modification works from a user perspective: |
| 35 | + |
| 36 | +1. I create a draft, I have an unlimited time to edit the files before publishing |
| 37 | +2. After publishing, I have 30 days from publication to edit the files |
| 38 | + * The time to unlock the files is configured via passing a custom timedelta to the policy, e.g. `FileModificationGracePeriodPolicy(timedelta(days=30))` |
| 39 | +3. After editing the files, I have 45 days from publication to upload my files and publish my changes |
| 40 | + * The time in which to publish the changes, which should be greater than the grace period, is configured in your config via `RDM_FILE_MODIFICATION_PERIOD = timedelta(days=30 + 15)` |
| 41 | + |
| 42 | +The second time period of 45 days is to prevent people from editing the files, and leaving the files editable for an unknown date in the future. |
| 43 | + |
| 44 | +!!! info |
| 45 | + |
| 46 | + Short time periods are recommended for the file modification period as there is a risk of users treating records as file storage, and not respecting that a DOI has been minted for this digital object. |
| 47 | + |
| 48 | +## Configure out of policy messages |
| 49 | + |
| 50 | +Unlike [record deletion](record_deletion.md) in which users outside of policy can "request" deletion, users are **not** similarly allowed to request file modification when they are outside of policy. Instead this request should be made via established channels relevant for your instance (whether by email, in person communication, official support ticket, etc) or you should communicate that no concessions will be made (and if they have an unpublishable draft it should be discarded). If you would like to satisfy the users request, you can unlock the record for them (in the same way they would) and then publish for them once they have made the changes. |
| 51 | + |
| 52 | +There are two messages which should be customized based upon how your instance handles support. |
| 53 | + |
| 54 | +First, the user facing message when they try to unlock the files outside of policy is a React component that should be [overridden](../customize/look-and-feel/override_components.md) using your `mapping.js`. For example, |
| 55 | + |
| 56 | +```js |
| 57 | +import { ModalContent } from "semantic-ui-react"; |
| 58 | +const ModificationMessage = () => { |
| 59 | + return ( |
| 60 | + <ModalContent> |
| 61 | + <p> |
| 62 | + {i18next.t( |
| 63 | + "Please contact us to request file modification, including the" + |
| 64 | + " record URL and a detailed justification in your message." |
| 65 | + )} |
| 66 | + </p> |
| 67 | + </ModalContent> |
| 68 | + ); |
| 69 | +}; |
| 70 | + |
| 71 | +export const overriddenComponents = { |
| 72 | + "InvenioAppRdm.Deposit.ModificationModal.message": ModificationMessage, |
| 73 | +}; |
| 74 | +``` |
| 75 | + |
| 76 | +Second, the message which is returned to the user when they have run out of time to publish can be overriden via changing the [translation](../../community/translations/i18n.md). The default message is: |
| 77 | + |
| 78 | +> "File modification grace period has passed. Please discard this draft to make any changes." |
0 commit comments