From d577f559e12e61c135c4bfc17bc285f59365b2f0 Mon Sep 17 00:00:00 2001 From: Liane Hampe Date: Tue, 30 Jan 2024 19:33:18 +0100 Subject: [PATCH 1/2] Adds an extra check in DmsfQuery#dmsf_node This change stablizes the query with DmsfLink objects since they could have stored a project_id of -1 causing a nil error. This may happen when the linking of a dms document with an issue was not successful or aborted as observed with https://github.com/danmunn/redmine_dmsf/pull/1466. --- app/models/dmsf_query.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/dmsf_query.rb b/app/models/dmsf_query.rb index 8f13d5e9..c853e93b 100644 --- a/app/models/dmsf_query.rb +++ b/app/models/dmsf_query.rb @@ -230,7 +230,7 @@ class DmsfQuery < Query dmsf_link = DmsfLink.find_by(id: item.id) if dmsf_link.dmsf_folder !dmsf_link.dmsf_folder.visible? || !DmsfFolder.permissions?(dmsf_link.dmsf_folder, allow_system: false) - else + elsif dmsf_link.project !dmsf_link.project.dmsf_available? end else From 360c195f1a14828fac2344792e41f90d4b205655 Mon Sep 17 00:00:00 2001 From: Liane Hampe Date: Thu, 15 Feb 2024 08:27:42 +0100 Subject: [PATCH 2/2] Adds further condition in DmsfQuery#dmsf_nodes It will make sure that a pending link will be deleted from the query and hence not displayed to the user. A pending link has no project assigned. For those links the case statement in DmsfQuery#dmsf_nodes will now return true what causes the link to be deleted from the query result. --- app/models/dmsf_query.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/dmsf_query.rb b/app/models/dmsf_query.rb index c853e93b..eeaba684 100644 --- a/app/models/dmsf_query.rb +++ b/app/models/dmsf_query.rb @@ -232,6 +232,8 @@ class DmsfQuery < Query !dmsf_link.dmsf_folder.visible? || !DmsfFolder.permissions?(dmsf_link.dmsf_folder, allow_system: false) elsif dmsf_link.project !dmsf_link.project.dmsf_available? + else + !dmsf_link.project&.dmsf_available? end else false