diff options
| author | Luc Donnet | 2017-07-25 22:15:35 +0200 |
|---|---|---|
| committer | Luc Donnet | 2017-07-25 22:15:35 +0200 |
| commit | cbfe9501f2d2cfc38cbe6ac12180e372dd78eca7 (patch) | |
| tree | dbe70647c87af0d779dbba06e20d0f0c2b4a294a /app/controllers | |
| parent | ea3ad8d1f9db76e3d2dfc5f96c930af8db074690 (diff) | |
| parent | cada0f02d732dce25492d7f7eb6d6232d56188dd (diff) | |
| download | chouette-core-cbfe9501f2d2cfc38cbe6ac12180e372dd78eca7.tar.bz2 | |
Merge branch 'master' into staging
Diffstat (limited to 'app/controllers')
| -rw-r--r-- | app/controllers/companies_controller.rb | 23 | ||||
| -rw-r--r-- | app/controllers/networks_controller.rb | 23 | ||||
| -rw-r--r-- | app/controllers/referential_companies_controller.rb | 23 | ||||
| -rw-r--r-- | app/controllers/referential_networks_controller.rb | 23 | ||||
| -rw-r--r-- | app/controllers/referentials_controller.rb | 4 | ||||
| -rw-r--r-- | app/controllers/time_tables_controller.rb | 29 | ||||
| -rw-r--r-- | app/controllers/workbenches_controller.rb | 9 |
7 files changed, 93 insertions, 41 deletions
diff --git a/app/controllers/companies_controller.rb b/app/controllers/companies_controller.rb index 07a732fc9..cf27c39cf 100644 --- a/app/controllers/companies_controller.rb +++ b/app/controllers/companies_controller.rb @@ -16,14 +16,13 @@ class CompaniesController < BreadcrumbController redirect_to params.merge(:page => 1) end - @companies = ModelDecorator.decorate( - @companies, - with: CompanyDecorator, - context: { - referential: line_referential - } - ) + @companies = decorate_companies(@companies) } + + format.json { + @companies = decorate_companies(@companies) + } + build_breadcrumb :index end end @@ -77,4 +76,14 @@ class CompaniesController < BreadcrumbController %w[asc desc].include?(params[:direction]) ? params[:direction] : 'asc' end + def decorate_companies(companies) + ModelDecorator.decorate( + companies, + with: CompanyDecorator, + context: { + referential: line_referential + } + ) + end + end diff --git a/app/controllers/networks_controller.rb b/app/controllers/networks_controller.rb index d1f83340e..5dae1ba3f 100644 --- a/app/controllers/networks_controller.rb +++ b/app/controllers/networks_controller.rb @@ -37,14 +37,13 @@ class NetworksController < BreadcrumbController redirect_to params.merge(:page => 1) end - @networks = ModelDecorator.decorate( - @networks, - with: NetworkDecorator, - context: { - line_referential: line_referential - } - ) + @networks = decorate_networks(@networks) } + + format.js { + @networks = decorate_networks(@networks) + } + build_breadcrumb :index end end @@ -87,4 +86,14 @@ class NetworksController < BreadcrumbController %w[asc desc].include?(params[:direction]) ? params[:direction] : 'asc' end + def decorate_networks(networks) + ModelDecorator.decorate( + networks, + with: NetworkDecorator, + context: { + line_referential: line_referential + } + ) + end + end diff --git a/app/controllers/referential_companies_controller.rb b/app/controllers/referential_companies_controller.rb index 53dde93bb..482f74ea0 100644 --- a/app/controllers/referential_companies_controller.rb +++ b/app/controllers/referential_companies_controller.rb @@ -14,14 +14,13 @@ class ReferentialCompaniesController < ChouetteController redirect_to params.merge(:page => 1) end - @companies = ModelDecorator.decorate( - @companies, - with: CompanyDecorator, - context: { - referential: referential - } - ) + @companies = decorate_companies(@companies) } + + format.js { + @companies = decorate_companies(@companies) + } + build_breadcrumb :index end end @@ -70,4 +69,14 @@ class ReferentialCompaniesController < ChouetteController %w[asc desc].include?(params[:direction]) ? params[:direction] : 'asc' end + def decorate_companies(companies) + ModelDecorator.decorate( + companies, + with: CompanyDecorator, + context: { + referential: referential + } + ) + end + end diff --git a/app/controllers/referential_networks_controller.rb b/app/controllers/referential_networks_controller.rb index e0ce71ce4..ee2db8008 100644 --- a/app/controllers/referential_networks_controller.rb +++ b/app/controllers/referential_networks_controller.rb @@ -30,14 +30,13 @@ class ReferentialNetworksController < ChouetteController redirect_to params.merge(:page => 1) end - @networks = ModelDecorator.decorate( - @networks, - with: ReferentialNetworkDecorator, - context: { - referential: referential - } - ) + @networks = decorate_networks(@networks) } + + format.js { + @networks = decorate_networks(@networks) + } + build_breadcrumb :index end end @@ -81,4 +80,14 @@ class ReferentialNetworksController < ChouetteController %w[asc desc].include?(params[:direction]) ? params[:direction] : 'asc' end + def decorate_networks(networks) + ModelDecorator.decorate( + networks, + with: ReferentialNetworkDecorator, + context: { + referential: referential + } + ) + end + end diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb index 838c46168..afd376092 100644 --- a/app/controllers/referentials_controller.rb +++ b/app/controllers/referentials_controller.rb @@ -9,7 +9,7 @@ class ReferentialsController < BreadcrumbController def new if params[:from] source_referential = Referential.find(params[:from]) - @referential = Referential.new_from(source_referential, organisation: current_organisation) + @referential = Referential.new_from(source_referential) end new! do @@ -118,7 +118,7 @@ class ReferentialsController < BreadcrumbController end def create_resource(referential) - referential.organisation = current_organisation unless referential.created_from + referential.organisation = current_organisation referential.ready = true super end diff --git a/app/controllers/time_tables_controller.rb b/app/controllers/time_tables_controller.rb index 20d500ea9..0054963c9 100644 --- a/app/controllers/time_tables_controller.rb +++ b/app/controllers/time_tables_controller.rb @@ -35,9 +35,9 @@ class TimeTablesController < ChouetteController def create tt_params = time_table_params - if tt_params[:calendar_id] + if tt_params[:calendar_id] && tt_params[:calendar_id] != "" %i(monday tuesday wednesday thursday friday saturday sunday).map { |d| tt_params[d] = true } - calendar = current_organisation.calendars.find_by_id(tt_params[:calendar_id]) + calendar = Calendar.find(tt_params[:calendar_id]) tt_params[:calendar_id] = nil if tt_params.has_key?(:dates_attributes) || tt_params.has_key?(:periods_attributes) end @@ -86,16 +86,14 @@ class TimeTablesController < ChouetteController redirect_to params.merge(:page => 1) end - @time_tables = ModelDecorator.decorate( - @time_tables, - with: TimeTableDecorator, - context: { - referential: @referential - } - ) + @time_tables = decorate_time_tables(@time_tables) build_breadcrumb :index } + + format.js { + @time_tables = decorate_time_tables(@time_tables) + } end end @@ -117,7 +115,8 @@ class TimeTablesController < ChouetteController end def tags - @tags = ActsAsTaggableOn::Tag.where("tags.name = ?", "%#{params[:tag]}%") + # @tags = ActsAsTaggableOn::Tag.where("tags.name = ?", "%#{params[:tag]}%") + @tags = Chouette::TimeTable.tags_on(:tags) respond_to do |format| format.json { render :json => @tags.map{|t| {:id => t.id, :name => t.name }} } end @@ -195,6 +194,16 @@ class TimeTablesController < ChouetteController Chouette::TimeTable.find(from_id) if from_id end + def decorate_time_tables(time_tables) + ModelDecorator.decorate( + time_tables, + with: TimeTableDecorator, + context: { + referential: @referential + } + ) + end + def time_table_params params.require(:time_table).permit( :objectid, diff --git a/app/controllers/workbenches_controller.rb b/app/controllers/workbenches_controller.rb index 22a71863a..19af28a98 100644 --- a/app/controllers/workbenches_controller.rb +++ b/app/controllers/workbenches_controller.rb @@ -2,7 +2,14 @@ class WorkbenchesController < BreadcrumbController before_action :query_params, only: [:show] defaults resource_class: Workbench - respond_to :html, only: [:show] + respond_to :html, only: [:show, :index] + + def index + # Only display Wb with selected name, according to #4108 + @workbench = current_organisation.workbenches.find_by(name: "Gestion de l'offre") + @referentials = @workbench.all_referentials + @calendars = Calendar.where('organisation_id = ? OR shared = ?', current_organisation.id, true) + end def show scope = resource.all_referentials |
