Skip to content

Commit 0c719e8

Browse files
authored
Merge pull request #3111 from DMPRoadmap/fix-org-visible-pdf
fix for downloading organizationally visible PDFs
2 parents 9f815ff + cc7c3e3 commit 0c719e8

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

app/policies/public_page_policy.rb

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
# Note the method names here correspond with controller actions
55
class PublicPagePolicy < ApplicationPolicy
66
# rubocop:disable Lint/MissingSuper
7-
def initialize(object, object2 = nil)
8-
@object = object
9-
@object2 = object2
7+
def initialize(user, record = nil)
8+
@user = user
9+
@record = record
1010
end
1111
# rubocop:enable Lint/MissingSuper
1212

@@ -19,19 +19,18 @@ def template_index?
1919
end
2020

2121
def template_export?
22-
@object.present? && @object2.published?
22+
@user.present? && @record.published?
2323
end
2424

2525
def plan_export?
26-
@object2.publicly_visible?
26+
@record.publicly_visible?
2727
end
2828

2929
def plan_organisationally_exportable?
30-
plan = @object
31-
user = @object2
32-
if plan.is_a?(Plan) && user.is_a?(User)
33-
return plan.publicly_visible? || (plan.organisationally_visible? && plan.owner.present? &&
34-
plan.owner.org_id == user.org_id)
30+
if @record.is_a?(Plan) && @user.is_a?(User)
31+
return @record.publicly_visible? ||
32+
(@record.organisationally_visible? && @record.owner.present? &&
33+
@record.owner.org_id == @user.org_id)
3534
end
3635

3736
false

0 commit comments

Comments
 (0)