Skip to content

Commit

Permalink
DMP ASS'T PATCH Plan.organisationally_or_publicly_visible
Browse files Browse the repository at this point in the history
This commit is intended to patch issue #732

This DMP Assistant fix was implemented in a way to minimise conflicts with the upstream, DMPRoadmap repo. This issue also exists in the upstream repo, so this commit will be readdressed after a fix is implemented there.
  • Loading branch information
aaronskiba committed Apr 26, 2024
1 parent 7259fcc commit 073f963
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/models/plan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,12 @@ class Plan < ApplicationRecord

# Retrieves any plan organisationally or publicly visible for a given org id
scope :organisationally_or_publicly_visible, lambda { |user|
plan_ids = user.org.org_admin_plans.where(complete: true).pluck(:id).uniq
# plan_ids = user.org.org_admin_plans.where(complete: true).pluck(:id).uniq
org_users_ids = user.org.users.where(active: true).pluck(:id)
plan_ids = Role.creator.where(user_id: org_users_ids, active: true).pluck(:plan_id)
includes(:template, roles: :user)
.where(id: plan_ids, visibility: [
.where(id: plan_ids, complete: true,
visibility: [
visibilities[:organisationally_visible],
visibilities[:publicly_visible]
])
Expand Down

0 comments on commit 073f963

Please sign in to comment.