Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
3c66cb4
Change weko-records-ui mdoels for URL download
ivis-yachi Dec 17, 2024
a787c3c
Fix isssues in weko-records-ui models
ivis-yachi Dec 17, 2024
33a7b77
Add minor changes to models
ivis-yachi Dec 18, 2024
af1b36a
Fix update_extra_info method
ivis-yachi Dec 18, 2024
15baf77
Add validation to update method
ivis-yachi Dec 18, 2024
441c9a0
Add showing error template
ivis-yachi Dec 20, 2024
a8afcb6
Fix error handlings in models
ivis-yachi Dec 24, 2024
141bd69
Add validations and constraints
ivis-yachi Dec 25, 2024
dc6599c
Add tests for model changes
ivis-yachi Dec 25, 2024
3c9f223
Merge pull request #372 from ivis-yachi/feature/W2024-23_change_models
ivis-kondo Dec 25, 2024
141ed73
シークレットURLボタン表示権限機能
sei-nakamura Dec 25, 2024
2881033
Change URL generation and download logic
ivis-yachi Jan 6, 2025
2c4be15
Fix extra_info update
ivis-yachi Jan 6, 2025
c6b7e61
コメント修正
sei-nakamura Jan 7, 2025
354b152
Merge pull request #390 from sei-nakamura/secret_url_modifi_NAKA
ivis-kondo Jan 7, 2025
ae6b82f
Merge branch 'feature/W2024-23' into feature/W2024-23_url_generation
ivis-yachi Jan 8, 2025
47a4a0b
Fix request validation
ivis-yachi Jan 8, 2025
d756667
Fix merge error
ivis-yachi Jan 8, 2025
cc37f48
Fix token validation
ivis-yachi Jan 8, 2025
c3f2a86
Change token validation logic
ivis-yachi Jan 9, 2025
a11d6a6
Fix timezone problem
ivis-yachi Jan 14, 2025
ed6a87d
Add tests for secret and onetime URL generation
ivis-yachi Jan 14, 2025
cfb9621
Delete debug codes
ivis-yachi Jan 15, 2025
ab6f6c0
Fix minor problems in tests
ivis-yachi Jan 15, 2025
ce6ecd0
ファイル詳細画面シークレットURL登録機能、管理者画面改修
sei-nakamura Jan 15, 2025
b280162
Fix token validation error
ivis-yachi Jan 15, 2025
6824020
Add a saving feature of download log
ivis-yachi Jan 15, 2025
03abbe4
Merge pull request #394 from ivis-yachi/feature/W2024-23_url_generation
ivis-kondo Jan 16, 2025
326309a
Refactored to share some duplicated logic
ivis-yachi Jan 16, 2025
50b9164
アクセス変更時シークレットURLの論理削除機能
sei-nakamura Jan 16, 2025
bd3b741
ファイル詳細画面レビュ後修正版
sei-nakamura Jan 17, 2025
dcb2a2c
ファイル詳細画面レビュ後修正最新版
sei-nakamura Jan 20, 2025
9b6af89
論理削除メソッドレビュ後修正版
sei-nakamura Jan 20, 2025
0f0a526
不要なコンソールログの削除
sei-nakamura Jan 20, 2025
8789be5
Add unit tests for download log
ivis-yachi Jan 20, 2025
4edd5db
Merge pull request #407 from ivis-yachi/feature/W2024-23_download_log
ivis-kondo Jan 22, 2025
d37d843
シークレットURL論理削除メソッド修正、単体テスト追加
sei-nakamura Jan 22, 2025
eeaeb65
Add copy endpoint to download url
ivis-yachi Jan 23, 2025
b3f24f2
シークレットURL論理削除メソッド追加
sei-nakamura Jan 23, 2025
80dbdc9
論理削除機能単体テストソースコード修正版
sei-nakamura Jan 24, 2025
4ac956d
Split endpoint for secret and onetime URLs
ivis-yachi Jan 24, 2025
103e3b1
Fix minor endpoint error
ivis-yachi Jan 24, 2025
b58663b
URL論理削除単体テスト検証ステップ追加。
sei-nakamura Jan 28, 2025
833e50a
Merge pull request #409 from sei-nakamura/access_change_logical_delete
ivis-kondo Jan 28, 2025
b8d041e
Add test codes for URL copy feature
ivis-yachi Jan 28, 2025
31773c7
Revised to avoid a deprecated practice
ivis-yachi Jan 28, 2025
5deb0d9
シークレットURL一覧機能
sei-nakamura Jan 28, 2025
5a64406
URL一覧表示機能シークレットURL修正、ワンタイムURL追加
sei-nakamura Jan 29, 2025
0b0c982
メッセージ追加
sei-nakamura Jan 29, 2025
dc25bb7
URL一覧表示指摘箇所修正1
sei-nakamura Jan 31, 2025
ae031ca
Merge branch 'feature/W2024-23' into secret_url_new_registration_func…
sei-nakamura Jan 31, 2025
ec0b9a9
Merge pull request #431 from ivis-yachi/feature/W2024-23_copy_and_del…
ivis-yachi Feb 3, 2025
46eb023
Add delete endpoint for download url
ivis-yachi Feb 3, 2025
216f8ae
Add 404 abort to URL delete functions
ivis-yachi Feb 6, 2025
fe5a47f
メッセージ、ポップアップ不足分追加
sei-nakamura Feb 6, 2025
b16a6aa
Add tests for URL delete functions
ivis-yachi Feb 6, 2025
def157a
Merge pull request #441 from ivis-yachi/feature/W2024-23_copy_and_del…
ivis-kondo Feb 6, 2025
3525550
Add Japanese localization
ivis-yachi Feb 6, 2025
0eed56d
Delete some view messages
ivis-yachi Feb 10, 2025
8e69598
Adjust views messages
ivis-yachi Feb 10, 2025
4c3fb62
Merge pull request #447 from ivis-yachi/feature/W2024-23_localization
ivis-kondo Feb 12, 2025
8b2dd3e
Merge branch 'feature/W2024-23' into URL_show_new_function
sei-nakamura Feb 12, 2025
c567223
Merge pull request #436 from sei-nakamura/URL_show_new_function
ivis-kondo Feb 12, 2025
0e60b16
Merge branch 'feature/W2024-23' into secret_url_new_registration_func…
sei-nakamura Feb 12, 2025
7da0d53
Merge branch 'feature/W2024-23' into secret_url_new_registration_func…
sei-nakamura Feb 12, 2025
519f0f7
Merge pull request #406 from sei-nakamura/secret_url_new_registration…
ivis-kondo Feb 12, 2025
da64a89
Fix integration test failures
ivis-yachi Feb 14, 2025
bd987a6
Fix i18n in weko-admin and weko-records-ui
ivis-yachi Feb 25, 2025
5e08e65
Add alembic migration settings
ivis-yachi Mar 6, 2025
7329a23
Revert "Fix i18n in weko-admin and weko-records-ui"
ivis-yachi Mar 11, 2025
b9133e4
Restore reverted commit
ivis-yachi Mar 11, 2025
092da1e
Add record data conversion
ivis-yachi Mar 12, 2025
862b4cb
Fix typo
ivis-yachi Mar 12, 2025
9e560aa
Modify the way the table is changed
ivis-yachi Mar 12, 2025
77fd4d4
Remove unnecessary codes
ivis-yachi Mar 12, 2025
ae9f278
Fix tests
ivis-yachi Mar 13, 2025
026bba4
Merge pull request #478 from ivis-yachi/feature/W2024-23_fix_i18n
ivis-kondo Mar 13, 2025
d46bdbb
Merge pull request #495 from ivis-yachi/feature/W2024-23_alembic
ivis-kondo Mar 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions modules/weko-admin/weko_admin/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1240,8 +1240,10 @@
WEKO_ADMIN_RESTRICTED_ACCESS_SETTINGS = {
"secret_URL_file_download": {
"secret_expiration_date": 30,
"max_secret_expiration_date":30,
"secret_expiration_date_unlimited_chk": False,
"secret_download_limit": 10,
"max_secret_download_limit":10,
"secret_download_limit_unlimited_chk": False,
},
"content_file_download": {
Expand Down
198 changes: 130 additions & 68 deletions modules/weko-admin/weko_admin/static/js/weko_admin/restricted_access.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@ const {useState, useEffect} = React;
const CONTENT_FILE_DOWNLOAD_LABEL = document.getElementById('content_file_download_label').value;
const DOWNLOAD_LIMIT_LABEL = document.getElementById('download_limit_label').value;
const EXPIRATION_DATE_LABEL = document.getElementById('expiration_date_label').value;
const MAX_DOWNLOAD_LIMIT_LABEL= document.getElementById('max_download_limit_label').value
const MAX_EXPIRATION_DATE_LABEL= document.getElementById('max_expiration_date_label').value
const EXPIRATION_DATE_INITIAL_LABEL = document.getElementById('expiration_date_initial_label').value;
const DOWNLOAD_LIMIT_INITIAL_LABEL = document.getElementById('download_limit_initial_label').value;
const UNLIMITED_LABEL = document.getElementById('unlimited_label').value;
const SAVE_LABEL = document.getElementById('save_label').value;
const CHECK_INPUT_DOWNLOAD = document.getElementById('check_input_download').value;
const CHECK_INPUT_EXPIRATION_DATE = document.getElementById('check_input_expiration_date').value;
const EMPTY_DOWNLOAD = document.getElementById('empty_download').value;
const EMPTY_EXPIRATION_DATE = document.getElementById('empty_expiration_date').value;
const EMPTY_MAX_EXPIRATION_DATE = document.getElementById('empty_max_expiration_date').value;
const EMPTY_MAX_DOWNLOAD_LIMIT = document.getElementById('empty_max_download_limit').value;
const USAGE_REPORT_WORKFLOW_ACCESS_LABEL = document.getElementById('usage_report_workflow_access_label').value
const MAXINT = Number(document.getElementById('maxint').value)
const MAX_DOWNLOAD_LIMIT = MAXINT;
Expand Down Expand Up @@ -64,66 +70,87 @@ function InputComponent({
label,
currentValue,
checkboxValue,
canSetUnlimited,
value,
setValue,
inputId,
checkboxId,
disabledAll=false
disabledAll=false,
maxLength=String(MAXINT).length,
max=MAXINT
}) {
const style = {marginRight: "5px", marginLeft: "15px"}
const style = {marginRight: "5px", marginLeft: "15px"};
const containerStyle ={display: 'flex',gap:'15px',marginBottom:'2px'};

function handleChange(event) {
event.preventDefault();
let target = event.target;
let key = target.id;
let updateValue = target.type === 'checkbox' ? target.checked : target.value;
let updateValue = target.value;

if (target.type !== 'checkbox') {
if (!event.target.validity.valid) {
updateValue = value[key];
}
if (isNaN(updateValue)) {
try {
updateValue = parseInt(updateValue);
} catch (e) {
console.log(e);
}
if (parseInt(updateValue) > max) {
updateValue = max;
}

if (!event.target.validity.valid) {
updateValue = value[key];
}
if (isNaN(updateValue)) {
try {
updateValue = parseInt(updateValue);
} catch (e) {
console.log(e);
}
}
setValue({...value, ...{[key]: updateValue}});
}

function handleUnlimited(event) {
let target = event.target;
let key = target.id;
let updateValue = target.type === 'checkbox' ? target.checked : target.value;
if (canSetUnlimited) {
if (!event.target.validity.valid) {
updateValue = value[key];
}
setValue({...value, ...{[key]: updateValue}});
}
}
return (
<div className="form-inline">
<label htmlFor={inputId} className="col-sm-2 text-right">{label}</label>
<input type="text" id={inputId} className="col-sm-2"
value={currentValue}
onChange={handleChange}
pattern="[0-9]*"
maxLength={String(MAXINT).length}
disabled={checkboxValue || disabledAll}
<div style={containerStyle} className="form-inline">
<label htmlFor={inputId} className="col-sm-2 text-right">{label}</label>
<input type="text" id={inputId} className="col-sm-2"
value={currentValue}
onChange={handleChange}
pattern="[0-9]*"
maxLength={maxLength}
disabled={checkboxValue || disabledAll}
max={max}

/>
{canSetUnlimited && (
<label htmlFor={checkboxId}
className="text-left">
<input type="checkbox"
style={style}
id={checkboxId}
key={Math.random()}
checked={checkboxValue}
onChange={handleChange}
onChange={handleUnlimited}
disabled={disabledAll}/>
{UNLIMITED_LABEL}
</label>
)}
</div>
)
}

function SecretURLFileDownloadLayout({value, setValue}) {
const {
secret_download_limit,
secret_download_limit_unlimited_chk,
secret_expiration_date,
secret_expiration_date_unlimited_chk,
max_secret_expiration_date,
max_secret_download_limit,
secret_enable
} = value;

Expand Down Expand Up @@ -162,26 +189,50 @@ function SecretURLFileDownloadLayout({value, setValue}) {
</label>
</div>
{/* end enabled checkbox */}
<InputComponent
label={EXPIRATION_DATE_LABEL}
currentValue={secret_expiration_date}
checkboxValue={secret_expiration_date_unlimited_chk}
inputId="secret_expiration_date"
checkboxId="secret_expiration_date_unlimited_chk"
value={value}
setValue={setValue}
disabledAll={disabledAll}
/>
<InputComponent
label={DOWNLOAD_LIMIT_LABEL}
currentValue={secret_download_limit}
checkboxValue={secret_download_limit_unlimited_chk}
inputId="secret_download_limit"
checkboxId="secret_download_limit_unlimited_chk"
value={value}
setValue={setValue}
disabledAll={disabledAll}
/>
<InputComponent
label={EXPIRATION_DATE_INITIAL_LABEL}
currentValue={secret_expiration_date}
inputId="secret_expiration_date"
canSetUnlimited = {false}
value={value}
setValue={setValue}
disabledAll={disabledAll}
maxLength={max_secret_expiration_date}
max={max_secret_expiration_date}
/>
<InputComponent
label={DOWNLOAD_LIMIT_INITIAL_LABEL}
currentValue={secret_download_limit}
inputId="secret_download_limit"
canSetUnlimited = {false}
value={value}
setValue={setValue}
disabledAll={disabledAll}
maxLength={max_secret_download_limit}
max={max_secret_download_limit}
/>
<InputComponent
label={MAX_EXPIRATION_DATE_LABEL}
currentValue={max_secret_expiration_date}
inputId="max_secret_expiration_date"
canSetUnlimited = {false}
value={value}
setValue={setValue}
disabledAll={disabledAll}
maxLength={2}
max={30}
/>
<InputComponent
label={MAX_DOWNLOAD_LIMIT_LABEL}
currentValue={max_secret_download_limit}
inputId="max_secret_download_limit"
canSetUnlimited = {false}
value={value}
setValue={setValue}
disabledAll={disabledAll}
maxLength={2}
max={10}
/>
</div>
</div>
</div>
Expand All @@ -193,9 +244,7 @@ function SecretURLFileDownloadLayout({value, setValue}) {
function ContentFileDownloadLayout({value, setValue}) {
const {
download_limit,
download_limit_unlimited_chk,
expiration_date,
expiration_date_unlimited_chk
} = value;

return (
Expand All @@ -210,18 +259,16 @@ function ContentFileDownloadLayout({value, setValue}) {
<InputComponent
label={EXPIRATION_DATE_LABEL}
currentValue={expiration_date}
checkboxValue={expiration_date_unlimited_chk}
inputId="expiration_date"
checkboxId="expiration_date_unlimited_chk"
canSetUnlimited = {false}
value={value}
setValue={setValue}
/>
<InputComponent
label={DOWNLOAD_LIMIT_LABEL}
currentValue={download_limit}
checkboxValue={download_limit_unlimited_chk}
inputId="download_limit"
checkboxId="download_limit_unlimited_chk"
canSetUnlimited = {false}
value={value}
setValue={setValue}
/>
Expand Down Expand Up @@ -250,6 +297,7 @@ function UsageReportWorkflowAccessLayout({value, setValue}) {
checkboxValue={expiration_date_access_unlimited_chk}
inputId="expiration_date_access"
checkboxId="expiration_date_access_unlimited_chk"
canSetUnlimited={true}
value={value}
setValue={setValue}
/>
Expand Down Expand Up @@ -480,13 +528,22 @@ function RestrictedAccessLayout({
showErrorMessage(MESSAGE_MISSING_DATA);
return false;
}


// Ensure the values are integers
const parsedSecretURLFileDownload = {
...secretURLFileDownload,
secret_download_limit: parseInt(secretURLFileDownload.secret_download_limit, 10),
max_secret_expiration_date: parseInt(secretURLFileDownload.max_secret_expiration_date, 10),
max_secret_download_limit: parseInt(secretURLFileDownload.max_secret_download_limit, 10),
secret_expiration_date: parseInt(secretURLFileDownload.secret_expiration_date, 10)
};

let data = {
secret_URL_file_download:secretURLFileDownload,
secret_URL_file_download:parsedSecretURLFileDownload,
content_file_download: contentFileDownload,
usage_report_workflow_access: usageReportWorkflowAccess,
terms_and_conditions: terms_data["data"]
}
};

$.ajax({
url: URL,
Expand All @@ -510,46 +567,51 @@ function RestrictedAccessLayout({
function validateSecretURLFileDownload() {
const {
secret_download_limit,
secret_download_limit_unlimited_chk,
secret_expiration_date,
secret_expiration_date_unlimited_chk
max_secret_expiration_date,
max_secret_download_limit
} = secretURLFileDownload;

let errorMessage;

if (secret_expiration_date === "" && !secret_expiration_date_unlimited_chk) {
if (secret_expiration_date === "" ) {
errorMessage = EMPTY_EXPIRATION_DATE;
} else if (secret_download_limit === "" && !secret_download_limit_unlimited_chk) {
} else if (secret_download_limit === "" ) {
errorMessage = EMPTY_DOWNLOAD;
} else if ((secret_expiration_date < 1 && !secret_expiration_date_unlimited_chk)
|| secret_expiration_date > MAX_EXPIRATION_DATE) {
} else if ((secret_expiration_date < 1 )
|| secret_expiration_date > max_secret_expiration_date) {
errorMessage = CHECK_INPUT_EXPIRATION_DATE;
} else if ((secret_download_limit < 1 && !secret_download_limit_unlimited_chk)
|| secret_download_limit > MAX_DOWNLOAD_LIMIT) {
} else if ((secret_download_limit < 1 )
|| secret_download_limit > max_secret_download_limit) {
errorMessage = CHECK_INPUT_DOWNLOAD;
} else if (max_secret_expiration_date === ""){
errorMessage = EMPTY_MAX_EXPIRATION_DATE;
} else if (max_secret_download_limit === ""){
errorMessage = EMPTY_DOWNLOAD;
} else if (max_secret_expiration_date < 1 ){
errorMessage = EMPTY_MAX_DOWNLOAD_LIMIT;
} else if (max_secret_download_limit < 1 ){
errorMessage = EMPTY_DOWNLOAD;
}

return errorMessage;
}

function validateContentFileDownload() {
const {
download_limit,
download_limit_unlimited_chk,
expiration_date,
expiration_date_unlimited_chk
} = contentFileDownload;

let errorMessage;

if (expiration_date === "" && !expiration_date_unlimited_chk) {
if (expiration_date === "" ) {
errorMessage = EMPTY_EXPIRATION_DATE;
} else if (download_limit === "" && !download_limit_unlimited_chk) {
} else if (download_limit === "" ) {
errorMessage = EMPTY_DOWNLOAD;
} else if ((expiration_date < 1 && !expiration_date_unlimited_chk)
} else if ((expiration_date < 1 )
|| expiration_date > MAX_EXPIRATION_DATE) {
errorMessage = CHECK_INPUT_EXPIRATION_DATE;
} else if ((download_limit < 1 && !download_limit_unlimited_chk)
} else if ((download_limit < 1 )
|| download_limit > MAX_DOWNLOAD_LIMIT) {
errorMessage = CHECK_INPUT_DOWNLOAD;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,29 @@
{% from "weko_theme/macros/modal_page.html" import all_modal %}
{% set download_limit = _("Download Limit") %}
{% set expiration_date = _("Expiration Date") %}
{% set max_download_limit = _("Max Download Limit") %}
{% set max_expiration_date = _("Max Expiration Date") %}
{% set expiration_date_initial = _("Expiration Date Initial Value") %}
{% set download_limit_initial = _("Download Limit Initial Value") %}
<input id="init_data" type="hidden" value='{{ data }}'/>
<input id="content_file_download_label" type="hidden" value='{{ _("Content File Download") }}'/>
<input id="download_limit_label" type="hidden" value='{{ download_limit }}'/>
<input id="expiration_date_label" type="hidden" value='{{ expiration_date }}'/>
<input id="max_download_limit_label" type="hidden" value='{{ max_download_limit }}'/>
<input id="max_expiration_date_label" type="hidden" value='{{ max_expiration_date }}'/>
<input id="expiration_date_initial_label" type="hidden" value='{{ expiration_date_initial }}'/>
<input id="download_limit_initial_label" type="hidden" value='{{ download_limit_initial }}'/>
<input id="unlimited_label" type="hidden" value='{{ _("Unlimited") }}'/>
<input id="save_label" type="hidden" value='{{ _("Save") }}'/>
<input id="usage_report_workflow_access_label" type="hidden" value='{{ _("Usage Report Workflow Access") }}'/>
<input id="check_input_download" type="hidden"
value='{{ _("Must set a positive integer for %(name)s.", name=download_limit) }}'/>
value='{{ _("Must set a positive integer and less than %(name1)s for %(name2)s.", name1=max_download_limit, name2=download_limit_initial) }}'/>
<input id="check_input_expiration_date" type="hidden"
value='{{ _("Must set a positive integer for %(name)s.", name=expiration_date) }}'/>
value='{{ _("Must set a positive integer and less than %(name1)s for %(name2)s.", name1=max_expiration_date, name2=expiration_date_initial) }}'/>
<input id="empty_download" type="hidden" value='{{ _("Please set %(name)s.", name=download_limit) }}'/>
<input id="empty_expiration_date" type="hidden" value='{{ _("Please set %(name)s.", name=expiration_date) }}'/>

<input id="empty_max_expiration_date" type="hidden" value='{{ _("Please set %(name)s.", name=max_expiration_date) }}'/>
<input id="empty_max_download_limit" type="hidden" value='{{ _("Please set %(name)s.", name=max_download_limit) }}'/>
<input type="hidden" id="english" value='{{_("English")}}'/>
<input type="hidden" id="japanese" value='{{_("Japanese")}}'/>
<input type="hidden" id="terms_and_conditions" value='{{_("Terms and Conditions")}}'/>
Expand Down
Binary file not shown.
Loading