aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/application_controller.rb6
-rw-r--r--app/controllers/calendars_controller.rb4
-rw-r--r--app/controllers/companies_controller.rb14
-rw-r--r--app/controllers/compliance_control_blocks_controller.rb13
-rw-r--r--app/controllers/compliance_controls_controller.rb2
-rw-r--r--app/controllers/exports_controller.rb3
-rw-r--r--app/controllers/referential_companies_controller.rb11
-rw-r--r--app/controllers/referentials_controller.rb2
-rw-r--r--app/controllers/stop_areas_controller.rb5
9 files changed, 40 insertions, 20 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index c4961123d..9a83394e2 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -36,12 +36,6 @@ class ApplicationController < ActionController::Base
end
helper_method :current_organisation
- def current_functional_scope
- functional_scope = current_organisation.sso_attributes.try(:[], "functional_scope") if current_organisation
- JSON.parse(functional_scope) if functional_scope
- end
- helper_method :current_functional_scope
-
def collection_name
self.class.name.split("::").last.gsub('Controller', '').underscore
end
diff --git a/app/controllers/calendars_controller.rb b/app/controllers/calendars_controller.rb
index 3d88e4910..adb3b4764 100644
--- a/app/controllers/calendars_controller.rb
+++ b/app/controllers/calendars_controller.rb
@@ -104,6 +104,10 @@ class CalendarsController < ChouetteController
end
end
+ def begin_of_association_chain
+ current_organisation
+ end
+
def ransack_contains_date
date =[]
if params[:q] && !params[:q]['contains_date(1i)'].empty?
diff --git a/app/controllers/companies_controller.rb b/app/controllers/companies_controller.rb
index 4afd12be1..a09cab783 100644
--- a/app/controllers/companies_controller.rb
+++ b/app/controllers/companies_controller.rb
@@ -38,12 +38,14 @@ class CompaniesController < ChouetteController
protected
def collection
- @q = line_referential.companies.search(params[:q])
-
+ scope = line_referential.companies
+ @q = scope.search(params[:q])
+ ids = @q.result(:distinct => true).pluck(:id)
+ scope = scope.where(id: ids)
if sort_column && sort_direction
- @companies ||= @q.result(:distinct => true).order(sort_column + ' ' + sort_direction).paginate(:page => params[:page])
+ @companies ||= scope.order(sort_column + ' ' + sort_direction).paginate(:page => params[:page])
else
- @companies ||= @q.result(:distinct => true).order(:name).paginate(:page => params[:page])
+ @companies ||= scope.order(:name).paginate(:page => params[:page])
end
end
@@ -69,7 +71,9 @@ class CompaniesController < ChouetteController
end
def company_params
- params.require(:company).permit( :objectid, :object_version, :name, :short_name, :organizational_unit, :operating_department_name, :code, :phone, :fax, :email, :registration_number, :url, :time_zone )
+ fields = [:objectid, :object_version, :name, :short_name, :organizational_unit, :operating_department_name, :code, :phone, :fax, :email, :registration_number, :url, :time_zone]
+ fields += permitted_custom_fields_params(Chouette::Company.custom_fields(line_referential.workgroup))
+ params.require(:company).permit( fields )
end
private
diff --git a/app/controllers/compliance_control_blocks_controller.rb b/app/controllers/compliance_control_blocks_controller.rb
index 9eee8dfaf..1173a548a 100644
--- a/app/controllers/compliance_control_blocks_controller.rb
+++ b/app/controllers/compliance_control_blocks_controller.rb
@@ -4,10 +4,23 @@ class ComplianceControlBlocksController < ChouetteController
belongs_to :compliance_control_set
actions :all, :except => [:show, :index]
+ after_action :display_errors, only: [:create, :update]
+
+ def display_errors
+ unless @compliance_control_block.errors[:condition_attributes].empty?
+ flash[:error] = @compliance_control_block.errors[:condition_attributes].join(', ')
+ end
+ end
+
private
def compliance_control_block_params
params.require(:compliance_control_block).permit(:transport_mode, :transport_submode)
end
+ protected
+
+ alias_method :compliance_control_set, :parent
+ helper_method :compliance_control_set
+
end
diff --git a/app/controllers/compliance_controls_controller.rb b/app/controllers/compliance_controls_controller.rb
index 73dc18f59..7df922d01 100644
--- a/app/controllers/compliance_controls_controller.rb
+++ b/app/controllers/compliance_controls_controller.rb
@@ -5,7 +5,7 @@ class ComplianceControlsController < ChouetteController
actions :all, :except => [:index]
def select_type
- @sti_subclasses = ComplianceControl.subclasses
+ @sti_subclasses = ComplianceControl.subclasses.sort_by {|compliance_control| compliance_control.default_code}
end
def show
diff --git a/app/controllers/exports_controller.rb b/app/controllers/exports_controller.rb
index a5282a514..c89da5000 100644
--- a/app/controllers/exports_controller.rb
+++ b/app/controllers/exports_controller.rb
@@ -3,13 +3,14 @@ class ExportsController < ChouetteController
include RansackDateFilter
include IevInterfaces
skip_before_action :authenticate_user!, only: [:upload]
+ skip_before_action :verify_authenticity_token, only: [:upload]
defaults resource_class: Export::Base, collection_name: 'exports', instance_name: 'export'
def upload
if params[:token] == resource.token_upload
resource.file = params[:file]
resource.save!
- redirect_to [resource.workbench, resource]
+ render json: {status: :ok}
else
user_not_authorized
end
diff --git a/app/controllers/referential_companies_controller.rb b/app/controllers/referential_companies_controller.rb
index 806a70c8f..200e56a89 100644
--- a/app/controllers/referential_companies_controller.rb
+++ b/app/controllers/referential_companies_controller.rb
@@ -40,11 +40,12 @@ class ReferentialCompaniesController < ChouetteController
end
@q = scope.search(params[:q])
-
+ ids = @q.result(:distinct => true).pluck(:id)
+ scope = scope.where(id: ids)
if sort_column && sort_direction
- @companies ||= @q.result(:distinct => true).order(sort_column + ' ' + sort_direction).paginate(:page => params[:page])
+ @companies ||= scope.order(sort_column + ' ' + sort_direction).paginate(:page => params[:page])
else
- @companies ||= @q.result(:distinct => true).order(:name).paginate(:page => params[:page])
+ @companies ||= scope.order(:name).paginate(:page => params[:page])
end
end
@@ -57,7 +58,9 @@ class ReferentialCompaniesController < ChouetteController
end
def company_params
- params.require(:company).permit( :objectid, :object_version, :name, :short_name, :organizational_unit, :operating_department_name, :code, :phone, :fax, :email, :registration_number, :url, :time_zone )
+ fields = [:objectid, :object_version, :name, :short_name, :organizational_unit, :operating_department_name, :code, :phone, :fax, :email, :registration_number, :url, :time_zone]
+ fields += permitted_custom_fields_params(Chouette::Company.custom_fields(@referential.workgroup))
+ params.require(:company).permit( fields )
end
private
diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb
index 6e3694547..fe661651e 100644
--- a/app/controllers/referentials_controller.rb
+++ b/app/controllers/referentials_controller.rb
@@ -143,7 +143,7 @@ class ReferentialsController < ChouetteController
def build_referential
if params[:from]
source_referential = Referential.find(params[:from])
- @referential = Referential.new_from(source_referential, current_functional_scope)
+ @referential = Referential.new_from(source_referential, current_organisation)
end
@referential.data_format = current_organisation.data_format
diff --git a/app/controllers/stop_areas_controller.rb b/app/controllers/stop_areas_controller.rb
index d0d9f652d..b2634467d 100644
--- a/app/controllers/stop_areas_controller.rb
+++ b/app/controllers/stop_areas_controller.rb
@@ -161,7 +161,7 @@ class StopAreasController < ChouetteController
helper_method :current_referential
def stop_area_params
- params.require(:stop_area).permit(
+ fields = [
:area_type,
:children_ids,
:city_name,
@@ -192,7 +192,8 @@ class StopAreasController < ChouetteController
:kind,
:status,
localized_names: Chouette::StopArea::AVAILABLE_LOCALIZATIONS
- )
+ ] + permitted_custom_fields_params(Chouette::StopArea.custom_fields) # XXX filter on the workgroup
+ params.require(:stop_area).permit(fields)
end
# Fake ransack filter