aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuc Donnet2017-12-01 13:30:04 +0100
committerLuc Donnet2017-12-01 13:30:04 +0100
commit8480e1db036e961fe106ff7fb2456c76f07d88ae (patch)
tree6dd9ffaeb5187a29a96aa8c072ab8cef3cd779ff
parent1bdb0765df3a172daedaa0e86dd1cdce328489fb (diff)
downloadchouette-core-8480e1db036e961fe106ff7fb2456c76f07d88ae.tar.bz2
Delete import links in show page must appear if user have the rights
-rw-r--r--app/decorators/import_decorator.rb22
1 files changed, 12 insertions, 10 deletions
diff --git a/app/decorators/import_decorator.rb b/app/decorators/import_decorator.rb
index d63d723cd..e748f830d 100644
--- a/app/decorators/import_decorator.rb
+++ b/app/decorators/import_decorator.rb
@@ -12,6 +12,7 @@ class ImportDecorator < Draper::Decorator
end
def action_links
+ policy = h.policy(object)
links = []
links << Link.new(
@@ -27,16 +28,17 @@ class ImportDecorator < Draper::Decorator
href: object.file.url
)
- # if h.policy(object).destroy?
- links << Link.new(
- content: h.destroy_link_content,
- href: h.workbench_import_path(
- context[:workbench],
- object
- ),
- method: :delete,
- data: { confirm: h.t('imports.actions.destroy_confirm') }
- )
+ if policy.destroy?
+ links << Link.new(
+ content: h.destroy_link_content,
+ href: h.workbench_import_path(
+ context[:workbench],
+ object
+ ),
+ method: :delete,
+ data: { confirm: h.t('imports.actions.destroy_confirm') }
+ )
+ end
links
end