From 531cdbf23c5b475cac7a94bf563b0db2f24d1f00 Mon Sep 17 00:00:00 2001 From: Martin Artnik Date: Wed, 21 Aug 2024 11:06:02 +0200 Subject: [PATCH] Properly handle experiments with hidden tasks in navigator [SCI-10988] --- app/models/experiment.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models/experiment.rb b/app/models/experiment.rb index 464de0f9e..57a1a820c 100644 --- a/app/models/experiment.rb +++ b/app/models/experiment.rb @@ -84,6 +84,8 @@ class Experiment < ApplicationRecord end def self.with_children_viewable_by_user(user) + # the NONE permission at the end also allows for experiments with hidden tasks (virtually empty) + # to show up on the list joins(" LEFT OUTER JOIN my_modules ON my_modules.experiment_id = experiments.id LEFT OUTER JOIN user_assignments my_module_user_assignments @@ -94,8 +96,8 @@ class Experiment < ApplicationRecord ") .where(' (my_module_user_assignments.user_id = ? AND my_module_user_roles.permissions @> ARRAY[?]::varchar[] - OR my_modules.id IS NULL) - ', user.id, MyModulePermissions::READ) + OR my_modules.id IS NULL OR my_module_user_roles.permissions @> ARRAY[?]::varchar[]) + ', user.id, MyModulePermissions::READ, MyModulePermissions::NONE) end def self.filter_by_teams(teams = [])