diff options
| -rw-r--r-- | app/controllers/calendars_controller.rb | 4 | ||||
| -rw-r--r-- | app/models/calendar.rb | 3 | ||||
| -rw-r--r-- | app/views/autocomplete_calendars/autocomplete.rabl | 2 | ||||
| -rw-r--r-- | app/views/calendars/_filters.html.slim | 4 | ||||
| -rw-r--r-- | app/views/calendars/_form_simple.html.slim | 3 | ||||
| -rw-r--r-- | app/views/calendars/index.html.slim | 4 | ||||
| -rw-r--r-- | app/views/calendars/show.html.slim | 3 | ||||
| -rw-r--r-- | config/locales/calendars.en.yml | 1 | ||||
| -rw-r--r-- | config/locales/calendars.fr.yml | 1 | ||||
| -rw-r--r-- | db/migrate/20180315152714_remove_short_name_from_calendars.rb | 5 | ||||
| -rw-r--r-- | db/schema.rb | 61 | ||||
| -rw-r--r-- | spec/factories/calendars.rb | 2 | ||||
| -rw-r--r-- | spec/models/calendar_spec.rb | 2 | 
13 files changed, 65 insertions, 30 deletions
| diff --git a/app/controllers/calendars_controller.rb b/app/controllers/calendars_controller.rb index cc7570d65..3d88e4910 100644 --- a/app/controllers/calendars_controller.rb +++ b/app/controllers/calendars_controller.rb @@ -64,13 +64,13 @@ class CalendarsController < ChouetteController    end    def calendar_params -    permitted_params = [:id, :name, :short_name, :shared, periods_attributes: [:id, :begin, :end, :_destroy], date_values_attributes: [:id, :value, :_destroy]] +    permitted_params = [:id, :name, :shared, periods_attributes: [:id, :begin, :end, :_destroy], date_values_attributes: [:id, :value, :_destroy]]      permitted_params << :shared if policy(Calendar).share?      params.require(:calendar).permit(*permitted_params)    end    def sort_column -    Calendar.column_names.include?(params[:sort]) ? params[:sort] : 'short_name' +    Calendar.column_names.include?(params[:sort]) ? params[:sort] : 'name'    end    def sort_direction diff --git a/app/models/calendar.rb b/app/models/calendar.rb index 84b569ab4..32eedf9ea 100644 --- a/app/models/calendar.rb +++ b/app/models/calendar.rb @@ -12,8 +12,7 @@ class Calendar < ActiveRecord::Base    belongs_to :organisation    belongs_to :workgroup -  validates_presence_of :name, :short_name, :organisation, :workgroup -  validates_uniqueness_of :short_name +  validates_presence_of :name, :organisation, :workgroup    has_many :time_tables diff --git a/app/views/autocomplete_calendars/autocomplete.rabl b/app/views/autocomplete_calendars/autocomplete.rabl index 3a7703c53..9a91e1d69 100644 --- a/app/views/autocomplete_calendars/autocomplete.rabl +++ b/app/views/autocomplete_calendars/autocomplete.rabl @@ -1,5 +1,5 @@  collection @calendars, :object_root => false -attribute :id, :name, :short_name, :shared +attribute :id, :name, :shared  node :text do |cal|    "<strong>" + cal.name + " - " + cal.id.to_s + "</strong>" diff --git a/app/views/calendars/_filters.html.slim b/app/views/calendars/_filters.html.slim index 8bfe1974e..4d664c358 100644 --- a/app/views/calendars/_filters.html.slim +++ b/app/views/calendars/_filters.html.slim @@ -1,7 +1,7 @@  = search_form_for @q, url: workgroup_calendars_path(@workgroup), builder: SimpleForm::FormBuilder, html: { method: :get, class: 'form form-filter' } do |f|    .ffg-row -    .input-group.search_bar class=filter_item_class(params[:q], :name_or_short_name_cont) -      = f.search_field :name_or_short_name_cont, class: 'form-control', placeholder: 'Indiquez un nom/nom court de calendrier...' +    .input-group.search_bar class=filter_item_class(params[:q], :name_cont) +      = f.search_field :name_cont, class: 'form-control', placeholder: 'Indiquez un nom/nom court de calendrier...'        span.input-group-btn          button.btn.btn-default#search_btn type='submit'            span.fa.fa-search diff --git a/app/views/calendars/_form_simple.html.slim b/app/views/calendars/_form_simple.html.slim index ba18c765b..1025130fd 100644 --- a/app/views/calendars/_form_simple.html.slim +++ b/app/views/calendars/_form_simple.html.slim @@ -4,8 +4,7 @@        .row          .col-lg-12            = f.input :name -          = f.input :short_name - +                      - if policy(@calendar).share?              .form-group.has_switch                = f.label :shared, class: 'col-sm-4 col-xs-5 control-label' diff --git a/app/views/calendars/index.html.slim b/app/views/calendars/index.html.slim index 0b58c0c72..d4b84fe82 100644 --- a/app/views/calendars/index.html.slim +++ b/app/views/calendars/index.html.slim @@ -20,10 +20,6 @@                  end \                ), \                TableBuilderHelper::Column.new( \ -                key: :short_name, \ -                attribute: 'short_name' \ -              ), \ -              TableBuilderHelper::Column.new( \                  key: :organisation, \                  attribute: Proc.new { |c| c.organisation.name } \                ), \ diff --git a/app/views/calendars/show.html.slim b/app/views/calendars/show.html.slim index cec4f66a5..fa1ab3b71 100644 --- a/app/views/calendars/show.html.slim +++ b/app/views/calendars/show.html.slim @@ -6,8 +6,7 @@      .row        .col-lg-6.col-md-6.col-sm-12.col-xs-12          = definition_list t('metadatas'), -          { 'Nom court' => resource.try(:short_name), -            Calendar.human_attribute_name(:shared) => t("#{resource.shared}"), +          { Calendar.human_attribute_name(:shared) => t("#{resource.shared}"),              'Organisation' => resource.organisation.name,              Calendar.human_attribute_name(:dates) =>  resource.dates.collect{|d| l(d, format: :short)}.join(', ').html_safe,              Calendar.human_attribute_name(:date_ranges) => resource.periods.map{|d| t('validity_range', debut: l(d.begin, format: :short), end: l(d.end, format: :short))}.join('<br>').html_safe } diff --git a/config/locales/calendars.en.yml b/config/locales/calendars.en.yml index c3df413af..b9540d124 100644 --- a/config/locales/calendars.en.yml +++ b/config/locales/calendars.en.yml @@ -64,7 +64,6 @@ en:      attributes:        calendar:          name: Name -        short_name: Short name          date_ranges: Date ranges          dates: Dates          shared: Shared diff --git a/config/locales/calendars.fr.yml b/config/locales/calendars.fr.yml index 6fd265925..6a87a889a 100644 --- a/config/locales/calendars.fr.yml +++ b/config/locales/calendars.fr.yml @@ -64,7 +64,6 @@ fr:      attributes:        calendar:          name: Nom -        short_name: Nom court          date_ranges: Intervalles de dates          dates: Dates          shared: Partagé diff --git a/db/migrate/20180315152714_remove_short_name_from_calendars.rb b/db/migrate/20180315152714_remove_short_name_from_calendars.rb new file mode 100644 index 000000000..3b6759f7b --- /dev/null +++ b/db/migrate/20180315152714_remove_short_name_from_calendars.rb @@ -0,0 +1,5 @@ +class RemoveShortNameFromCalendars < ActiveRecord::Migration +  def change +    remove_column :calendars, :short_name, :string +  end +end diff --git a/db/schema.rb b/db/schema.rb index 58c8b0779..9e118e972 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -15,9 +15,10 @@ ActiveRecord::Schema.define(version: 20180319043333) do    # These are extensions that must be enabled in order to support this database    enable_extension "plpgsql" -  enable_extension "postgis"    enable_extension "hstore" +  enable_extension "postgis"    enable_extension "unaccent" +  enable_extension "objectid"    create_table "access_links", id: :bigserial, force: :cascade do |t|      t.integer  "access_point_id",                        limit: 8 @@ -83,20 +84,18 @@ ActiveRecord::Schema.define(version: 20180319043333) do    create_table "calendars", id: :bigserial, force: :cascade do |t|      t.string    "name" -    t.string    "short_name"      t.daterange "date_ranges",                               array: true      t.date      "dates",                                     array: true      t.boolean   "shared",                    default: false      t.integer   "organisation_id", limit: 8      t.datetime  "created_at"      t.datetime  "updated_at" -    t.integer   "workgroup_id",    limit: 8      t.integer   "int_day_types"      t.date      "excluded_dates",                            array: true +    t.integer   "workgroup_id",    limit: 8    end    add_index "calendars", ["organisation_id"], name: "index_calendars_on_organisation_id", using: :btree -  add_index "calendars", ["short_name"], name: "index_calendars_on_short_name", unique: true, using: :btree    add_index "calendars", ["workgroup_id"], name: "index_calendars_on_workgroup_id", using: :btree    create_table "clean_up_results", id: :bigserial, force: :cascade do |t| @@ -119,6 +118,7 @@ ActiveRecord::Schema.define(version: 20180319043333) do      t.datetime "updated_at"      t.date     "end_date"      t.string   "date_type" +    t.string   "mode"    end    add_index "clean_ups", ["referential_id"], name: "index_clean_ups_on_referential_id", using: :btree @@ -299,18 +299,58 @@ ActiveRecord::Schema.define(version: 20180319043333) do    add_index "custom_fields", ["resource_type"], name: "index_custom_fields_on_resource_type", using: :btree +  create_table "export_messages", id: :bigserial, force: :cascade do |t| +    t.string   "criticity" +    t.string   "message_key" +    t.hstore   "message_attributes" +    t.integer  "export_id",           limit: 8 +    t.integer  "resource_id",         limit: 8 +    t.datetime "created_at" +    t.datetime "updated_at" +    t.hstore   "resource_attributes" +  end + +  add_index "export_messages", ["export_id"], name: "index_export_messages_on_export_id", using: :btree +  add_index "export_messages", ["resource_id"], name: "index_export_messages_on_resource_id", using: :btree + +  create_table "export_resources", id: :bigserial, force: :cascade do |t| +    t.integer  "export_id",     limit: 8 +    t.string   "status" +    t.datetime "created_at" +    t.datetime "updated_at" +    t.string   "resource_type" +    t.string   "reference" +    t.string   "name" +    t.hstore   "metrics" +  end + +  add_index "export_resources", ["export_id"], name: "index_export_resources_on_export_id", using: :btree +    create_table "exports", id: :bigserial, force: :cascade do |t| -    t.integer  "referential_id",  limit: 8      t.string   "status" -    t.string   "type" -    t.string   "options" +    t.string   "current_step_id" +    t.float    "current_step_progress" +    t.integer  "workbench_id",          limit: 8 +    t.integer  "referential_id",        limit: 8 +    t.string   "name"      t.datetime "created_at"      t.datetime "updated_at" -    t.string   "references_type" -    t.string   "reference_ids" +    t.string   "file" +    t.datetime "started_at" +    t.datetime "ended_at" +    t.string   "token_upload" +    t.string   "type" +    t.integer  "parent_id",             limit: 8 +    t.string   "parent_type" +    t.datetime "notified_parent_at" +    t.integer  "current_step",                    default: 0 +    t.integer  "total_steps",                     default: 0 +    t.string   "creator" +    t.hstore   "options"    end    add_index "exports", ["referential_id"], name: "index_exports_on_referential_id", using: :btree +  add_index "exports", ["workbench_id"], name: "index_exports_on_workbench_id", using: :btree    create_table "facilities", id: :bigserial, force: :cascade do |t|      t.integer  "stop_area_id",       limit: 8 @@ -766,6 +806,7 @@ ActiveRecord::Schema.define(version: 20180319043333) do      t.datetime "created_at"      t.datetime "updated_at"      t.string   "objectid_format" +    t.string   "registration_number_format"    end    create_table "stop_areas", id: :bigserial, force: :cascade do |t| @@ -802,6 +843,8 @@ ActiveRecord::Schema.define(version: 20180319043333) do      t.string   "kind"      t.jsonb    "localized_names"      t.datetime "confirmed_at" +    t.json     "custom_field_values" +    end    add_index "stop_areas", ["name"], name: "index_stop_areas_on_name", using: :btree diff --git a/spec/factories/calendars.rb b/spec/factories/calendars.rb index d9fd242d1..d78f230c6 100644 --- a/spec/factories/calendars.rb +++ b/spec/factories/calendars.rb @@ -1,7 +1,6 @@  FactoryGirl.define do    factory :calendar do      sequence(:name) { |n| "Calendar #{n}" } -    sequence(:short_name) { |n| "Cal #{n}" }      date_ranges { [generate(:date_range)] }      sequence(:dates) { |n| [ Date.yesterday - n, Date.yesterday - 2*n ] }      shared false @@ -14,4 +13,3 @@ FactoryGirl.define do      date..(date+1)    end  end - diff --git a/spec/models/calendar_spec.rb b/spec/models/calendar_spec.rb index a5c0a7471..09ac0e416 100644 --- a/spec/models/calendar_spec.rb +++ b/spec/models/calendar_spec.rb @@ -4,8 +4,6 @@ RSpec.describe Calendar, :type => :model do    it { is_expected.to validate_presence_of(:organisation) }    it { is_expected.to validate_presence_of(:name) } -  it { is_expected.to validate_presence_of(:short_name) } -  it { is_expected.to validate_uniqueness_of(:short_name) }    it { is_expected.to be_versioned }    describe '#to_time_table' do | 
