aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/companies_controller.rb
diff options
context:
space:
mode:
authorXinhui2016-10-10 14:41:34 +0200
committerXinhui2016-10-10 14:41:34 +0200
commit70bf7114e5c02e13487125f3083a3be7e23aa5bb (patch)
treefb2bc9a661cc91c47ccd671539ce22af161e52f5 /app/controllers/companies_controller.rb
parent765747615d237ffb0953ec86a57ddff54713f912 (diff)
downloadchouette-core-70bf7114e5c02e13487125f3083a3be7e23aa5bb.tar.bz2
Company policy
Refs #1780
Diffstat (limited to 'app/controllers/companies_controller.rb')
-rw-r--r--app/controllers/companies_controller.rb17
1 files changed, 15 insertions, 2 deletions
diff --git a/app/controllers/companies_controller.rb b/app/controllers/companies_controller.rb
index cd0467a21..78b9f43a0 100644
--- a/app/controllers/companies_controller.rb
+++ b/app/controllers/companies_controller.rb
@@ -1,6 +1,6 @@
class CompaniesController < BreadcrumbController
include ApplicationHelper
-
+ before_action :check_policy, :only => [:edit, :update, :destroy]
defaults :resource_class => Chouette::Company
respond_to :html
respond_to :xml
@@ -10,7 +10,6 @@ class CompaniesController < BreadcrumbController
belongs_to :line_referential
def index
-
index! do |format|
format.html {
if collection.out_of_bounds?
@@ -21,6 +20,16 @@ class CompaniesController < BreadcrumbController
end
end
+ def new
+ authorize resource_class
+ super
+ end
+
+ def create
+ authorize resource_class
+ super
+ end
+
protected
def collection
@@ -39,6 +48,10 @@ class CompaniesController < BreadcrumbController
alias_method :line_referential, :parent
+ def check_policy
+ authorize resource
+ end
+
def company_params
params.require(:company).permit( :objectid, :object_version, :creation_time, :creator_id, :name, :short_name, :organizational_unit, :operating_department_name, :code, :phone, :fax, :email, :registration_number, :url, :time_zone )
end