From bec1e722f1f4dadc34db6984ccfe7155d6c95ed5 Mon Sep 17 00:00:00 2001 From: Luc Donnet Date: Sat, 19 Nov 2016 18:05:29 +0100 Subject: Fix transport mode display in both views referential_lines and lines Refs #1974 --- app/models/chouette/line.rb | 2 - app/views/lines/show.html.slim | 126 ++++++++++++++--------------- app/views/referential_lines/show.html.slim | 23 +++--- config/locales/enumerize.en.yml | 38 ++++++++- config/locales/enumerize.fr.yml | 38 ++++++++- config/locales/lines.en.yml | 1 + config/locales/lines.fr.yml | 1 + lib/stif/codif_line_synchronization.rb | 2 +- 8 files changed, 145 insertions(+), 86 deletions(-) diff --git a/app/models/chouette/line.rb b/app/models/chouette/line.rb index 9b18f0ffb..80b901bd4 100644 --- a/app/models/chouette/line.rb +++ b/app/models/chouette/line.rb @@ -24,7 +24,6 @@ class Chouette::Line < Chouette::ActiveRecord accepts_nested_attributes_for :footnotes, :reject_if => :all_blank, :allow_destroy => true attr_reader :group_of_line_tokens - attr_accessor :transport_mode # validates_presence_of :network # validates_presence_of :company @@ -36,7 +35,6 @@ class Chouette::Line < Chouette::ActiveRecord validates_format_of :text_color, :with => %r{\A[0-9a-fA-F]{6}\Z}, :allow_nil => true, :allow_blank => true validates_presence_of :name - validates :transport_mode, inclusion: { in: self.transport_mode.values } scope :by_text, ->(text) { where('lower(name) LIKE :t or lower(published_name) LIKE :t or lower(objectid) LIKE :t or lower(comment) LIKE :t or lower(number) LIKE :t', t: "%#{text.downcase}%") } diff --git a/app/views/lines/show.html.slim b/app/views/lines/show.html.slim index b314dee82..82ed8bdcf 100644 --- a/app/views/lines/show.html.slim +++ b/app/views/lines/show.html.slim @@ -50,57 +50,67 @@ p label = "#{@line.human_attribute_name('transport_mode')} : " - = t("transport_modes.label.#{@line.transport_mode}") - - p - label = "#{@line.human_attribute_name('stable_id')} : " - = @line.stable_id - - p - label = "#{@line.human_attribute_name('url')} : " - = @line.url - - p - label = "#{@line.human_attribute_name('mobility_restricted_suitability')} : " - - - if @line.mobility_restricted_suitability.nil? - = @line.human_attribute_name("unspecified_mrs") - - elsif @line.mobility_restricted_suitability? - = @line.human_attribute_name("accessible") + - if @line.transport_mode + = " " + t("enumerize.line.transport_mode.#{@line.transport_mode}") - else - = @line.human_attribute_name("not_accessible") - - br - = "#{@line.human_attribute_name('number_of_mrs_vj')} : #{@line.vehicle_journeys.where('mobility_restricted_suitability = ?', true).count}" - br - = "#{@line.human_attribute_name('number_of_non_mrs_vj')} : #{@line.vehicle_journeys.where('mobility_restricted_suitability = ?', false).count}" - br - = @line.human_attribute_name("number_of_null_mrs_vj") - = " : " - = @line.vehicle_journeys.count - (@line.vehicle_journeys.where("mobility_restricted_suitability = ?", true).count + @line.vehicle_journeys.where("mobility_restricted_suitability = ?", false).count) - + = " -" + p - label = "#{@line.human_attribute_name('flexible_service')} : " - - - if @line.flexible_service.nil? - = @line.human_attribute_name("unspecified_fs") - - elsif @line.flexible_service? - = @line.human_attribute_name("on_demaond_fs") + label = "#{@line.human_attribute_name('transport_submode')} : " + - if @line.transport_submode + = " " + t("enumerize.line.transport_submode.#{@line.transport_submode}") - else - = @line.human_attribute_name("regular_fs") + = " -" - br - = "#{@line.human_attribute_name('number_of_fs_vj')} : #{@line.vehicle_journeys.where('flexible_service = ?', true).count}" - br - = "#{@line.human_attribute_name('number_of_non_fs_vj')} : #{@line.vehicle_journeys.where('flexible_service = ?', false).count}" - br - = @line.human_attribute_name("number_of_null_fs_vj") + / p + / label = "#{@line.human_attribute_name('stable_id')} : " + / = @line.stable_id - - if @line.flexible_service.nil? - = "(#{@line.human_attribute_name('default_fs_msg')})" + p + label = "#{@line.human_attribute_name('url')} : " + = @line.url - = " : " - = @line.vehicle_journeys.count - (@line.vehicle_journeys.where("flexible_service = ?", true).count + @line.vehicle_journeys.where("flexible_service = ?", false).count) + / p + / label = "#{@line.human_attribute_name('mobility_restricted_suitability')} : " + / + / - if @line.mobility_restricted_suitability.nil? + / = @line.human_attribute_name("unspecified_mrs") + / - elsif @line.mobility_restricted_suitability? + / = @line.human_attribute_name("accessible") + / - else + / = @line.human_attribute_name("not_accessible") + / + / br + / = "#{@line.human_attribute_name('number_of_mrs_vj')} : #{@line.vehicle_journeys.where('mobility_restricted_suitability = ?', true).count}" + / br + / = "#{@line.human_attribute_name('number_of_non_mrs_vj')} : #{@line.vehicle_journeys.where('mobility_restricted_suitability = ?', false).count}" + / br + / = @line.human_attribute_name("number_of_null_mrs_vj") + / = " : " + / = @line.vehicle_journeys.count - (@line.vehicle_journeys.where("mobility_restricted_suitability = ?", true).count + @line.vehicle_journeys.where("mobility_restricted_suitability = ?", false).count) + / + / p + / label = "#{@line.human_attribute_name('flexible_service')} : " + / + / - if @line.flexible_service.nil? + / = @line.human_attribute_name("unspecified_fs") + / - elsif @line.flexible_service? + / = @line.human_attribute_name("on_demaond_fs") + / - else + / = @line.human_attribute_name("regular_fs") + / + / br + / = "#{@line.human_attribute_name('number_of_fs_vj')} : #{@line.vehicle_journeys.where('flexible_service = ?', true).count}" + / br + / = "#{@line.human_attribute_name('number_of_non_fs_vj')} : #{@line.vehicle_journeys.where('flexible_service = ?', false).count}" + / br + / = @line.human_attribute_name("number_of_null_fs_vj") + / + / - if @line.flexible_service.nil? + / = "(#{@line.human_attribute_name('default_fs_msg')})" + / + / = " : " + / = @line.vehicle_journeys.count - (@line.vehicle_journeys.where("flexible_service = ?", true).count + @line.vehicle_journeys.where("flexible_service = ?", false).count) p label = "#{@line.human_attribute_name('footnotes')} : " @@ -108,27 +118,13 @@ - @line.footnotes.each do |footnote| li = "#{footnote.code} : #{footnote.label}" - p - label = "#{@line.human_attribute_name('comment')} : " - = @line.comment - - .row - #mobility_restricted_suitability.col-md-6 - #flexible_service.col-md-6 - -p.after_map - -h3.routes - = t('.itineraries') - -.routes.paginated_content - / FIXME #825 - / = paginated_content @routes, "routes/route" + / p + / label = "#{@line.human_attribute_name('comment')} : " + / = @line.comment -- if @line.group_of_lines.any? - h3.line_group_of_lines = t('.group_of_lines') - .group_of_lines.paginated_content - = paginated_content @group_of_lines, "group_of_lines/group_of_line", delete: false + / .row + / #mobility_restricted_suitability.col-md-6 + / #flexible_service.col-md-6 - content_for :sidebar do ul.actions diff --git a/app/views/referential_lines/show.html.slim b/app/views/referential_lines/show.html.slim index 9b19982ff..07143488b 100644 --- a/app/views/referential_lines/show.html.slim +++ b/app/views/referential_lines/show.html.slim @@ -48,20 +48,20 @@ h2 p label = "#{@line.human_attribute_name('transport_mode')} : " - if @line.transport_mode - = " " + t("transport_modes.label.#{@line.transport_mode}") + = " " + t("enumerize.line.transport_mode.#{@line.transport_mode}") - else = " -" - + p label = "#{@line.human_attribute_name('transport_submode')} : " - if @line.transport_submode - = " " + t("enumerize.linereferential.transport_submode.#{@line.transport_submode}") + = " " + t("enumerize.line.transport_submode.#{@line.transport_submode}") - else = " -" - p - label = "#{@line.human_attribute_name('stable_id')} : " - = " #{@line.stable_id}" + / p + / label = "#{@line.human_attribute_name('stable_id')} : " + / = " #{@line.stable_id}" p label = "#{@line.human_attribute_name('url')} : " @@ -113,9 +113,9 @@ h2 / - @line.footnotes.each do |footnote| / li = "#{footnote.code} : #{footnote.label}" - p - label = "#{@line.human_attribute_name('comment')} : " - = @line.comment + / p + / label = "#{@line.human_attribute_name('comment')} : " + / = @line.comment .row #mobility_restricted_suitability.col-md-6 @@ -129,11 +129,6 @@ h3.routes / = paginated_content @routes, "routes/route" = render 'reflines_routes' -- if @line.group_of_lines.any? - h3.line_group_of_lines = t('.group_of_lines') - .group_of_lines.paginated_content - = paginated_content @group_of_lines, "referential_group_of_lines/group_of_line", :delete => false - - content_for :sidebar do ul.actions - if policy(Chouette::Line).create? diff --git a/config/locales/enumerize.en.yml b/config/locales/enumerize.en.yml index d4612e4af..e09a08696 100644 --- a/config/locales/enumerize.en.yml +++ b/config/locales/enumerize.en.yml @@ -50,7 +50,7 @@ en: wayback: straight_forward: 'Straight Forward' backward: 'Backward' - defaults: + vehicle_journey: transport_mode: interchange: Interchange unknown: "unknown" @@ -86,7 +86,41 @@ en: funicular: Funicular other: Other - linereferential: + line: + transport_mode: + interchange: Interchange + unknown: "unknown" + air: "Air" + train: "Train" + long_distance_train: "Long distance train" + local_train: "Local train" + rapid_transit: "Rapid transit" + metro: "Metro" + tramway: "Tramway" + coach: "Coach" + bus: "Bus" + ferry: "Ferry" + waterborne: "Waterborne" + private_vehicle: "Private vehicle" + walk: "Walk" + trolleybus: "Trolleybus" + bicycle: "Bicycle" + shuttle: "Shuttle" + taxi: "Taxi" + val: "VAL" + other: "Other" + air: Air + bus: Bus + coach: Coach + ferry: Ferry + metro: Metro + rail: Rail + trolleybus: Trolleybus + tram: Tramway + water: Water + cableway: Cableway + funicular: Funicular + other: Other transport_submode: unknown: 'Unknown' undefined: 'Undefined' diff --git a/config/locales/enumerize.fr.yml b/config/locales/enumerize.fr.yml index b45ffa416..62f5d53f6 100644 --- a/config/locales/enumerize.fr.yml +++ b/config/locales/enumerize.fr.yml @@ -50,7 +50,42 @@ fr: wayback: straight_forward: 'Aller' backward: 'Retour' - defaults: + vehicle_journey: + transport_mode: + interchange: Interconnection + unknown: Inconnu + air: Air + train: Train + long_distance_train: Train Grande Ligne + local_train: TER + rapid_transit: RER + metro: Métro + tramway: Tramway + coach: Autocar + bus: Bus + ferry: Ferry + waterborne: Bac + private_vehicle: Voiture particulière + walk: Marche à pied + trolleybus: Trolleybus + bicycle: Vélo + shuttle: Navette + taxi: Taxi + val: VAL + other: Autre + bus: Bus + coach: Autocar + ferry: Ferry + metro: Métro + rail: Train + trolleybus: Trolleybus + tram: Tramway + water: Eau + cableway: Téléphérique + funicular: Funiculaire + other: Autre + + line: transport_mode: interchange: Interconnection unknown: Inconnu @@ -85,7 +120,6 @@ fr: funicular: Funiculaire other: Autre - linereferential: transport_submode: unknown: 'Inconnu' undefined: 'Non défini' diff --git a/config/locales/lines.en.yml b/config/locales/lines.en.yml index aeaac7ee4..51ea2a176 100644 --- a/config/locales/lines.en.yml +++ b/config/locales/lines.en.yml @@ -61,6 +61,7 @@ en: published_name: "Published name" number: "Number" transport_mode: "Transport mode" + transport_submode: "Transport Submode" url: "Web page" color: "Line color" text_color: "Text color" diff --git a/config/locales/lines.fr.yml b/config/locales/lines.fr.yml index abd6696b4..0ac9e676e 100644 --- a/config/locales/lines.fr.yml +++ b/config/locales/lines.fr.yml @@ -61,6 +61,7 @@ fr: published_name: "Nom public" number: "Indice" transport_mode: "Mode de transport" + transport_submode: "Sous mode de transport" url: "Page web associée" color: "Couleur du tracé" text_color: "Couleur du texte" diff --git a/lib/stif/codif_line_synchronization.rb b/lib/stif/codif_line_synchronization.rb index 600415424..318d5427c 100644 --- a/lib/stif/codif_line_synchronization.rb +++ b/lib/stif/codif_line_synchronization.rb @@ -89,7 +89,7 @@ module Stif deactivated: (api_line.status == "inactive" ? true : false), import_xml: api_line.xml } - + params[:transport_mode] = api_line.transport_mode.to_s params[:transport_submode] = api_line.transport_submode.to_s unless api_line.operator_ref.nil? params[:company] = Chouette::Company.find_by(objectid: api_line.operator_ref) -- cgit v1.2.3