diff options
61 files changed, 389 insertions, 427 deletions
diff --git a/.gitignore b/.gitignore index 3a8d7d6d2..4bd57ce25 100644 --- a/.gitignore +++ b/.gitignore @@ -29,5 +29,7 @@ coverage # IDE .idea +bin/ + # Ignore node modules /node_modules @@ -128,6 +128,7 @@ gem 'letter_opener' group :development do gem 'capistrano', '2.13.5' gem 'capistrano-ext' + gem 'capistrano-npm', require: false gem 'guard' gem 'guard-rspec' gem 'rails-erd' diff --git a/Gemfile.lock b/Gemfile.lock index 58cccc276..a3ede77d1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -103,6 +103,8 @@ GEM net-ssh-gateway (>= 1.1.0) capistrano-ext (1.2.1) capistrano (>= 1.0.0) + capistrano-npm (0.0.2) + capistrano (>= 2.5.5) capybara (2.4.4) mime-types (>= 1.16) nokogiri (>= 1.3.3) @@ -580,6 +582,7 @@ DEPENDENCIES calendar_helper (= 0.2.5) capistrano (= 2.13.5) capistrano-ext + capistrano-npm capybara (~> 2.4.0) cocoon codifligne! @@ -677,4 +680,4 @@ DEPENDENCIES will_paginate-bootstrap (~> 1.0.1) BUNDLED WITH - 1.13.5 + 1.13.6 diff --git a/app/assets/javascripts/es6_browserified/components/TodoList.js b/app/assets/javascripts/es6_browserified/components/TodoList.js index fbc204417..e909f07bb 100644 --- a/app/assets/javascripts/es6_browserified/components/TodoList.js +++ b/app/assets/javascripts/es6_browserified/components/TodoList.js @@ -10,8 +10,8 @@ const TodoList = ({ todos, onDeleteClick, onMoveUpClick, onMoveDownClick, onChan key={'item-' + index} onDeleteClick={() => onDeleteClick(index)} onMoveUpClick={() => { - onMoveUpClick(index)} - } + onMoveUpClick(index) + }} onMoveDownClick={() => onMoveDownClick(index)} onChange={ onChange } first={ index === 0 } diff --git a/app/controllers/api/v1/routes_controller.rb b/app/controllers/api/v1/routes_controller.rb index e3694725f..fbc589355 100644 --- a/app/controllers/api/v1/routes_controller.rb +++ b/app/controllers/api/v1/routes_controller.rb @@ -3,11 +3,11 @@ class Api::V1::RoutesController < Api::V1::ChouetteController defaults :resource_class => Chouette::Route, :finder => :find_by_objectid! belongs_to :line, :parent_class => Chouette::Line, :optional => true, :finder => :find_by_objectid!, :param => :line_id - + protected def collection @routes ||= parent.routes - end + end end diff --git a/app/controllers/referential_companies_controller.rb b/app/controllers/referential_companies_controller.rb index 104deba9f..a369488ba 100644 --- a/app/controllers/referential_companies_controller.rb +++ b/app/controllers/referential_companies_controller.rb @@ -27,7 +27,7 @@ class ReferentialCompaniesController < ChouetteController end def collection - @q = referential.companies.search(params[:q]) + @q = referential.workbench.companies.search(params[:q]) @companies ||= @q.result(:distinct => true).order(:name).paginate(:page => params[:page]) end diff --git a/app/controllers/referential_group_of_lines_controller.rb b/app/controllers/referential_group_of_lines_controller.rb index d40fd6090..4decef558 100644 --- a/app/controllers/referential_group_of_lines_controller.rb +++ b/app/controllers/referential_group_of_lines_controller.rb @@ -55,7 +55,7 @@ class ReferentialGroupOfLinesController < ChouetteController end def collection - @q = referential.group_of_lines.search(params[:q]) + @q = referential.workbench.group_of_lines.search(params[:q]) @group_of_lines ||= @q.result(:distinct => true).order(:name).paginate(:page => params[:page]) end diff --git a/app/controllers/referential_networks_controller.rb b/app/controllers/referential_networks_controller.rb index 2d3f4ad6b..00c680c65 100644 --- a/app/controllers/referential_networks_controller.rb +++ b/app/controllers/referential_networks_controller.rb @@ -35,7 +35,7 @@ class ReferentialNetworksController < ChouetteController end def collection - @q = referential.networks.search(params[:q]) + @q = referential.workbench.networks.search(params[:q]) @networks ||= @q.result(:distinct => true).order(:name).paginate(:page => params[:page]) end diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb index 3ae59f975..003c85d3a 100644 --- a/app/controllers/referentials_controller.rb +++ b/app/controllers/referentials_controller.rb @@ -57,11 +57,7 @@ class ReferentialsController < BreadcrumbController end def create_resource(referential) - if referential.created_from - referential.clone_association referential.created_from - else - referential.organisation = current_organisation - end + referential.organisation = current_organisation unless referential.created_from super end diff --git a/app/controllers/routes_controller.rb b/app/controllers/routes_controller.rb index 59c129867..a7e8e32a6 100644 --- a/app/controllers/routes_controller.rb +++ b/app/controllers/routes_controller.rb @@ -77,7 +77,7 @@ class RoutesController < ChouetteController private def route_params - params.require(:route).permit( :direction_code, :wayback_code, :line_id, :objectid, :object_version, :creation_time, :creator_id, :name, :comment, :opposite_route_id, :published_name, :number, :direction, :wayback, { stop_points_attributes: [ :id, :_destroy, :position, :stop_area_id, :for_boarding, :for_alighting ] } ) + params.require(:route).permit( :line_id, :objectid, :object_version, :creation_time, :creator_id, :name, :comment, :opposite_route_id, :published_name, :number, :direction, :wayback, { stop_points_attributes: [ :id, :_destroy, :position, :stop_area_id, :for_boarding, :for_alighting ] } ) end end diff --git a/app/controllers/stop_areas_controller.rb b/app/controllers/stop_areas_controller.rb index 8f6a1565a..1f55b1de8 100644 --- a/app/controllers/stop_areas_controller.rb +++ b/app/controllers/stop_areas_controller.rb @@ -26,6 +26,7 @@ class StopAreasController < BreadcrumbController end def add_children + authorize stop_area @stop_area = stop_area @children = stop_area.children build_breadcrumb :edit diff --git a/app/helpers/routes_helper.rb b/app/helpers/routes_helper.rb index b3d79262e..159c93054 100644 --- a/app/helpers/routes_helper.rb +++ b/app/helpers/routes_helper.rb @@ -6,11 +6,11 @@ module RoutesHelper end def fonticon_wayback(wayback) - if wayback == "A" + if wayback == 'straight_forward' return '<i class="fa fa-arrow-right"></i>'.html_safe else - return '<i class="fa fa-arrow-left"></i>'.html_safe + return '<i class="fa fa-arrow-left"></i>'.html_safe end end - + end diff --git a/app/inputs/search_stop_area_input.rb b/app/inputs/search_stop_area_input.rb index e5cfafc34..c7e21e921 100644 --- a/app/inputs/search_stop_area_input.rb +++ b/app/inputs/search_stop_area_input.rb @@ -1,5 +1,5 @@ class SearchStopAreaInput < Formtastic::Inputs::SearchInput - + def search if options[:json] tokenLimit = options[:tokenLimit].present? ? options[:tokenLimit] : "null" @@ -16,19 +16,19 @@ class SearchStopAreaInput < Formtastic::Inputs::SearchInput var item_localization = function( item){ var localization = item.zip_code + ' ' + item.short_city_name; - return localization; + return localization; }; - var item_format = function( item ){ - var name = item_name( item ); + var item_format = function( item ){ + var name = item_name( item ); var localization = item_localization( item ); - + html_result = '<li>'; html_result += '<span><image src=\"' + item.stop_area_path + '\" height=\"25px\" width=\"25px\"></span>' if(name != '') { - html_result += '<span style=\"height:25px; line-height:25px; margin-left: 5px; \">' + name + '</span>' ; - } + html_result += '<span style=\"height:25px; line-height:25px; margin-left: 5px; \">' + name + '</span>' ; + } if(localization != '') { html_result += '<small style=\"height:25px; line-height:25px; margin-left: 10px; color: #555; \">' + localization + '</small>'; @@ -48,7 +48,7 @@ class SearchStopAreaInput < Formtastic::Inputs::SearchInput noResultsText: '#{options[:no_result_text]}', searchingText: '#{options[:searching_text]}', resultsFormatter: item_format, - tokenFormatter: item_format, + tokenFormatter: item_format, }); });").html_safe) end @@ -62,7 +62,7 @@ class SearchStopAreaInput < Formtastic::Inputs::SearchInput end end - def input_html_options + def input_html_options css_class = super[:class] super.merge({ :required => nil, diff --git a/app/models/chouette/for_alighting_enumerations.rb b/app/models/chouette/for_alighting_enumerations.rb index 4f34927d3..ab07a670d 100644 --- a/app/models/chouette/for_alighting_enumerations.rb +++ b/app/models/chouette/for_alighting_enumerations.rb @@ -2,7 +2,7 @@ module Chouette module ForAlightingEnumerations extend Enumerize extend ActiveModel::Naming - + enumerize :for_alighting, in: %w[normal forbidden request_stop is_flexible] end end diff --git a/app/models/chouette/route.rb b/app/models/chouette/route.rb index 8949a6bc2..446eb5f70 100644 --- a/app/models/chouette/route.rb +++ b/app/models/chouette/route.rb @@ -1,14 +1,17 @@ class Chouette::Route < Chouette::TridentActiveRecord include RouteRestrictions + extend Enumerize + extend ActiveModel::Naming + + enumerize :direction, in: %i(straight_forward backward clockwise counter_clockwise north north_west west south_west south south_east east north_east) + enumerize :wayback, in: %i(straight_forward backward) + # FIXME http://jira.codehaus.org/browse/JRUBY-6358 self.primary_key = "id" - attr_accessor :wayback_code - attr_accessor :direction_code - def self.nullable_attributes - [:published_name, :comment, :number, :name] + [:published_name, :comment, :number, :name, :direction, :wayback] end belongs_to :line @@ -61,8 +64,11 @@ class Chouette::Route < Chouette::TridentActiveRecord # validates_presence_of :name validates_presence_of :line - # validates_presence_of :direction_code - # validates_presence_of :wayback_code + # validates_presence_of :direction + # validates_presence_of :wayback + + validates :direction, inclusion: { in: self.direction.values } + validates :wayback, inclusion: { in: self.wayback.values } before_destroy :dereference_opposite_route @@ -96,52 +102,6 @@ class Chouette::Route < Chouette::TridentActiveRecord .order( "vehicle_journey_at_stops.departure_time") end - def self.direction_binding - { "A" => "straight_forward", - "R" => "backward", - "ClockWise" => "clock_wise", - "CounterClockWise" => "counter_clock_wise", - "North" => "north", - "NorthWest" => "north_west", - "West" => "west", - "SouthWest" => "south_west", - "South" => "south", - "SouthEast" => "south_east", - "East" => "east", - "NorthEast" => "north_east"} - end - def direction_code - return nil if self.class.direction_binding[direction].nil? - Chouette::Direction.new( self.class.direction_binding[direction]) - end - def direction_code=(direction_code) - self.direction = nil - self.class.direction_binding.each do |k,v| - self.direction = k if v==direction_code - end - end - @@directions = nil - def self.directions - @@directions ||= Chouette::Direction.all - end - def self.wayback_binding - { "A" => "straight_forward", "R" => "backward"} - end - def wayback_code - return nil if self.class.wayback_binding[wayback].nil? - Chouette::Wayback.new( self.class.wayback_binding[wayback]) - end - def wayback_code=(wayback_code) - self.wayback = nil - self.class.wayback_binding.each do |k,v| - self.wayback = k if v==wayback_code - end - end - @@waybacks = nil - def self.waybacks - @@waybacks ||= Chouette::Wayback.all - end - def stop_point_permutation?( stop_point_ids) stop_points.map(&:id).map(&:to_s).sort == stop_point_ids.map(&:to_s).sort end diff --git a/app/models/concerns/route_restrictions.rb b/app/models/concerns/route_restrictions.rb index 5a098d86f..4a21cbccf 100644 --- a/app/models/concerns/route_restrictions.rb +++ b/app/models/concerns/route_restrictions.rb @@ -8,7 +8,7 @@ module RouteRestrictions # HUB-37 def wayback_code_limitation return unless hub_restricted? - errors.add( :wayback_code, I18n.t('hub.routes.wayback_code_exclusive')) if line.routes.reject {|r| r.id==id}.map(&:wayback_code).include?( wayback_code) + errors.add( :wayback, I18n.t('hub.routes.wayback_code_exclusive')) if line.routes.reject {|r| r.id==id}.map(&:wayback).include?( wayback) end # HUB-37 diff --git a/app/models/line_referential.rb b/app/models/line_referential.rb index 7d3b638cb..e1f048fd8 100644 --- a/app/models/line_referential.rb +++ b/app/models/line_referential.rb @@ -6,7 +6,7 @@ class LineReferential < ActiveRecord::Base has_many :group_of_lines, class_name: 'Chouette::GroupOfLine' has_many :companies, class_name: 'Chouette::Company' has_many :networks, class_name: 'Chouette::Network' - has_many :line_referential_syncs, -> { order created_at: :desc} + has_many :line_referential_syncs, -> { order created_at: :desc } has_many :workbenches def add_member(organisation, options = {}) diff --git a/app/models/organisation.rb b/app/models/organisation.rb index 86386772c..31443d1c7 100644 --- a/app/models/organisation.rb +++ b/app/models/organisation.rb @@ -39,20 +39,22 @@ class Organisation < ActiveRecord::Base end end + def self.sync_update code, name, scope + org = Organisation.find_or_initialize_by(code: code) + if scope + org.sso_attributes ||= {} + org.sso_attributes[:functional_scope] = scope + end + org.name = name + org.synced_at = Time.now + org.save + org + end + def self.portail_sync self.portail_api_request.each do |el| - Organisation.find_or_create_by(code: el['code']).tap do |org| - org.name = el['name'] - if el['functional_scope'] - org.sso_attributes ||= {} - org.sso_attributes[:functional_scope] = el['functional_scope'].delete('\\"') - end - if org.changed? - org.synced_at = Time.now - org.save - puts "✓ Organisation #{org.name} has been updated" unless Rails.env.test? - end - end + org = self.sync_update el['code'], el['name'], el['functional_scope'] + puts "✓ Organisation #{org.name} has been updated" unless Rails.env.test? end end end diff --git a/app/models/referential.rb b/app/models/referential.rb index afadf5edd..8b8df3294 100644 --- a/app/models/referential.rb +++ b/app/models/referential.rb @@ -30,7 +30,7 @@ class Referential < ActiveRecord::Base validates_presence_of :line_referential belongs_to :created_from, class_name: 'Referential' - has_many :lines, through: :line_referential + has_many :associated_lines, through: :line_referential, source: :lines has_many :companies, through: :line_referential has_many :group_of_lines, through: :line_referential has_many :networks, through: :line_referential @@ -43,6 +43,10 @@ class Referential < ActiveRecord::Base has_many :stop_areas, through: :stop_area_referential belongs_to :workbench + def lines + workbench ? workbench.lines : associated_lines + end + def slug_excluded_values if ! slug.nil? if slug.start_with? "pg_" @@ -128,13 +132,6 @@ class Referential < ActiveRecord::Base }) end - def clone_association from - self.organisation = from.organisation - self.line_referential = from.line_referential - self.stop_area_referential = from.stop_area_referential - self.workbench = from.workbench - end - def self.available_srids [ [ "RGF 93 Lambert 93 (2154)", 2154 ], @@ -171,7 +168,8 @@ class Referential < ActiveRecord::Base projection_type || "" end - before_validation :assign_line_and_stop_area_referential, :on => :create, if: :workbench + before_validation :assign_line_and_stop_area_referential, :on => :create, if: :workbench, unless: :created_from + before_validation :clone_associations, :on => :create, if: :created_from before_create :create_schema after_create :create_referential_metadata, if: :workbench, unless: :created_from @@ -185,6 +183,13 @@ class Referential < ActiveRecord::Base self.referential_metadatas.create end + def clone_associations + self.organisation = created_from.organisation + self.line_referential = created_from.line_referential + self.stop_area_referential = created_from.stop_area_referential + self.workbench = created_from.workbench + end + def clone_referential_metadatas self.created_from.referential_metadatas.each do |meta| self.referential_metadatas << ReferentialMetadata.new_from(meta) diff --git a/app/models/user.rb b/app/models/user.rb index 8f0c32c54..5cfdf0605 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -29,16 +29,10 @@ class User < ActiveRecord::Base after_destroy :check_destroy_organisation def cas_extra_attributes=(extra_attributes) - extra = extra_attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} - self.name = extra[:full_name] - self.email = extra[:email] - - self.organisation = Organisation.find_or_create_by(code: extra[:organisation_code]).tap do |org| - org.name = extra[:organisation_name] - org.sso_attributes ||= {} - org.sso_attributes[:functional_scope] = extra[:functional_scope].delete('\\"') if extra[:functional_scope] - org.synced_at = Time.now - end + extra = extra_attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} + self.name = extra[:full_name] + self.email = extra[:email] + self.organisation = Organisation.sync_update extra[:organisation_code], extra[:organisation_name], extra[:functional_scope] end def self.portail_api_request @@ -60,25 +54,14 @@ class User < ActiveRecord::Base def self.portail_sync self.portail_api_request.each do |el| - User.find_or_create_by(username: el['username']).tap do |user| - user.name = "#{el['firstname']} #{el['lastname']}" - user.email = el['email'] - user.locked_at = el['locked_at'] - - # Set organisation - user.organisation = Organisation.find_or_create_by(code: el['organization_code']).tap do |org| - org.name = el['organization_name'] - org.sso_attributes ||= {} - org.sso_attributes[:functional_scope] = el['functional_scope'].delete('\\"') if el['functional_scope'] - org.synced_at = Time.now - end - - if user.changed? - user.synced_at = Time.now - user.save - puts "✓ user #{user.username} has been updated" unless Rails.env.test? - end - end + user = User.find_or_initialize_by(username: el['username']) + user.name = "#{el['firstname']} #{el['lastname']}" + user.email = el['email'] + user.locked_at = el['locked_at'] + user.organisation = Organisation.sync_update el['organization_code'], el['organization_name'], el['functional_scope'] + user.synced_at = Time.now + user.save + puts "✓ user #{user.username} has been updated" unless Rails.env.test? end end diff --git a/app/models/workbench.rb b/app/models/workbench.rb index 3525fe55e..a83fea70d 100644 --- a/app/models/workbench.rb +++ b/app/models/workbench.rb @@ -3,6 +3,12 @@ class Workbench < ActiveRecord::Base belongs_to :line_referential belongs_to :stop_area_referential + has_many :lines, -> (workbench) { Stif::MyWorkbenchScopes.new(workbench).line_scope(self) }, through: :line_referential + has_many :networks, through: :line_referential + has_many :companies, through: :line_referential + has_many :group_of_lines, through: :line_referential + has_many :stop_areas, through: :stop_area_referential + validates :name, presence: true validates :organisation, presence: true diff --git a/app/views/api/kml/routes/show.kml.slim b/app/views/api/kml/routes/show.kml.slim index 3b08d81ce..51d2817c8 100644 --- a/app/views/api/kml/routes/show.kml.slim +++ b/app/views/api/kml/routes/show.kml.slim @@ -6,11 +6,11 @@ kml xmlns="http://www.opengis.net/kml/2.2" placemark id="#{@route.objectid}" name = h(@route.name) extendeddata - - [:direction_code, :wayback_code, :objectid, :object_version, :creation_time, :creator_id, :name, :comment, :published_name, :number, :direction, :wayback].each do |prop| + - [:direction, :wayback, :objectid, :object_version, :creation_time, :creator_id, :name, :comment, :published_name, :number, :direction_text, :wayback_text].each do |prop| data name="#{prop.to_s}" value = h(@route.send( prop)) data name="line_objectid" value = h(@route.line.objectid) - = @route.geometry_presenter.geometry.kml_representation.html_safe
\ No newline at end of file + = @route.geometry_presenter.geometry.kml_representation.html_safe diff --git a/app/views/footnotes/_footnote_fields.html.slim b/app/views/footnotes/_footnote_fields.html.slim index ab006cfa9..c1944ed2d 100644 --- a/app/views/footnotes/_footnote_fields.html.slim +++ b/app/views/footnotes/_footnote_fields.html.slim @@ -1,4 +1,4 @@ = f.inputs :class => 'nested-fields footnote' do = f.input :code, :wrapper_html => { class: 'col-md-3' } = f.input :label, :wrapper_html => { class: 'col-md-7' } - = link_to_remove_association t('actions.destroy'), f, class: 'col-md-2 remove'
\ No newline at end of file + = link_to_remove_association t('actions.destroy'), f, class: 'col-md-2 remove' diff --git a/app/views/lines/_form.html.slim b/app/views/lines/_form.html.slim index 113a5c46c..ace0c4548 100644 --- a/app/views/lines/_form.html.slim +++ b/app/views/lines/_form.html.slim @@ -19,11 +19,11 @@ .footnotes_block h3 = t("footnotes.index.title") - + #footnotes = form.semantic_fields_for :footnotes do |f| = render "footnotes/footnote_fields", :f => f - + .add_footnote = link_to_add_association t("footnotes.actions.add_footnote"), form, :footnotes , :partial => "footnotes/footnote_fields", :"data-association-insertion-method" => "append", :"data-association-insertion-node" => "div#footnotes", class: 'add' @@ -32,7 +32,7 @@ = form.action :cancel, as: :link javascript: - $(function() { + $(function() { $("#line_group_of_line_tokens").tokenInput("#{name_filter_referential_group_of_lines_path(@line_referential, format: :json)}", { crossDomain: false, prePopulate: $('#group_of_line_tokens').data('pre'), @@ -42,4 +42,4 @@ javascript: noResultsText: "#{I18n.t('no_result_text')}", searchingText: "#{I18n.t('searching_term')}" }); - });
\ No newline at end of file + }); diff --git a/app/views/referential_companies/_company.html.slim b/app/views/referential_companies/_company.html.slim index 06e13764e..e6090540d 100644 --- a/app/views/referential_companies/_company.html.slim +++ b/app/views/referential_companies/_company.html.slim @@ -2,10 +2,12 @@ .panel-heading .panel-title.clearfix span.pull-right - = link_to edit_referential_company_path(@referential, company), class: 'btn btn-default btn-sm' do - span.fa.fa-pencil - = link_to referential_company_path(@referential, company), :method => :delete, :data => {:confirm => t('companies.actions.destroy_confirm')}, class: 'btn btn-danger btn-sm' do - span.fa.fa-trash-o + - if policy(company).update? + = link_to edit_referential_company_path(@referential, company), class: 'btn btn-default btn-sm' do + span.fa.fa-pencil + - if policy(company).destroy? + = link_to referential_company_path(@referential, company), :method => :delete, :data => {:confirm => t('companies.actions.destroy_confirm')}, class: 'btn btn-danger btn-sm' do + span.fa.fa-trash-o h5 = link_to [@referential, company], class: 'preview', title: "#{Chouette::Company.model_name.human.capitalize} #{company.name}" do span.name @@ -13,4 +15,4 @@ .panel-body p = company.human_attribute_name('code') - = company.code
\ No newline at end of file + = company.code diff --git a/app/views/referential_companies/index.html.slim b/app/views/referential_companies/index.html.slim index b32f206ca..6af6d7fc8 100644 --- a/app/views/referential_companies/index.html.slim +++ b/app/views/referential_companies/index.html.slim @@ -19,6 +19,7 @@ - content_for :sidebar do ul.actions - li - = link_to t('companies.actions.new'), new_referential_company_path(@referential), class: 'add' - br
\ No newline at end of file + - if policy(Chouette::Company).create? + li + = link_to t('companies.actions.new'), new_referential_company_path(@referential), class: 'add' + br diff --git a/app/views/referential_companies/show.html.slim b/app/views/referential_companies/show.html.slim index a445dad61..a1a767bbd 100644 --- a/app/views/referential_companies/show.html.slim +++ b/app/views/referential_companies/show.html.slim @@ -44,12 +44,15 @@ - content_for :sidebar do ul.actions - li - = link_to t('companies.actions.new'), new_referential_company_path(@referential), class: 'add' - li - = link_to t('companies.actions.edit'), edit_referential_company_path(@referential, @company), class: 'edit' - li - = link_to t('companies.actions.destroy'), referential_company_path(@referential, @company), :method => :delete, :data => {:confirm => t('companies.actions.destroy_confirm')}, class: 'remove' - br - - = creation_tag(@company)
\ No newline at end of file + - if policy(Chouette::Company).create? + li + = link_to t('companies.actions.new'), new_referential_company_path(@referential), class: 'add' + - if policy(@company).update? + li + = link_to t('companies.actions.edit'), edit_referential_company_path(@referential, @company), class: 'edit' + - if policy(@company).destroy? + li + = link_to t('companies.actions.destroy'), referential_company_path(@referential, @company), :method => :delete, :data => {:confirm => t('companies.actions.destroy_confirm')}, class: 'remove' + br + + = creation_tag(@company) diff --git a/app/views/referential_lines/_line.html.slim b/app/views/referential_lines/_line.html.slim index 0dffb50aa..1c8b8eaa8 100644 --- a/app/views/referential_lines/_line.html.slim +++ b/app/views/referential_lines/_line.html.slim @@ -3,7 +3,7 @@ ul.ce-LineBlock-header-list li = check_box_tag "ids[]", line.id, false, class: "multiple_selection", style: "display: none;" - + - if line.number && line.number.length <= 3 span.label.label-default.line_number style="#{number_style(line)}" = line.number @@ -13,11 +13,11 @@ h5.ce-LineBlock-header-title = truncate(line.name, length: 24) li - - if edit + - if edit && policy(Chouette::Line).update? = link_to edit_referential_line_path(@referential, line), class: 'btn btn-default btn-sm' do span.fa.fa-pencil - - if delete + - if delete && policy(Chouette::Line).destroy? = link_to referential_line_path(@referential, line), method: :delete, data: { confirm: t('lines.actions.destroy_confirm') }, class: 'btn btn-danger btn-sm' do span.fa.fa-trash-o @@ -46,4 +46,4 @@ = line.human_attribute_name('group_of_line') = link_to_if( line.group_of_lines.first, line.group_of_lines.first.name, referential_group_of_line_path(@referential, line.group_of_lines.first), :title => "#{line.human_attribute_name('group_of_line')} #{line.group_of_lines.first.name}") - else - = t('lines.form.several_group_of_lines', :count => line.group_of_lines.count)
\ No newline at end of file + = t('lines.form.several_group_of_lines', :count => line.group_of_lines.count) diff --git a/app/views/referential_lines/index.html.slim b/app/views/referential_lines/index.html.slim index 4922cde85..5647bde0c 100644 --- a/app/views/referential_lines/index.html.slim +++ b/app/views/referential_lines/index.html.slim @@ -24,25 +24,27 @@ - content_for :sidebar do ul.actions - li - = link_to t('lines.actions.new'), new_referential_line_path(@referential), class: 'add' + - if policy(Chouette::Line).create? + li + = link_to t('lines.actions.new'), new_referential_line_path(@referential), class: 'add' - #multiple_selection_menu - h4> = t(".multi_selection") + - if policy(Chouette::Line).destroy? + #multiple_selection_menu + h4> = t(".multi_selection") - .disabled - a.enable href="#" - = t(".multi_selection_enable") + .disabled + a.enable href="#" + = t(".multi_selection_enable") - .enabled style="display: none;" - a.disable href="#" - = t(".multi_selection_disable") + .enabled style="display: none;" + a.disable href="#" + = t(".multi_selection_disable") - ul.actions - = link_to t(".delete_selected"), referential_lines_path(@referential), "data-multiple-method" => "delete", :class => "remove", "confirmation-text" => t("lines.actions.destroy_selection_confirm") + ul.actions + = link_to t(".delete_selected"), referential_lines_path(@referential), "data-multiple-method" => "delete", :class => "remove", "confirmation-text" => t("lines.actions.destroy_selection_confirm") a.select_all href="#" = t(".select_all") = " | " a.deselect_all href="#" - = t(".deselect_all")
\ No newline at end of file + = t(".deselect_all") diff --git a/app/views/referential_lines/show.html.slim b/app/views/referential_lines/show.html.slim index ae8314a14..495f0bda7 100644 --- a/app/views/referential_lines/show.html.slim +++ b/app/views/referential_lines/show.html.slim @@ -121,15 +121,19 @@ h3.routes = t('.itineraries') - content_for :sidebar do ul.actions - li - = link_to t('lines.actions.new'), new_referential_line_path(@referential), class: 'add' - li - = link_to t('lines.actions.edit'), edit_referential_line_path(@referential, @line), class: 'edit' - li - = link_to t('lines.actions.destroy'), referential_line_path(@referential, @line), method: :delete, :data => {:confirm => t('lines.actions.destroy_confirm')}, class: 'remove' + - if policy(Chouette::Line).create? + li + = link_to t('lines.actions.new'), new_referential_line_path(@referential), class: 'add' + - if policy(@line).update? + li + = link_to t('lines.actions.edit'), edit_referential_line_path(@referential, @line), class: 'edit' + - if policy(@line).destroy? + li + = link_to t('lines.actions.destroy'), referential_line_path(@referential, @line), method: :delete, :data => {:confirm => t('lines.actions.destroy_confirm')}, class: 'remove' - if !@line.hub_restricted? || (@line.hub_restricted? && @line.routes.size < 2) - li - = link_to t('routes.actions.new'), new_referential_line_route_path(@referential, @line), class: 'add' + / FIXME #825 + li + / = link_to t('routes.actions.new'), new_referential_line_route_path(@referential, @line), class: 'add' - = creation_tag(@line)
\ No newline at end of file + = creation_tag(@line) diff --git a/app/views/referential_networks/_network.html.slim b/app/views/referential_networks/_network.html.slim index dc1aa6b5c..f7c7b66eb 100644 --- a/app/views/referential_networks/_network.html.slim +++ b/app/views/referential_networks/_network.html.slim @@ -2,13 +2,14 @@ .panel-heading .panel-title.clearfix span.pull-right - = link_to edit_referential_network_path(@referential, network), class: 'btn btn-default btn-sm' do - span.fa.fa-pencil - - = link_to referential_network_path(@referential, network), method: :delete, :data => { :confirm => t('networks.actions.destroy_confirm') }, class: 'btn btn-danger btn-sm' do - span.fa.fa-trash-o + - if policy(network).update? + = link_to edit_referential_network_path(@referential, network), class: 'btn btn-default btn-sm' do + span.fa.fa-pencil + - if policy(network).destroy? + = link_to referential_network_path(@referential, network), method: :delete, :data => { :confirm => t('networks.actions.destroy_confirm') }, class: 'btn btn-danger btn-sm' do + span.fa.fa-trash-o h5 = link_to [@referential, network], class: 'preview', title: "#{Chouette::Network.model_name.human.capitalize} #{network.name}" do span.name - = truncate(network.name, :length => 20)
\ No newline at end of file + = truncate(network.name, :length => 20) diff --git a/app/views/referential_networks/index.html.slim b/app/views/referential_networks/index.html.slim index f3ead931e..e3e9f2a07 100644 --- a/app/views/referential_networks/index.html.slim +++ b/app/views/referential_networks/index.html.slim @@ -19,5 +19,6 @@ - content_for :sidebar do ul.actions li + - if policy(Chouette::Network).create? = link_to t('networks.actions.new'), new_referential_network_path(@referential), class: 'add' - br
\ No newline at end of file + br diff --git a/app/views/referential_networks/show.html.slim b/app/views/referential_networks/show.html.slim index 936f6a4a8..d579d311b 100644 --- a/app/views/referential_networks/show.html.slim +++ b/app/views/referential_networks/show.html.slim @@ -36,12 +36,15 @@ - content_for :sidebar do ul.actions - li - = link_to t('networks.actions.new'), new_referential_network_path(@referential), class: 'add' - li - = link_to t('networks.actions.edit'), edit_referential_network_path(@referential, @network), class: 'edit' - li - = link_to t('networks.actions.destroy'), referential_network_path(@referential, @network), method: :delete, data: { :confirm => t('networks.actions.destroy_confirm')}, class: 'remove' - br - - = creation_tag(@network)
\ No newline at end of file + - if policy(Chouette::Network).create? + li + = link_to t('networks.actions.new'), new_referential_network_path(@referential), class: 'add' + - if policy(@network).update? + li + = link_to t('networks.actions.edit'), edit_referential_network_path(@referential, @network), class: 'edit' + - if policy(@network).destroy? + li + = link_to t('networks.actions.destroy'), referential_network_path(@referential, @network), method: :delete, data: { :confirm => t('networks.actions.destroy_confirm')}, class: 'remove' + br + + = creation_tag(@network) diff --git a/app/views/referential_stop_areas/_genealogical.html.slim b/app/views/referential_stop_areas/_genealogical.html.slim index a44884c92..162c24d9b 100644 --- a/app/views/referential_stop_areas/_genealogical.html.slim +++ b/app/views/referential_stop_areas/_genealogical.html.slim @@ -5,7 +5,7 @@ h3 = genealogical_title = link_to([@referential, @stop_area.parent], :title => t("area_types.label.#{@stop_area.parent.stop_area_type}") + "#{@stop_area.parent.name}") do = image_tag "map/" + @stop_area.parent.stop_area_type + ".png" = @stop_area.parent.name - + .link = image_tag "icons/link.png" @@ -18,7 +18,7 @@ h3 = genealogical_title .link = image_tag "icons/link.png" - else - .no_parent = + .no_parent .target = image_tag "map/" + @stop_area.stop_area_type + ".png" @@ -51,4 +51,4 @@ h3 = genealogical_title span = route.line.number = link_to([@referential, route.line , route]) do - span = route.name
\ No newline at end of file + span = route.name diff --git a/app/views/referential_stop_areas/_stop_area.html.slim b/app/views/referential_stop_areas/_stop_area.html.slim index f94bd319e..bb9ed7ce3 100644 --- a/app/views/referential_stop_areas/_stop_area.html.slim +++ b/app/views/referential_stop_areas/_stop_area.html.slim @@ -2,11 +2,13 @@ .panel-heading .panel-title.clearfix span.pull-right - = link_to edit_referential_stop_area_path(@referential, stop_area), class: 'btn btn-default btn-sm' do - span.fa.fa-pencil + - if policy(stop_area).update? + = link_to edit_referential_stop_area_path(@referential, stop_area), class: 'btn btn-default btn-sm' do + span.fa.fa-pencil - = link_to referential_stop_area_path(@referential, stop_area), method: :delete, :data => {:confirm => t('stop_areas.actions.destroy_confirm')}, class: 'btn btn-danger btn-sm' do - span.fa.fa-trash-o + - if policy(stop_area).destroy? + = link_to referential_stop_area_path(@referential, stop_area), method: :delete, :data => {:confirm => t('stop_areas.actions.destroy_confirm')}, class: 'btn btn-danger btn-sm' do + span.fa.fa-trash-o h5 = link_to([@referential, stop_area], class: "preview", :title => t("area_types.label.#{stop_area.stop_area_type}") + " #{stop_area.name}") do @@ -34,11 +36,11 @@ - else - stop_area.routing_lines.each do |line| span.label.label-default.line = line.number - + - else = "#{t('.lines')} : " - if stop_area.lines.blank? = t(".no_object") - else - stop_area.lines.each do |line| - span.label.label-default.line = line.number || truncate( line.name, length: 4 )
\ No newline at end of file + span.label.label-default.line = line.number || truncate( line.name, length: 4 ) diff --git a/app/views/referential_stop_areas/index.html.slim b/app/views/referential_stop_areas/index.html.slim index 85bd15d20..1b634b09c 100644 --- a/app/views/referential_stop_areas/index.html.slim +++ b/app/views/referential_stop_areas/index.html.slim @@ -26,7 +26,8 @@ - content_for :sidebar do ul.actions + - if policy(Chouette::StopArea).create? + li + = link_to t('stop_areas.actions.new'), new_referential_stop_area_path(@referential), class: 'add' li - = link_to t('stop_areas.actions.new'), new_referential_stop_area_path(@referential), class: 'add' - li - / = link_to t('stop_areas.actions.default_geometry'), default_geometry_referential_stop_areas_path(@referential), :method => :put, :class => "calculator"
\ No newline at end of file + / = link_to t('stop_areas.actions.default_geometry'), default_geometry_referential_stop_areas_path(@referential), :method => :put, :class => "calculator" diff --git a/app/views/referential_stop_areas/show.html.slim b/app/views/referential_stop_areas/show.html.slim index 76414edf0..2278c4812 100644 --- a/app/views/referential_stop_areas/show.html.slim +++ b/app/views/referential_stop_areas/show.html.slim @@ -109,7 +109,7 @@ p.after_map .genealogical.clearfix - = render "stop_areas/genealogical" + = render "referential_stop_areas/genealogical" - if manage_access_points div @@ -122,22 +122,25 @@ p.after_map tr td ul.actions - li - = link_to t('stop_areas.actions.new'), new_referential_stop_area_path(@referential), class: 'add' - li - = link_to t('stop_areas.actions.edit'), edit_referential_stop_area_path(@referential, @stop_area), class: 'edit' - li - = link_to t('stop_areas.actions.destroy'), referential_stop_area_path(@referential, @stop_area), method: :delete, data: { :confirm => t('stop_areas.actions.destroy_confirm') }, class: 'remove' + - if policy(Chouette::StopArea).new? + li + = link_to t('stop_areas.actions.new'), new_referential_stop_area_path(@referential), class: 'add' + - if policy(@stop_area).update? + li + = link_to t('stop_areas.actions.edit'), edit_referential_stop_area_path(@referential, @stop_area), class: 'edit' + - if policy(@stop_area).destroy? + li + = link_to t('stop_areas.actions.destroy'), referential_stop_area_path(@referential, @stop_area), method: :delete, data: { :confirm => t('stop_areas.actions.destroy_confirm') }, class: 'remove' - if manage_itl - tr - td - h4 = t('.itl_managment') - ul.actions - li - = link_to t('stop_areas.actions.add_routing_lines'), add_routing_lines_referential_stop_area_path(@referential, @stop_area), class: 'add_routing_lines' - li - = link_to t('stop_areas.actions.add_routing_stops'), add_routing_stops_referential_stop_area_path(@referential, @stop_area), class: 'add_routing_stops' + / tr + / td + / h4 = t('.itl_managment') + / ul.actions + / li + / = link_to t('stop_areas.actions.add_routing_lines'), add_routing_lines_referential_stop_area_path(@referential, @stop_area), class: 'add_routing_lines' + / li + / = link_to t('stop_areas.actions.add_routing_stops'), add_routing_stops_referential_stop_area_path(@referential, @stop_area), class: 'add_routing_stops' - else tr @@ -145,17 +148,17 @@ p.after_map h4 = t('.stop_managment') ul.actions li - = link_to t('stop_areas.actions.select_parent'), select_parent_referential_stop_area_path(@referential, @stop_area), class: 'parent' + / = link_to t('stop_areas.actions.select_parent'), select_parent_referential_stop_area_path(@referential, @stop_area), class: 'parent' - if @stop_area.parent == nil li - = link_to t('stop_areas.actions.clone_as_parent'), new_referential_stop_area_stop_area_copy_path(@referential, @stop_area, hierarchy: 'parent'), class: 'clone' + / = link_to t('stop_areas.actions.clone_as_parent'), new_referential_stop_area_stop_area_copy_path(@referential, @stop_area, hierarchy: 'parent'), class: 'clone' - if manage_children li - = link_to t('stop_areas.actions.add_children'), add_children_referential_stop_area_path(@referential, @stop_area), class: 'children' + / = link_to t('stop_areas.actions.add_children'), add_children_referential_stop_area_path(@referential, @stop_area), class: 'children' li - = link_to t('stop_areas.actions.clone_as_child'), new_referential_stop_area_stop_area_copy_path(@referential, @stop_area, hierarchy: 'child'), class: 'clone' + / = link_to t('stop_areas.actions.clone_as_child'), new_referential_stop_area_stop_area_copy_path(@referential, @stop_area, hierarchy: 'child'), class: 'clone' - if manage_access_points tr @@ -163,9 +166,9 @@ p.after_map h4 = t(".access_managment") ul.actions li - = link_to t('access_points.actions.new'), new_referential_stop_area_access_point_path(@referential,@stop_area), class: 'add' + / = link_to t('access_points.actions.new'), new_referential_stop_area_access_point_path(@referential,@stop_area), class: 'add' li - = link_to t('stop_areas.actions.manage_access_links'), access_links_referential_stop_area_path(@referential,@stop_area), class: 'access_link' + / = link_to t('stop_areas.actions.manage_access_links'), access_links_referential_stop_area_path(@referential,@stop_area), class: 'access_link' br diff --git a/app/views/referentials/_counts.html.slim b/app/views/referentials/_counts.html.slim index fc3ad251e..9754ebc99 100644 --- a/app/views/referentials/_counts.html.slim +++ b/app/views/referentials/_counts.html.slim @@ -67,4 +67,4 @@ li.list-group-item span.badge = @referential.access_points.size = image_tag "map/access_in_out.png" - = Referential.human_attribute_name("access_points")
\ No newline at end of file + = Referential.human_attribute_name("access_points") diff --git a/app/views/referentials/index.html.slim b/app/views/referentials/index.html.slim index e37f157de..c03943ac7 100644 --- a/app/views/referentials/index.html.slim +++ b/app/views/referentials/index.html.slim @@ -14,12 +14,3 @@ / FIXME #823 - if false li = link_to t('referentials.actions.new'), new_referential_path, class: 'add' - - ul - / FIXME #820 - / Don't blame me. See #820 - li = link_to 'Données Reflex', stop_area_referential_path(1) - - / FIXME #824 - / Don't blame me. See #824 - li = link_to 'Données CodifLigne', line_referential_path(1) diff --git a/app/views/referentials/show.html.slim b/app/views/referentials/show.html.slim index d5fed0344..1fc8f108f 100644 --- a/app/views/referentials/show.html.slim +++ b/app/views/referentials/show.html.slim @@ -44,7 +44,7 @@ h2 - if @referential.api_keys.present? h3.api_keys = t('.api_keys') - + .api_keys.paginated_content = paginated_content(@referential.api_keys, "api_keys/api_key") @@ -66,8 +66,9 @@ h2 li = link_to t('referentials.actions.destroy'), referential_path(@referential), method: :delete, data: {:confirm => t('referentials.actions.destroy_confirm')}, class: "remove" li = link_to t('api_keys.actions.new'), new_referential_api_key_path(@referential), class: 'add' + li = link_to t('referentials.actions.clone'), new_referential_path(from: @referential.id), class: 'add' br h4 = t('.clean_up') - == render 'clean'
\ No newline at end of file + == render 'clean' diff --git a/app/views/routes/_form.html.slim b/app/views/routes/_form.html.slim index cb22e3a70..1005b7046 100644 --- a/app/views/routes/_form.html.slim +++ b/app/views/routes/_form.html.slim @@ -6,36 +6,36 @@ = f.input :published_name .col-lg-4.col-md-4.col-sm-4.col-xs-4 = f.input :number - + .row .col-lg-6.col-md-6.col-sm-5.col-xs-5 = f.input :comment .col-lg-6.col-md-6.col-sm-7.col-xs-7 = f.input :opposite_route, collection: @line.routes.select { |r| r.id != @route.id } - + .row .col-lg-4.col-md-4.col-sm-4.col-xs-4 - = f.input :direction_code, collection: Chouette::Route.directions, include_blank: false, member_label: Proc.new { |mode| t("directions.label.#{mode}") } + = f.input :direction, include_blank: false .col-lg-4.col-md-4.col-sm-4.col-xs-4 - = f.input :wayback_code, collection: Chouette::Route.waybacks, include_blank: false, member_label: Proc.new { |mode| t("waybacks.label.#{mode}") } + = f.input :wayback, include_blank: false .col-lg-4.col-md-4.col-sm-4.col-xs-4 = f.input :objectid, required: !@route.new_record?, input_html: { title: t("formtastic.titles#{format_restriction_for_locales(@referential)}.route.objectid") } - + .row style="margin-top:20px" .col-lg-12.col-md-12.col-sm-12.col-xs-12 #stop_points - / div.clearfix style="margin-bottom:5px" - / label style="margin:0" Arrêts - / .btn.btn-primary.btn-xs.pull-right data-event="add_stop_point" - / span.fa.fa-plus - / = " #{t('routes.actions.add_stop_point')}" - - / = link_to_add_association f, :stop_points, class: 'btn btn-primary btn-xs pull-right' do - / span.fa.fa-plus - / = " #{t('routes.actions.add_stop_point')}" - / THIS IS BROKEN - / = link_to t('routes.actions.new_stop_point'), new_referential_stop_area_path(@referential), target: '_blank' - + / div.clearfix style="margin-bottom:5px" + / label style="margin:0" Arrêts + / .btn.btn-primary.btn-xs.pull-right data-event="add_stop_point" + / span.fa.fa-plus + / = " #{t('routes.actions.add_stop_point')}" + / + / = link_to_add_association f, :stop_points, class: 'btn btn-primary btn-xs pull-right' do + / span.fa.fa-plus + / = " #{t('routes.actions.add_stop_point')}" + / THIS IS BROKEN + / = link_to t('routes.actions.new_stop_point'), new_referential_stop_area_path(@referential), target: '_blank' + / / .list-group / = f.simple_fields_for :stop_points do |point| / = render 'stop_point_fields', f: point diff --git a/app/views/routes/_route.html.slim b/app/views/routes/_route.html.slim index fd740fa9b..5a377761f 100644 --- a/app/views/routes/_route.html.slim +++ b/app/views/routes/_route.html.slim @@ -11,9 +11,9 @@ h5 = link_to [@referential, @line, route], class: 'preview', title: "#{Chouette::Route.model_name.human.capitalize} #{route.name}" do span.name - - if route.wayback_code + - if route.wayback = fonticon_wayback(route.wayback) - + = truncate(route.name, length: 20) .panel-body @@ -38,6 +38,6 @@ p - if !route.direction.blank? - = "#{route.human_attribute_name('direction_code')} : #{t('directions.label.'+route.direction_code)}" + => "#{route.human_attribute_name('direction')} : #{route.direction_text}" - else - br
\ No newline at end of file + br diff --git a/app/views/routes/show.html.slim b/app/views/routes/show.html.slim index 2b0b46cd3..26cf2f33f 100644 --- a/app/views/routes/show.html.slim +++ b/app/views/routes/show.html.slim @@ -21,16 +21,16 @@ = @route.comment p - label = "#{@route.human_attribute_name(:direction_code)} : " - - if @route.direction_code - = t("directions.label.#{@route.direction_code}").capitalize + label = "#{@route.human_attribute_name(:direction)} : " + - if @route.direction + = @route.direction_text - else = t(".undefined") p - label = "#{@route.human_attribute_name(:wayback_code)} : " - - if @route.wayback_code - = t("waybacks.label.#{@route.wayback_code}").capitalize + label = "#{@route.human_attribute_name(:wayback)} : " + - if @route.wayback + = @route.wayback_text - else = t(".undefined") @@ -74,10 +74,10 @@ h3 = t('.stop_points') ul.actions - if @route.stop_points.size >= 2 li = link_to t('journey_patterns.actions.new'), new_referential_line_route_journey_pattern_path(@referential, @line, @route), class: 'add' - + - if @route.stop_points.present? li = link_to t('routes.actions.edit_boarding_alighting'), edit_boarding_alighting_referential_line_route_path(@referential, @line, @route), class: 'edit' - + - if @route.journey_patterns.size > 0 li = link_to t('vehicle_journeys.actions.index'), [@referential, @line, @route, :vehicle_journeys], class: 'clock' diff --git a/app/views/shared/_header.html.slim b/app/views/shared/_header.html.slim index 33f563075..73e705e35 100644 --- a/app/views/shared/_header.html.slim +++ b/app/views/shared/_header.html.slim @@ -85,12 +85,12 @@ nav.navbar.navbar-default.navbar-fixed-top role="navigation" = link_to referential_route_sections_path(@referential) do span.badge.pull-right = @referential.route_sections.size = Referential.human_attribute_name("route_sections") - + li = link_to referential_timebands_path(@referential) do span.badge.pull-right = @referential.timebands.size = Referential.human_attribute_name("timebands") - + li = link_to Referential.human_attribute_name("imports"), referential_imports_path(@referential) li diff --git a/config/deploy.rb b/config/deploy.rb index cd6391ec3..34d1b6e4d 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -23,6 +23,11 @@ ssh_options[:forward_agent] = true require "bundler/capistrano" require 'whenever/capistrano' +require 'capistrano/npm' +set :npm_options, '--production --silent --no-progress' + +after 'deploy:finalize_update', 'npm:install' + # Whenever set :whenever_variables, ->{ "'environment=#{fetch :whenever_environment}&bundle_command=bin/bundle exec&additionnal_path=/var/lib/gems/2.2.0/bin'" } # invoke bin/bundle to use 'correct' ruby environment diff --git a/config/locales/directions.en.yml b/config/locales/directions.en.yml index 575ffe90d..05bc29da3 100644 --- a/config/locales/directions.en.yml +++ b/config/locales/directions.en.yml @@ -3,7 +3,7 @@ en: label: straight_forward: "straight forward" backward: "backward" - clock_wise: "clockwise" + clockwise: "clockwise" counter_clock_wise: "counterclockwise" north: "north" north_west: "north west" diff --git a/config/locales/enumerize.en.yml b/config/locales/enumerize.en.yml index 99e2edb75..aab0bcf32 100644 --- a/config/locales/enumerize.en.yml +++ b/config/locales/enumerize.en.yml @@ -33,3 +33,20 @@ en: netex: "Experimental" hub: "Specific Transdev Format" kml: "line, route, ... drawings on Keyhole Markup Language format" + route: + direction: + straight_forward: 'Straight Forward' + backward: 'Backward' + clockwise: 'ClockWise' + counter_clockwise: 'Counter Clockwise' + north: 'North' + north_west: 'North West' + west: 'West' + south_west: 'South West' + south: 'South' + south_east: 'South East' + east: 'East' + north_east: 'North East' + wayback: + straight_forward: 'Straight Forward' + backward: 'Backward' diff --git a/config/locales/enumerize.fr.yml b/config/locales/enumerize.fr.yml index 4bfd71d28..b800521e3 100644 --- a/config/locales/enumerize.fr.yml +++ b/config/locales/enumerize.fr.yml @@ -1,6 +1,6 @@ fr: - simple_form: - include_blanks: + simple_form: + include_blanks: defaults: for_boarding: "Non défini" for_alighting: "Non défini" @@ -9,7 +9,7 @@ fr: normal: "Montée autorisée" forbidden: "Montée interdite" request_stop: "Montée sur demande au conducteur" - is_flexible: "Montée sur réservation" + is_flexible: "Montée sur réservation" for_alighting: normal: "Descente autorisée" forbidden: "Descente interdite" @@ -32,4 +32,21 @@ fr: gtfs: "General Transit Feed Specification défini par Google" netex: "Expérimental" hub: "Format spécifique Transdev" - kml: "Tracés de lignes, séquences d'arrêts, ... en 'Keyhole Markup Language'" + kml: "Tracés de lignes, séquences d'arrêts, ... en 'Keyhole Markup Language'" + route: + direction: + straight_forward: 'Aller' + backward: 'Retour' + clockwise: 'Sens horaire' + counter_clockwise: 'Sens anti horaire' + north: 'Nord' + north_west: 'Nord Ouest' + west: 'Ouest' + south_west: 'Sud Ouest' + south: 'Sud' + south_east: 'Sud Est' + east: 'Est' + north_east: 'Nord Est' + wayback: + straight_forward: 'Aller' + backward: 'Retour' diff --git a/config/locales/referentials.en.yml b/config/locales/referentials.en.yml index 3691a8227..4609069c7 100644 --- a/config/locales/referentials.en.yml +++ b/config/locales/referentials.en.yml @@ -24,6 +24,7 @@ en: destroy_confirm: "Do you confirm to destroy this data space ?" destroy: "Destroy this data space" edit: "Edit this data space" + clone: "Clone this data space" errors: pg_excluded: "can't begins with pg_" public_excluded: "public is a reserved value" @@ -81,4 +82,4 @@ en: notice: referential: archived: "The data space has been successfully archived" - unarchived: "The data space has been successfully unarchived"
\ No newline at end of file + unarchived: "The data space has been successfully unarchived" diff --git a/config/locales/referentials.fr.yml b/config/locales/referentials.fr.yml index cada9c3a0..18ef4e8da 100644 --- a/config/locales/referentials.fr.yml +++ b/config/locales/referentials.fr.yml @@ -24,6 +24,7 @@ fr: destroy_confirm: "Etes vous sûr de vouloir supprimer cet espace de données ?" destroy: "Supprimer cet espace de données" edit: "Modifier cet espace de données" + clone: "Cloner cet espace de données" errors: pg_excluded: "ne peut pas commencer par pg_ (valeurs réservées)" public_excluded: "public est une valeur réservée" diff --git a/config/locales/routes.en.yml b/config/locales/routes.en.yml index a3a26cb8c..b78feff0f 100644 --- a/config/locales/routes.en.yml +++ b/config/locales/routes.en.yml @@ -18,8 +18,8 @@ en: title: "Update route %{route}" show: title: "Route %{route}" - stop_points: "Stop point on route list" - journey_patterns: "Route journey patterns list" + stop_points: "Stop point on route list" + journey_patterns: "Route journey patterns list" no_opposite_route: "No reversed route associated" undefined: "Undefined" index: @@ -33,37 +33,37 @@ en: for_alighting: "Alighting" route: no_journey_pattern: "No Journey pattern" - wayback: + wayback: positive: "forward" negative: "backward" opposite: "Opposite route" no_opposite: "No opposite route" - activerecord: - models: - route: + activerecord: + models: + route: zero: "route" one: "route" other: "routes" attributes: route: - wayback: + wayback: positive: "forward" negative: "backward" line: "Line" vehicle_journeys: "Vehicle journeys" journey_patterns: "Journey patterns" name: "Name" - published_name: "Published name" + published_name: "Published name" comment: "Comments" number: "Number" - direction_code: "Direction" - wayback_code: "Wayback" + direction: "Direction" + wayback: "Wayback" opposite_route: "Reversed route" objectid: "Neptune identifier" object_version: "Version" creation_time: "Created on" creator_id: "Created by" - no_journey_pattern: "No journey pattern" + no_journey_pattern: "No journey pattern" formtastic: titles: route: diff --git a/config/locales/routes.fr.yml b/config/locales/routes.fr.yml index ea190e6e2..f80693b8b 100644 --- a/config/locales/routes.fr.yml +++ b/config/locales/routes.fr.yml @@ -56,8 +56,8 @@ fr: published_name: "Nom public" number: "Indice" comment: "Commentaire" - direction_code: "Direction" - wayback_code: "Sens" + direction: "Direction" + wayback: "Sens" opposite_route: "Séquence d'arrêts associée en sens opposé" objectid: "Identifiant Neptune" object_version: "Version" diff --git a/lib/stif/my_workbench_scopes.rb b/lib/stif/my_workbench_scopes.rb new file mode 100644 index 000000000..89c4e659c --- /dev/null +++ b/lib/stif/my_workbench_scopes.rb @@ -0,0 +1,23 @@ +module Stif + class MyWorkbenchScopes + attr_accessor :workbench + + def initialize(workbench) + @workbench = workbench + end + + def line_scope(initial_scope) + ids = self.parse_functional_scope + ids ? initial_scope.where(objectid: ids) : initial_scope + end + + def parse_functional_scope + return false unless @workbench.organisation.sso_attributes + begin + JSON.parse @workbench.organisation.sso_attributes['functional_scope'] + rescue Exception => e + Rails.logger.error "MyWorkbenchScopes : #{e}" + end + end + end +end diff --git a/lib/tasks/ci.rake b/lib/tasks/ci.rake index 7fca878b6..2b584c08b 100644 --- a/lib/tasks/ci.rake +++ b/lib/tasks/ci.rake @@ -3,6 +3,7 @@ namespace :ci do task :setup do cp "config/database/jenkins.yml", "config/database.yml" sh "RAILS_ENV=test rake db:migrate" + sh "npm install" end def git_branch diff --git a/spec/factories/chouette_routes.rb b/spec/factories/chouette_routes.rb index 047c35912..e872d24f5 100644 --- a/spec/factories/chouette_routes.rb +++ b/spec/factories/chouette_routes.rb @@ -4,23 +4,23 @@ FactoryGirl.define do sequence(:name) { |n| "Route #{n}" } sequence(:published_name) { |n| "Long route #{n}" } sequence(:number) { |n| "#{n}" } - sequence(:wayback_code) { |n| Chouette::Wayback.new( n % 2) } - sequence(:direction_code) { |n| Chouette::Direction.new( n % 12) } + sequence(:wayback) { |n| Chouette::Route.wayback.values[n % 2] } + sequence(:direction) { |n| Chouette::Route.direction.values[n % 12] } sequence(:objectid) { |n| "test:Route:#{n}" } - + association :line, :factory => :line - + factory :route do transient do stop_points_count 5 end - + after(:create) do |route, evaluator| create_list(:stop_point, evaluator.stop_points_count, route: route) end - + end end - + end diff --git a/spec/features/access_points_spec.rb b/spec/features/access_points_spec.rb index a78545ee4..327c5879a 100644 --- a/spec/features/access_points_spec.rb +++ b/spec/features/access_points_spec.rb @@ -40,24 +40,25 @@ describe "Access points", :type => :feature do end - describe "new" do - it "creates an access point" do - visit referential_stop_area_path(referential, stop_area) - click_link I18n.t("access_points.actions.new") - fill_in "access_point[name]", :with => "My Access Point Name" - click_button(I18n.t('formtastic.create',model: I18n.t('activerecord.models.access_point.one'))) - expect(page).to have_content("My Access Point Name") - end - end + # Fixme #1780 + # describe "new" do + # it "creates an access point" do + # visit referential_stop_area_path(referential, stop_area) + # click_link I18n.t("access_points.actions.new") + # fill_in "access_point[name]", :with => "My Access Point Name" + # click_button(I18n.t('formtastic.create',model: I18n.t('activerecord.models.access_point.one'))) + # expect(page).to have_content("My Access Point Name") + # end + # end - describe "edit" do - it "edits an acess point" do - visit referential_stop_area_access_point_path(referential, stop_area, subject) - click_link I18n.t("access_points.actions.edit") - fill_in "access_point[name]", :with => "My New Access Point Name" - click_button(I18n.t('formtastic.update',model: I18n.t('activerecord.models.access_point.one'))) - expect(page).to have_content("My New Access Point Name") - end - end + # describe "edit" do + # it "edits an acess point" do + # visit referential_stop_area_access_point_path(referential, stop_area, subject) + # click_link I18n.t("access_points.actions.edit") + # fill_in "access_point[name]", :with => "My New Access Point Name" + # click_button(I18n.t('formtastic.update',model: I18n.t('activerecord.models.access_point.one'))) + # expect(page).to have_content("My New Access Point Name") + # end + # end end diff --git a/spec/features/routes_spec.rb b/spec/features/routes_spec.rb index c50ff50bc..70f3448ab 100644 --- a/spec/features/routes_spec.rb +++ b/spec/features/routes_spec.rb @@ -34,46 +34,13 @@ describe "Routes", :type => :feature do click_link "Ajouter une séquence d'arrêts" fill_in "route_name", :with => "A to B" fill_in "Indice", :with => "AB" - select 'aller', :from => "route_direction_code" - select 'aller', :from => "route_wayback_code" + select 'Aller', :from => "route_direction" + select 'Aller', :from => "route_wayback" click_button("Créer séquence d'arrêts") expect(page).to have_content("A to B") end end - describe "from line's page, select a route and edit it" do - it "return to line's page with changed name" do - visit referential_line_path(referential,line) - click_link "#{route.name}" - click_link "Modifier cette séquence d'arrêts" - fill_in "route_name", :with => "#{route.name}-changed" - click_button("Modifier séquence d'arrêts") - expect(page).to have_content("#{route.name}-changed") - end - end - - describe "from line's page, select a route and delete it" do - it "return to line's page without route name" do - visit referential_line_path(referential,line) - click_link "#{route.name}" - click_link "Supprimer cette séquence d'arrêts" - expect(page).not_to have_content(route.name) - end - end - - describe "from route's page, select edit boarding/alighting and update it" do - it "Edits boarding/alighting properties on route stops" do - visit referential_line_route_path(referential, line, route) - click_link I18n.t('routes.actions.edit_boarding_alighting') - expect(page).to have_content(I18n.t('routes.edit_boarding_alighting.title')) - stop_points.each do |sp| - expect(page).to have_content(sp.stop_area.name) - expect(page).to have_content(sp.for_boarding) - expect(page).to have_content(sp.for_alighting) - end - end - end - describe "Modifies boarding/alighting properties on route stops" do it "Puts (http) an update request" do #visit edit_boarding_alighting_referential_line_route_path(referential, line, route) diff --git a/spec/models/chouette/route_spec.rb b/spec/models/chouette/route_spec.rb index 1acc5a0f7..0392485d8 100644 --- a/spec/models/chouette/route_spec.rb +++ b/spec/models/chouette/route_spec.rb @@ -3,17 +3,21 @@ require 'spec_helper' describe Chouette::Route, :type => :model do subject { create(:route) } - it { is_expected.to validate_uniqueness_of :objectid } - describe '#objectid' do subject { super().objectid } it { is_expected.to be_kind_of(Chouette::ObjectId) } end + it { is_expected.to enumerize(:direction).in(:straight_forward, :backward, :clockwise, :counter_clockwise, :north, :north_west, :west, :south_west, :south, :south_east, :east, :north_east) } + it { is_expected.to enumerize(:wayback).in(:straight_forward, :backward) } + #it { is_expected.to validate_presence_of :name } it { is_expected.to validate_presence_of :line } + it { is_expected.to validate_uniqueness_of :objectid } #it { is_expected.to validate_presence_of :wayback_code } #it { is_expected.to validate_presence_of :direction_code } + it { is_expected.to validate_inclusion_of(:direction).in_array(%i(straight_forward backward clockwise counter_clockwise north north_west west south_west south south_east east north_east)) } + it { is_expected.to validate_inclusion_of(:wayback).in_array(%i(straight_forward backward)) } context "reordering methods" do let( :bad_stop_point_ids){subject.stop_points.map { |sp| sp.id + 1}} @@ -165,74 +169,4 @@ describe Chouette::Route, :type => :model do end end end - - describe "#direction_code" do - def self.legacy_directions - %w{A R ClockWise CounterClockWise North NorthWest West SouthWest - South SouthEast East NorthEast} - end - legacy_directions.each do |direction| - context "when direction is #{direction}" do - direction_code = Chouette::Direction.new( Chouette::Route.direction_binding[ direction]) - it "should be #{direction_code}" do - subject.direction = direction - expect(subject.direction_code).to eq(direction_code) - end - end - end - context "when direction is nil" do - it "should be nil" do - subject.direction = nil - expect(subject.direction_code).to be_nil - end - end - end - describe "#direction_code=" do - context "when unknown direction is provided" do - it "should change direction to nil" do - subject.direction_code = "dummy" - expect(subject.direction).to be_nil - end - end - context "when an existing direction (west) is provided" do - it "should change direction Direction.west" do - subject.direction_code = "west" - expect(subject.direction).to eq("West") - end - end - end - describe "#wayback_code" do - def self.legacy_waybacks - %w{A R} - end - legacy_waybacks.each do |wayback| - context "when wayback is #{wayback}" do - wayback_code = Chouette::Wayback.new( Chouette::Route.wayback_binding[ wayback]) - it "should be #{wayback_code}" do - subject.wayback = wayback - expect(subject.wayback_code).to eq(wayback_code) - end - end - end - context "when wayback is nil" do - it "should be nil" do - subject.wayback = nil - expect(subject.wayback_code).to be_nil - end - end - end - describe "#wayback_code=" do - context "when unknown wayback is provided" do - it "should change wayback to nil" do - subject.wayback_code = "dummy" - expect(subject.wayback).to be_nil - end - end - context "when an existing wayback (straight_forward) is provided" do - it "should change wayback Wayback.straight_forward" do - subject.wayback_code = "straight_forward" - expect(subject.wayback).to eq("A") - end - end - end end diff --git a/spec/models/organisation_spec.rb b/spec/models/organisation_spec.rb index c0aba2eb8..823ee7ea6 100644 --- a/spec/models/organisation_spec.rb +++ b/spec/models/organisation_spec.rb @@ -36,7 +36,7 @@ describe Organisation, :type => :model do it 'should retrieve functional scope' do Organisation.portail_sync org = Organisation.find_by(code: 'RATP') - expect(org.sso_attributes['functional_scope']).to eq "[STIF:CODIFLIGNE:Line:C00840, STIF:CODIFLIGNE:Line:C00086]" + expect(org.sso_attributes['functional_scope']).to eq "[\"STIF:CODIFLIGNE:Line:C00840\", \"STIF:CODIFLIGNE:Line:C00086\"]" end it 'should update existing organisations' do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index c20e80ca1..bb43be63e 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -36,7 +36,7 @@ describe User, :type => :model do it 'should store organisation functional_scope' do User.authenticate_with_cas_ticket(ticket) org = Organisation.find_by(code: ticket.extra_attributes[:organisation_code]) - expect(org.sso_attributes['functional_scope']).to eq "[STIF:CODIFLIGNE:Line:C00840, STIF:CODIFLIGNE:Line:C00086]" + expect(org.sso_attributes['functional_scope']).to eq "[\"STIF:CODIFLIGNE:Line:C00840\", \"STIF:CODIFLIGNE:Line:C00086\"]" end it 'should not create a new organisation if organisation is already present' do diff --git a/spec/models/workbench_spec.rb b/spec/models/workbench_spec.rb index 023a65ea2..84149ddb0 100644 --- a/spec/models/workbench_spec.rb +++ b/spec/models/workbench_spec.rb @@ -1,7 +1,6 @@ require 'rails_helper' RSpec.describe Workbench, :type => :model do - it 'should have a valid factory' do expect(FactoryGirl.build(:workbench)).to be_valid end @@ -12,4 +11,26 @@ RSpec.describe Workbench, :type => :model do it { should belong_to(:organisation) } it { should belong_to(:line_referential) } it { should belong_to(:stop_area_referential) } + + it { should have_many(:lines).through(:line_referential) } + it { should have_many(:networks).through(:line_referential) } + it { should have_many(:companies).through(:line_referential) } + it { should have_many(:group_of_lines).through(:line_referential) } + + it { should have_many(:stop_areas).through(:stop_area_referential) } + + context '.lines' do + let!(:ids) { ['STIF:CODIFLIGNE:Line:C00840', 'STIF:CODIFLIGNE:Line:C00086'] } + let!(:organisation) { create :organisation, sso_attributes: { functional_scope: ids.to_json } } + let(:workbench) { create :workbench, organisation: organisation } + + it 'should filter lines based on my organisation functional_scope' do + ids.insert('STIF:CODIFLIGNE:Line:0000').each do |id| + create :line, objectid: id, line_referential: workbench.line_referential + end + lines = workbench.lines + expect(lines.count).to eq 2 + expect(lines.map(&:objectid)).to include(*ids) + end + end end |
