|
| 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 | +To enable user file modification, there is a default time-based policy which allows users to edit their records within a certain period. 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 | +### Configure policies |
| 31 | + |
| 32 | +The time periods of the grace period policy are configured in two places, both in your config. |
| 33 | + |
| 34 | +First, the time to unlock the files is configured via passing a custom timedelta to the policy, e.g. `FileModificationGracePeriodPolicy(timedelta(days=30))` |
| 35 | + |
| 36 | +Second, 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)` |
| 37 | + |
| 38 | +!!! info |
| 39 | + |
| 40 | + 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. |
| 41 | + |
| 42 | +## Configure out of policy messages |
| 43 | + |
| 44 | +Unlike record deletion 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 bucket for them (in the same way they would) and then publish for them once they have made the changes. |
| 45 | + |
| 46 | +There are two messages which should be customised based upon how your instance handles support. |
| 47 | + |
| 48 | +First, the user facing message when they try to unlock the files outside of policy is a React compontent that should be [overridden](../customize/look-and-feel/override_components.md) using your `mapping.js`. For example, |
| 49 | + |
| 50 | +```js |
| 51 | +import { ModalContent } from "semantic-ui-react"; |
| 52 | +const ModificationMessage = () => { |
| 53 | + return ( |
| 54 | + <ModalContent> |
| 55 | + <p> |
| 56 | + {i18next.t( |
| 57 | + "Please contact us to request file modification, including the" + |
| 58 | + " record URL and a detailed justification in your message." |
| 59 | + )} |
| 60 | + </p> |
| 61 | + </ModalContent> |
| 62 | + ); |
| 63 | +}; |
| 64 | + |
| 65 | +export const overriddenComponents = { |
| 66 | + "InvenioAppRdm.Deposit.ModificationModal.message": ModificationMessage, |
| 67 | +}; |
| 68 | +``` |
| 69 | + |
| 70 | +Second, the message which is returned to the user when they have run out of time to publish is defined via your config: |
| 71 | + |
| 72 | +``` |
| 73 | +RDM_FILE_MODIFICATION_VALIDATION_ERROR_MESSAGE = _( |
| 74 | + "File modification grace period has passed. Please discard this draft to make any changes." |
| 75 | +) |
| 76 | +``` |
0 commit comments