diff options
| author | Luc Donnet | 2018-02-07 10:03:36 +0100 | 
|---|---|---|
| committer | GitHub | 2018-02-07 10:03:36 +0100 | 
| commit | de6ef9294f7a1890d6f9de479e965d571233a96e (patch) | |
| tree | 02b7cec8fe79473955e48731f78d6bcd1dcb0366 | |
| parent | 4f58c4eaca46dc975aa907840cdbe067f6225d5e (diff) | |
| parent | 7d24256844e33bcb7875076a4bcfae22dd308009 (diff) | |
| download | chouette-core-de6ef9294f7a1890d6f9de479e965d571233a96e.tar.bz2 | |
Merge pull request #281 from af83/5817-referential-vehicle-journeys-index--fix-StopArea-kind-a
5817 referential vehicle journeys index  fix stop area kind a
| -rw-r--r-- | app/models/chouette/stop_area.rb | 4 | ||||
| -rw-r--r-- | app/views/referential_vehicle_journeys/_filters.html.slim | 2 | ||||
| -rw-r--r-- | app/views/stop_areas/_form.html.slim | 11 | ||||
| -rw-r--r-- | db/migrate/20180202170009_set_stop_areas_kind_to_commercial_on_existing_records.rb | 11 | ||||
| -rw-r--r-- | db/schema.rb | 2 | 
5 files changed, 22 insertions, 8 deletions
| diff --git a/app/models/chouette/stop_area.rb b/app/models/chouette/stop_area.rb index cf2afbc73..bb8747faa 100644 --- a/app/models/chouette/stop_area.rb +++ b/app/models/chouette/stop_area.rb @@ -47,10 +47,6 @@ module Chouette      validate :parent_area_type_must_be_greater      validate :area_type_of_right_kind -    after_initialize do -      self.kind ||= :commercial -    end -      def self.nullable_attributes        [:registration_number, :street_name, :country_code, :fare_code,        :nearest_topic_name, :comment, :long_lat_type, :zip_code, :city_name, :url, :time_zone] diff --git a/app/views/referential_vehicle_journeys/_filters.html.slim b/app/views/referential_vehicle_journeys/_filters.html.slim index bd8245e39..3104e3a71 100644 --- a/app/views/referential_vehicle_journeys/_filters.html.slim +++ b/app/views/referential_vehicle_journeys/_filters.html.slim @@ -42,7 +42,7 @@          = f.input :published_journey_name_lteq, label: false, wrapper_html: { class: 'w45'}      .form-group.togglable class=filter_item_class(params[:q], :stop_area_ids)        = f.label Chouette::StopArea.model_name.human.pluralize, required: false, class: 'control-label' -      = f.input :stop_area_ids, collection: @all_stop_areas.select(:id, :name, :kind).order(name: :asc), checked: params[:q] && params[:q][:stop_area_ids], as: :check_boxes, label: false, label_method: lambda{|l| ("<span>" + l.name + "</span>").html_safe}, required: false, wrapper_html: { class: 'checkbox_list'}, multiple: true +      = f.input :stop_area_ids, collection: @all_stop_areas.select(:id, :name).order(name: :asc), checked: params[:q] && params[:q][:stop_area_ids], as: :check_boxes, label: false, label_method: lambda{|l| ("<span>" + l.name + "</span>").html_safe}, required: false, wrapper_html: { class: 'checkbox_list'}, multiple: true      .form-group.togglable class=filter_item_class(params[:q], :purchase_window)        = f.label Chouette::VehicleJourney.human_attribute_name(:purchase_window), class: 'control-label'        .filter_menu diff --git a/app/views/stop_areas/_form.html.slim b/app/views/stop_areas/_form.html.slim index 9897a27ac..bb1fbe1e9 100644 --- a/app/views/stop_areas/_form.html.slim +++ b/app/views/stop_areas/_form.html.slim @@ -12,8 +12,15 @@              .col-sm-9.col-xs-7                - f.object.localized_names.each do |k, v|                  .col-md-6= f.input "localized_names[#{k}]", input_html: {value: v}, label: label_for_country(k) -                 -        = f.input :kind, as: :radio_buttons, checked: @stop_area.kind, :input_html => {:disabled => !@stop_area.new_record?}, :include_blank => false, item_wrapper_class: 'radio-inline', wrapper: :horizontal_form, disabled: !@stop_area.new_record? + +        = f.input :kind, +            as: :radio_buttons, +            checked: @stop_area.new_record? ? :commercial : @stop_area.kind, +            input_html: { disabled: !@stop_area.new_record? }, +            include_blank: false, +            item_wrapper_class: 'radio-inline', +            wrapper: :horizontal_form, +            disabled: !@stop_area.new_record?          .slave data-master="[name='stop_area[kind]']" data-value="commercial"            = f.input :parent_id, as: :select, :collection => [f.object.parent_id], input_html: { data: { select2_ajax: 'true', url: autocomplete_stop_area_referential_stop_areas_path(@stop_area_referential), initvalue: {id: f.object.parent_id, text: f.object.parent.try(:full_name)}}}          - %i(non_commercial commercial).each do |kind| diff --git a/db/migrate/20180202170009_set_stop_areas_kind_to_commercial_on_existing_records.rb b/db/migrate/20180202170009_set_stop_areas_kind_to_commercial_on_existing_records.rb new file mode 100644 index 000000000..6c6f6370e --- /dev/null +++ b/db/migrate/20180202170009_set_stop_areas_kind_to_commercial_on_existing_records.rb @@ -0,0 +1,11 @@ +class SetStopAreasKindToCommercialOnExistingRecords < ActiveRecord::Migration +  def up +    Chouette::StopArea +      .where('kind != ? or kind is null', :non_commercial) +      .update_all(kind: :commercial) +  end + +  def down +    raise ActiveRecord::IrreversibleMigration +  end +end diff --git a/db/schema.rb b/db/schema.rb index d54a40feb..cd4d42005 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@  #  # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180124124215) do +ActiveRecord::Schema.define(version: 20180202170009) do    # These are extensions that must be enabled in order to support this database    enable_extension "plpgsql" | 
