File tree Expand file tree Collapse file tree 3 files changed +63
-2
lines changed
theme/assets/semantic-ui/js/invenio_app_rdm Expand file tree Collapse file tree 3 files changed +63
-2
lines changed Original file line number Diff line number Diff line change 99
1010"""Utility functions."""
1111
12+ from datetime import datetime , timedelta , timezone
1213from itertools import chain
1314
1415from flask import current_app , g
@@ -167,8 +168,14 @@ def evaluate_file_modification(record):
167168 "valid_user" : file_mod .valid_user ,
168169 "allowed" : fm_allowed ,
169170 }
171+
170172 if fm_allowed :
171173 file_modification ["fileModification" ] = file_mod
172- file_modification ["context" ] = {}
174+ created = record ._record .created .replace (tzinfo = timezone .utc )
175+ modification_until = created + current_app .config .get (
176+ "RDM_FILE_MODIFICATION_PERIOD"
177+ )
178+ days_until = (modification_until - datetime .now (timezone .utc )).days
179+ file_modification ["context" ] = {"days_until" : days_until }
173180
174181 return file_modification
Original file line number Diff line number Diff line change 1+ // This file is part of InvenioRDM
2+ // Copyright (C) 2025 CERN.
3+ //
4+ // Invenio RDM Records is free software; you can redistribute it and/or modify it
5+ // under the terms of the MIT License; see LICENSE file for more details.
6+
7+ import React , { Component } from "react" ;
8+ import PropTypes from "prop-types" ;
9+ import { i18next } from "@translations/invenio_app_rdm/i18next" ;
10+
11+ export class FileModificationUntil extends Component {
12+ render ( ) {
13+ const { filesLocked, fileModification, record } = this . props ;
14+
15+ if ( ! fileModification . fileModification ?. enabled ) {
16+ return null ;
17+ }
18+
19+ if ( ! filesLocked && record . is_published && fileModification . context ?. days_until ) {
20+ return (
21+ < >
22+ { " " }
23+ { i18next . t ( "– Unlocked, {{ daysUntil }} days to publish changes" , {
24+ daysUntil : fileModification . context . days_until ,
25+ } ) }
26+ </ >
27+ ) ;
28+ }
29+
30+ return null ;
31+ }
32+ }
33+
34+ FileModificationUntil . propTypes = {
35+ filesLocked : PropTypes . bool . isRequired ,
36+ fileModification : PropTypes . object ,
37+ record : PropTypes . object . isRequired ,
38+ } ;
39+
40+ FileModificationUntil . defaultProps = {
41+ fileModification : { } ,
42+ } ;
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ import { CopyrightsField } from "@js/invenio_rdm_records/src/deposit/fields/Copy
4848import { ShareDraftButton } from "./ShareDraftButton" ;
4949import { depositFormSectionsConfig , severityChecksConfig } from "./config" ;
5050import { RecordDeletion } from "../components/RecordDeletion" ;
51+ import { FileModificationUntil } from "../components/FileModificationUntil" ;
5152
5253export class RDMDepositForm extends Component {
5354 constructor ( props ) {
@@ -183,12 +184,23 @@ export class RDMDepositForm extends Component {
183184 record = { record }
184185 config = { this . config }
185186 noFiles = { this . noFiles }
187+ fileModification = { fileModification }
188+ filesLocked = { filesLocked }
186189 >
187190 < AccordionField
188191 includesPaths = { this . sectionsConfig [ "files-section" ] }
189192 severityChecks = { this . severityChecks }
190193 active
191- label = { i18next . t ( "Files" ) }
194+ label = {
195+ < >
196+ { i18next . t ( "Files" ) }
197+ < FileModificationUntil
198+ fileModification = { fileModification }
199+ filesLocked = { filesLocked }
200+ record = { record }
201+ />
202+ </ >
203+ }
192204 id = "files-section"
193205 >
194206 { this . noFiles && record . is_published && (
You can’t perform that action at this time.
0 commit comments