From 64f7f1bad4da1f83b9e7d174f3b2262be68ad419 Mon Sep 17 00:00:00 2001 From: Martin Artnik Date: Mon, 26 Aug 2024 12:07:13 +0200 Subject: [PATCH 1/2] Fix deleted result activities, experiment activity permission checks, dashboard permission checks [SCI-11000] --- app/controllers/dashboard/calendars_controller.rb | 4 ++-- app/services/activities_service.rb | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/controllers/dashboard/calendars_controller.rb b/app/controllers/dashboard/calendars_controller.rb index 93217a54c..50c101638 100644 --- a/app/controllers/dashboard/calendars_controller.rb +++ b/app/controllers/dashboard/calendars_controller.rb @@ -9,7 +9,7 @@ module Dashboard date = params[:date].in_time_zone(current_user.time_zone) start_date = date.at_beginning_of_month.utc - 8.days end_date = date.at_end_of_month.utc + 15.days - due_dates = current_user.my_modules.active.uncomplete + due_dates = current_user.my_modules.readable_by_user(current_user).active.uncomplete .joins(experiment: :project) .where(experiments: { archived: false }) .where(projects: { archived: false }) @@ -23,7 +23,7 @@ module Dashboard date = params[:date].in_time_zone(current_user.time_zone) start_date = date.utc end_date = date.end_of_day.utc - my_modules = current_user.my_modules.active.uncomplete + my_modules = current_user.my_modules.readable_by_user(current_user).active.uncomplete .joins(experiment: :project) .where(experiments: { archived: false }) .where(projects: { archived: false }) diff --git a/app/services/activities_service.rb b/app/services/activities_service.rb index f0f7a720a..c39a00790 100644 --- a/app/services/activities_service.rb +++ b/app/services/activities_service.rb @@ -15,14 +15,18 @@ class ActivitiesService visible_by_repositories = Activity.where(subject_type: %w(RepositoryBase RepositoryRow), team_id: visible_repository_teams.select(:id)) .order(created_at: :desc) visible_by_projects = Activity.where(project_id: visible_projects.select(:id)) - .where.not(subject_type: %w(MyModule Result Protocol)) + .where.not(subject_type: %w(Experiment MyModule Result Protocol)) .order(created_at: :desc) + visible_by_experiments = Activity.where(subject_type: 'Experiment') + .where(subject_id: Experiment.viewable_by_user(user, visible_teams)) + .order(created_at: :desc) + visible_by_my_modules = Activity.where("subject_id IN (?) AND subject_type = 'MyModule' OR " \ "subject_id IN (?) AND subject_type = 'Result' OR " \ "subject_id IN (?) AND subject_type = 'Protocol'", visible_my_modules.select(:id), - Result.where(my_module: visible_my_modules).select(:id), + Result.with_discarded.where(my_module: visible_my_modules).select(:id), Protocol.where(my_module: visible_my_modules).select(:id)) .order(created_at: :asc) @@ -36,6 +40,7 @@ class ActivitiesService "((#{visible_by_teams.to_sql}) UNION ALL " \ "(#{visible_by_repositories.to_sql}) UNION ALL " \ "(#{visible_by_protocol_templates.to_sql}) UNION ALL " \ + "(#{visible_by_experiments.to_sql}) UNION ALL " \ "(#{visible_by_my_modules.to_sql}) UNION ALL " \ "(#{visible_by_projects.to_sql})) AS activities" ) From 726b1973f1cd55d87f8635f40d316dcbf5c38314 Mon Sep 17 00:00:00 2001 From: Martin Artnik Date: Tue, 27 Aug 2024 11:20:46 +0200 Subject: [PATCH 2/2] Update mapping step selections once an item is selected [SCI-11004] --- .../vue/repositories/modals/import/mapping_step.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/javascript/vue/repositories/modals/import/mapping_step.vue b/app/javascript/vue/repositories/modals/import/mapping_step.vue index fad5c3f3a..79526b6eb 100644 --- a/app/javascript/vue/repositories/modals/import/mapping_step.vue +++ b/app/javascript/vue/repositories/modals/import/mapping_step.vue @@ -44,11 +44,11 @@ {{ i18n.t('repositories.import_records.steps.step2.importedFileText') }} {{ params.file_name }}
-
+
{{ column }}
-