aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjpl2016-11-28 17:23:20 +0100
committerjpl2016-11-28 17:23:30 +0100
commitae9f75fb405fc0a61b79ca4862d9f052a1fb4fea (patch)
treeeac2941a786a5c3634c2d3cfdcb6bf1edb510d88
parent8d98af273f3607f3e85915ec418d7653a5e93e3f (diff)
downloadchouette-core-ae9f75fb405fc0a61b79ca4862d9f052a1fb4fea.tar.bz2
Refs #2019: updating table_builder helper with policies conditions
-rw-r--r--app/helpers/newfront_helper.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/app/helpers/newfront_helper.rb b/app/helpers/newfront_helper.rb
index c943b0f76..3d94cebe6 100644
--- a/app/helpers/newfront_helper.rb
+++ b/app/helpers/newfront_helper.rb
@@ -62,7 +62,22 @@ module NewfrontHelper
polymorph_url << item
if action == :delete
- content_tag :li, link_to(t("table.#{action}"), polymorph_url, method: :delete, data: { confirm: 'Etes-vous sûr(e) de vouloir effectuer cette action ?' })
+ if policy(item).present?
+ if policy(item).destroy?
+ content_tag :li, link_to(t("table.#{action}"), polymorph_url, method: :delete, data: { confirm: 'Etes-vous sûr(e) de vouloir effectuer cette action ?' })
+ end
+ else
+ content_tag :li, link_to(t("table.#{action}"), polymorph_url, method: :delete, data: { confirm: 'Etes-vous sûr(e) de vouloir effectuer cette action ?' })
+ end
+
+ elsif action == :edit
+ if policy(item).present?
+ if policy(item).update?
+ content_tag :li, link_to(t("table.#{action}"), polymorph_url)
+ end
+ else
+ content_tag :li, link_to(t("table.#{action}"), polymorph_url)
+ end
else
content_tag :li, link_to(t("table.#{action}"), polymorph_url)
end