Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 10 additions & 6 deletions modules/weko-admin/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2032,7 +2032,8 @@ def test_index(self, client, users, db, admin_settings, mocker):
assert kwargs["deleted_workflow_name_dict"] == '{"1": "test_workflow"}'
assert kwargs["workflows"] == ["workflow 1"]
assert kwargs["duplicate_check_value"] == ""

assert kwargs["is_enable_duplicate_check"] == False

# xml get
# old_format exit and xml setting is workflow
login_user_via_session(client,email=users[0]["email"])# sysadmin
Expand All @@ -2058,7 +2059,8 @@ def test_index(self, client, users, db, admin_settings, mocker):
assert kwargs["deleted_workflow_name_dict"] == '{"1": "test_workflow"}'
assert kwargs["workflows"] == ["workflow 1"]
assert kwargs["duplicate_check_value"] == ""

assert kwargs["is_enable_duplicate_check"] == False

# tsv/csv get
# new_format exit
AdminSettings.query.filter_by(name="sword_api_setting").delete()
Expand All @@ -2084,7 +2086,7 @@ def test_index(self, client, users, db, admin_settings, mocker):
assert kwargs["deleted_workflow_name_dict"] == '{"1": "test_workflow"}'
assert kwargs["workflows"] == ["workflow 1"]
assert kwargs["duplicate_check_value"] == "checked"

assert kwargs["is_enable_duplicate_check"] == False
# xml get
# new_format exit
mock_render = mocker.patch("weko_admin.admin.SwordAPISettingsView.render", return_value=make_response())
Expand All @@ -2100,7 +2102,7 @@ def test_index(self, client, users, db, admin_settings, mocker):
assert kwargs["deleted_workflow_name_dict"] == '{"1": "test_workflow"}'
assert kwargs["workflows"] == ["workflow 1"]
assert kwargs["duplicate_check_value"] == "checked"

assert kwargs["is_enable_duplicate_check"] == False

# not exist admin_settings
default_settings = {
Expand Down Expand Up @@ -2180,7 +2182,8 @@ def test_create_view(self, client, db, users, item_type, flows, tokens, sword_ma
assert args[0] == "weko_admin/admin/sword_api_jsonld_settings.html"
assert kwargs["workflows"]
assert kwargs["can_edit"]

assert kwargs["is_enable_duplicate_check"] == False

# post
# success registration_type:Direct, active:True
login_user_via_session(client,email=users[0]["email"])# sysadmin
Expand Down Expand Up @@ -2322,7 +2325,8 @@ def test_edit_view(self, client, db, users, item_type, flows, tokens, sword_mapp
assert args[0] == "weko_admin/admin/sword_api_jsonld_settings.html"
assert kwargs["workflows"]
assert kwargs["can_edit"]

assert kwargs["is_enable_duplicate_check"] == False

# get
# cannot edit
mock_can_edit.return_value = False
Expand Down
7 changes: 6 additions & 1 deletion modules/weko-admin/weko_admin/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1553,7 +1553,8 @@ def index(self):
active_value = active_value,
registration_type_value = registration_type_value,
workflow_value = workflow_value,
duplicate_check_value = duplicate_check_value
duplicate_check_value = duplicate_check_value,
is_enable_duplicate_check = current_app.config.get("WEKO_ITEMS_UI_ENABLE_DUPLICATE_CHECK", False)
)
else:
# POST
Expand Down Expand Up @@ -1650,6 +1651,8 @@ def _format_metadata_collection(view, context, model, name):
return _("Inactive Message")

def _format_duplicate_check(view, context, model, name):
if current_app.config.get("WEKO_ITEMS_UI_ENABLE_DUPLICATE_CHECK", False) == False:
return ""
if model.duplicate_check:
return _("Active Message")
else:
Expand Down Expand Up @@ -1741,6 +1744,7 @@ def create_view(self):
current_model_json=None,
can_edit=True,
item_type_names=item_type_names,
is_enable_duplicate_check = current_app.config.get("WEKO_ITEMS_UI_ENABLE_DUPLICATE_CHECK", False)
)
else:
# POST
Expand Down Expand Up @@ -1879,6 +1883,7 @@ def edit_view(self, id):
can_edit=can_edit,
item_type_names=item_type_names,
id=model.id,
is_enable_duplicate_check = current_app.config.get("WEKO_ITEMS_UI_ENABLE_DUPLICATE_CHECK", False)
)
else:
# POST
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
</div>
</div>

<div class="row form-group">
<div class="row form-group" {%- if not is_enable_duplicate_check %}style="display:none;"{% endif %}>
<div class="col-sm-2 text-left">
<label>{{_('Duplicate Check')}}</label>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
</div>
</div>

<div class="row form-group">
<div class="row form-group" {%- if not is_enable_duplicate_check %}style="display:none;"{% endif %}>
<div class="col-sm-2 text-left">
<label>{{_('Duplicate Check')}}</label>
</div>
Expand Down
6 changes: 6 additions & 0 deletions modules/weko-items-ui/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11402,6 +11402,12 @@ def test_get_duplicate_fields():
# .tox/c1/bin/pytest --cov=weko_items_ui tests/test_utils.py::test_check_duplicate -v --cov-branch --cov-report=term --basetemp=/code/modules/weko-items-ui/.tox/c1/tmp
def test_check_duplicate(app, users,db_records3):
with app.test_request_context():
# Duplicate check disabled
app.config["WEKO_ITEMS_UI_ENABLE_DUPLICATE_CHECK"] = False
res, [], [] = check_duplicate('',True)
assert res == False

app.config["WEKO_ITEMS_UI_ENABLE_DUPLICATE_CHECK"] = True
# JSON format NG
res, [], [] = check_duplicate('',True)
assert res == False
Expand Down
3 changes: 3 additions & 0 deletions modules/weko-items-ui/weko_items_ui/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,3 +385,6 @@

WEKO_ITEMS_UI_PROXY_POSTING = False
"""Setting for multiple proxy posters."""

WEKO_ITEMS_UI_ENABLE_DUPLICATE_CHECK = False
"""Setting for duplicate check."""
5 changes: 5 additions & 0 deletions modules/weko-items-ui/weko_items_ui/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4066,6 +4066,8 @@ def get_duplicate_fields(data):
def check_duplicate(data, is_item=True, exclude_ids=[]):
"""Check if a record or item is duplicate in records_metadata.

If the setting for enabling/disabling the duplicate check function is False, it returns false.

Checks whether records or items in records_metadata are unique.

If an identifier exists, returns True if a duplicate item exists.
Expand All @@ -4086,6 +4088,9 @@ def check_duplicate(data, is_item=True, exclude_ids=[]):
- List of duplicate record IDs.
- List of duplicate record URLs.
"""
if current_app.config.get("WEKO_ITEMS_UI_ENABLE_DUPLICATE_CHECK", False) is False:
return False, [], []

if isinstance(data, str):
try:
data = json.loads(data)
Expand Down
Loading