Skip to content

Commit

Permalink
Merge pull request #3111 from DMPRoadmap/fix-org-visible-pdf
Browse files Browse the repository at this point in the history
fix for downloading organizationally visible PDFs
  • Loading branch information
briri authored Feb 15, 2022
2 parents 9f815ff + cc7c3e3 commit 0c719e8
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions app/policies/public_page_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
# Note the method names here correspond with controller actions
class PublicPagePolicy < ApplicationPolicy
# rubocop:disable Lint/MissingSuper
def initialize(object, object2 = nil)
@object = object
@object2 = object2
def initialize(user, record = nil)
@user = user
@record = record
end
# rubocop:enable Lint/MissingSuper

Expand All @@ -19,19 +19,18 @@ def template_index?
end

def template_export?
@object.present? && @object2.published?
@user.present? && @record.published?
end

def plan_export?
@object2.publicly_visible?
@record.publicly_visible?
end

def plan_organisationally_exportable?
plan = @object
user = @object2
if plan.is_a?(Plan) && user.is_a?(User)
return plan.publicly_visible? || (plan.organisationally_visible? && plan.owner.present? &&
plan.owner.org_id == user.org_id)
if @record.is_a?(Plan) && @user.is_a?(User)
return @record.publicly_visible? ||
(@record.organisationally_visible? && @record.owner.present? &&
@record.owner.org_id == @user.org_id)
end

false
Expand Down

0 comments on commit 0c719e8

Please sign in to comment.