Skip to content

Commit 23eb8a8

Browse files
author
John Pinto
committed
Issue #3561 - Fix for bug "Discrepancy in Org Admin view of the
Organisation Plans and the related CSV Download". Changes: - where(Role.creator_condition) condition added to Plans retrieved in the Org model's org_admin_plans method. This ensures that Plans returned are only active plans. Note: if an owner or co-owner de-activates a plan the Role of the user is set to active: false, so any plan with creator with role (having active: false) would mean the Plan is removed. - To avoid duplication we removed .where(Role.creator_condition) in org_admin method in app/controllers/paginable/plans_controller.rb from line plans = plans.joins(:template, roles: [user::org]).where(Role.creator_condition).
1 parent bfbb518 commit 23eb8a8

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

app/controllers/paginable/plans_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def org_admin
4646
@super_admin = current_user.can_super_admin?
4747
@clicked_through = params[:click_through].present?
4848
plans = @super_admin ? Plan.all : current_user.org.org_admin_plans
49-
plans = plans.joins(:template, roles: [user: :org]).where(Role.creator_condition)
49+
plans = plans.joins(:template, roles: [user: :org])
5050

5151
paginable_renderise(
5252
partial: 'org_admin',

app/models/org.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,13 @@ def org_admin_plans
292292
if Rails.configuration.x.plans.org_admins_read_all
293293
Plan.includes(:template, :phases, :roles, :users).where(id: combined_plan_ids)
294294
.where(roles: { active: true })
295+
.where(Role.creator_condition)
295296
else
296297
Plan.includes(:template, :phases, :roles, :users).where(id: combined_plan_ids)
297298
.where.not(visibility: Plan.visibilities[:privately_visible])
298299
.where.not(visibility: Plan.visibilities[:is_test])
299300
.where(roles: { active: true })
301+
.where(Role.creator_condition)
300302
end
301303
end
302304
# rubocop:enable Metrics/AbcSize

0 commit comments

Comments
 (0)