diff options
| -rw-r--r-- | app/helpers/compliance_controls_helper.rb | 4 | ||||
| -rw-r--r-- | app/javascript/vehicle_journeys/actions/index.js | 9 | ||||
| -rw-r--r-- | app/views/autocomplete_purchase_windows/index.rabl | 13 | ||||
| -rw-r--r-- | app/views/referentials/select_compliance_control_set.html.slim | 2 | ||||
| -rw-r--r-- | app/views/workbench_outputs/show.html.slim | 3 | ||||
| -rw-r--r-- | config/locales/compliance_check_sets.en.yml | 2 | ||||
| -rw-r--r-- | config/locales/compliance_check_sets.fr.yml | 2 | ||||
| -rw-r--r-- | config/locales/import_resources.en.yml | 2 | ||||
| -rw-r--r-- | config/locales/import_resources.fr.yml | 2 | ||||
| -rw-r--r-- | config/locales/referentials.fr.yml | 2 | ||||
| -rw-r--r-- | db/migrate/20180405133659_change_companies_custom_fields_values_type.rb | 8 | ||||
| -rw-r--r-- | db/schema.rb | 18 | ||||
| -rw-r--r-- | db/seeds/dev/custom_fields.seeds.rb | 52 | ||||
| -rw-r--r-- | db/seeds/development/custom_fields.seeds.rb | 52 | ||||
| -rw-r--r-- | db/seeds/seed_helpers.rb | 2 | ||||
| -rw-r--r-- | db/seeds/stif.seeds.rb | 2 | ||||
| -rw-r--r-- | lib/tasks/ci.rake | 17 | 
17 files changed, 153 insertions, 39 deletions
| diff --git a/app/helpers/compliance_controls_helper.rb b/app/helpers/compliance_controls_helper.rb index 297ae3afa..abf909929 100644 --- a/app/helpers/compliance_controls_helper.rb +++ b/app/helpers/compliance_controls_helper.rb @@ -11,7 +11,7 @@ module ComplianceControlsHelper    def compliance_control_metadatas(compliance_control)      attributes = resource.class.dynamic_attributes -    attributes.push(*resource.control_attributes.keys) if resource.respond_to? :control_attributes +    attributes.push(*resource.control_attributes.keys) if resource&.control_attributes&.keys      {}.tap do |hash|        attributes.each do |attribute| @@ -19,4 +19,4 @@ module ComplianceControlsHelper        end      end    end -end  +end diff --git a/app/javascript/vehicle_journeys/actions/index.js b/app/javascript/vehicle_journeys/actions/index.js index e00e9b1b0..537dcfc06 100644 --- a/app/javascript/vehicle_journeys/actions/index.js +++ b/app/javascript/vehicle_journeys/actions/index.js @@ -113,14 +113,9 @@ const actions = {      type : 'EDIT_PURCHASE_WINDOWS_VEHICLEJOURNEY_MODAL',      vehicleJourneys    }), -  selectPurchaseWindowsModal: (selectedWindow) =>({ +  selectPurchaseWindowsModal: (selectedItem) =>({      type: 'SELECT_PURCHASE_WINDOW_MODAL', -    selectedItem:{ -      id: selectedWindow.id, -      name: selectedWindow.name, -      color: selectedWindow.color, -      objectid: selectedWindow.objectid -    } +    selectedItem    }),    addSelectedPurchaseWindow: () => ({      type: 'ADD_SELECTED_PURCHASE_WINDOW' diff --git a/app/views/autocomplete_purchase_windows/index.rabl b/app/views/autocomplete_purchase_windows/index.rabl index 1d0287602..bdc513c31 100644 --- a/app/views/autocomplete_purchase_windows/index.rabl +++ b/app/views/autocomplete_purchase_windows/index.rabl @@ -2,11 +2,12 @@ collection @purchase_windows, :object_root => false  node do |window|    { -    :id => window.id, -    :name => window.name, -    :objectid => window.objectid, -    :color => window.color, -    :short_id => window.get_objectid.short_id, -    :text => "<strong><span class='fa fa-circle' style='color:" + (window.color ? window.color : '#4b4b4b') + "'></span> " + window.name + " - " + window.get_objectid.short_id + "</strong>" +    id: window.id, +    name: window.name, +    objectid: window.objectid, +    color: window.color, +    short_id: window.get_objectid.short_id, +    bounding_dates: window.bounding_dates, +    text: "<strong><span class='fa fa-circle' style='color:" + (window.color ? window.color : '#4b4b4b') + "'></span> " + window.name + " - " + window.get_objectid.short_id + "</strong>"    }  end diff --git a/app/views/referentials/select_compliance_control_set.html.slim b/app/views/referentials/select_compliance_control_set.html.slim index 3550bb202..7be82364d 100644 --- a/app/views/referentials/select_compliance_control_set.html.slim +++ b/app/views/referentials/select_compliance_control_set.html.slim @@ -8,7 +8,7 @@            .row              .col-lg-12                .form-group -                = label_tag 'name', nil, class: 'string required col-sm-4 col-xs-5 control-label' +                = label_tag ComplianceControlSet.ts, nil, class: 'string required col-sm-4 col-xs-5 control-label'                  .col-sm-8.col-xs-7                    = select_tag :compliance_control_set, options_from_collection_for_select(@compliance_control_sets, "id", "name"), class: 'select optional form-control'                .separator diff --git a/app/views/workbench_outputs/show.html.slim b/app/views/workbench_outputs/show.html.slim index a9e106dbb..b310119e6 100644 --- a/app/views/workbench_outputs/show.html.slim +++ b/app/views/workbench_outputs/show.html.slim @@ -6,7 +6,8 @@    .row.mb-sm      .col-lg-12.text-right        = link_to t('.see_current_output'), referential_path(@workbench.output.current), class: 'btn btn-primary' if @workbench.output&.current -      = link_to t('merges.actions.create'), new_workbench_merge_path(@workbench), class: 'btn btn-primary' +      - if policy(Merge).create? +        = link_to t('merges.actions.create'), new_workbench_merge_path(@workbench), class: 'btn btn-primary'  .page_content    .container-fluid diff --git a/config/locales/compliance_check_sets.en.yml b/config/locales/compliance_check_sets.en.yml index 63708328b..73ecf8996 100644 --- a/config/locales/compliance_check_sets.en.yml +++ b/config/locales/compliance_check_sets.en.yml @@ -23,7 +23,7 @@ en:        table_state: "%{lines_status} lines imported out of %{lines_in_compliance_check_set} in the archive"        table_explanation: "These controls apply to all imported data and condition the construction of your organization's offer."        table_title: Analysed lines state -      metrics: "%{ok_count} ok, %{error_count} errors, %{warning_count} warnings, %{uncheck_count} n/a" +      metrics: "%{error_count} errors, %{warning_count} warnings"        metadatas:          referential: "Object analysed"          referential_type: "Apply to" diff --git a/config/locales/compliance_check_sets.fr.yml b/config/locales/compliance_check_sets.fr.yml index 20bf11d85..045fed4ce 100644 --- a/config/locales/compliance_check_sets.fr.yml +++ b/config/locales/compliance_check_sets.fr.yml @@ -19,7 +19,7 @@ fr:        table_state: "%{lines_status} lignes valides sur %{lines_in_compliance_check_set} présentes dans l'offre de transport"        table_explanation: Ces contrôles s’appliquent pour toutes les données importées et conditionnent la construction de l’offre de votre organisation        table_title: État des lignes analysées -      metrics: "%{ok_count} ok, %{error_count} errors, %{warning_count} warnings, %{uncheck_count} n/a" +      metrics: "%{error_count} errors, %{warning_count} warnings"        metadatas:          referential: "Objet analysé"          referential_type: "Appliqué à" diff --git a/config/locales/import_resources.en.yml b/config/locales/import_resources.en.yml index 386039319..4b1f9c394 100644 --- a/config/locales/import_resources.en.yml +++ b/config/locales/import_resources.en.yml @@ -6,7 +6,7 @@ en:          table_state: "%{lines_imported} line(s) imported on %{lines_in_zipfile} presents in zipfile"          table_title: "Satus of anlyzed files"          table_explanation: "When calendriers.xml and/or commun.xml are not imported, then all lines file are not processed." -        metrics: "%{ok_count} ok, %{error_count} errors, %{warning_count} warnings, %{uncheck_count} n/a" +        metrics: "%{error_count} errors, %{warning_count} warnings"    import_resources:      <<: *resources    activerecord: diff --git a/config/locales/import_resources.fr.yml b/config/locales/import_resources.fr.yml index 50fb7f1ca..93a576f01 100644 --- a/config/locales/import_resources.fr.yml +++ b/config/locales/import_resources.fr.yml @@ -6,7 +6,7 @@ fr:          table_state: "%{lines_imported} ligne(s) importée(s) sur %{lines_in_zipfile} présente(s) dans l'archive"          table_title: "Etat des fichiers analysés"          table_explanation: "Dans le cas ou le(s) fichiers calendriers.xml et/ou commun.xml sont dans un état non importé, alors tous les fichiers lignes sont automatiquement dans un état non traité." -        metrics: "%{ok_count} ok, %{error_count} errors, %{warning_count} warnings, %{uncheck_count} n/a" +        metrics: "%{error_count} errors, %{warning_count} warnings"    import_resources:      <<: *resources    activerecord: diff --git a/config/locales/referentials.fr.yml b/config/locales/referentials.fr.yml index ec6c7c643..cf012ef8e 100644 --- a/config/locales/referentials.fr.yml +++ b/config/locales/referentials.fr.yml @@ -32,7 +32,7 @@ fr:          title: 'Dupliquer un jeu de données'        submit: "Valider"      select_compliance_control_set: -      title: "Sélection du jeu de contôles" +      title: "Sélection du jeu de contrôles"      actions:        new: "Créer un jeu de données"        destroy_confirm: "Etes vous sûr de vouloir supprimer ce jeu de données ?" diff --git a/db/migrate/20180405133659_change_companies_custom_fields_values_type.rb b/db/migrate/20180405133659_change_companies_custom_fields_values_type.rb new file mode 100644 index 000000000..7248c29f6 --- /dev/null +++ b/db/migrate/20180405133659_change_companies_custom_fields_values_type.rb @@ -0,0 +1,8 @@ +class ChangeCompaniesCustomFieldsValuesType < ActiveRecord::Migration +  def change +    reversible do |dir| +      dir.up { change_column :companies, :custom_field_values, 'jsonb USING CAST(custom_field_values AS jsonb)', :default => {} } +      dir.down { change_column :companies, :custom_field_values, 'json USING CAST(custom_field_values AS json)', :default => {} } +    end +  end +end diff --git a/db/schema.rb b/db/schema.rb index 0f6f21b83..023cdc7eb 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,14 +11,13 @@  #  # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180319043333) do +ActiveRecord::Schema.define(version: 20180405133659) do    # These are extensions that must be enabled in order to support this database    enable_extension "plpgsql" -  enable_extension "hstore"    enable_extension "postgis" +  enable_extension "hstore"    enable_extension "unaccent" -  enable_extension "objectid"    create_table "access_links", id: :bigserial, force: :cascade do |t|      t.integer  "access_point_id",                        limit: 8 @@ -118,13 +117,12 @@ 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    create_table "companies", id: :bigserial, force: :cascade do |t| -    t.string   "objectid",                            null: false +    t.string   "objectid",                                         null: false      t.integer  "object_version",            limit: 8      t.string   "name"      t.string   "short_name" @@ -141,7 +139,7 @@ ActiveRecord::Schema.define(version: 20180319043333) do      t.text     "import_xml"      t.datetime "created_at"      t.datetime "updated_at" -    t.json     "custom_field_values" +    t.jsonb    "custom_field_values",                 default: {}    end    add_index "companies", ["line_referential_id"], name: "index_companies_on_line_referential_id", using: :btree @@ -462,9 +460,9 @@ ActiveRecord::Schema.define(version: 20180319043333) do      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.datetime "notified_parent_at"      t.string   "creator"    end @@ -1074,8 +1072,10 @@ ActiveRecord::Schema.define(version: 20180319043333) do      t.string   "name"      t.integer  "line_referential_id",      limit: 8      t.integer  "stop_area_referential_id", limit: 8 -    t.datetime "created_at",                         null: false -    t.datetime "updated_at",                         null: false +    t.datetime "created_at",                                      null: false +    t.datetime "updated_at",                                      null: false +    t.string   "import_types",                       default: [],              array: true +    t.string   "export_types",                       default: [],              array: true    end    add_foreign_key "access_links", "access_points", name: "aclk_acpt_fkey" diff --git a/db/seeds/dev/custom_fields.seeds.rb b/db/seeds/dev/custom_fields.seeds.rb new file mode 100644 index 000000000..eb3afc394 --- /dev/null +++ b/db/seeds/dev/custom_fields.seeds.rb @@ -0,0 +1,52 @@ +# coding: utf-8 + +require_relative '../seed_helpers' + +Workgroup.find_each do |workgroup| +  puts workgroup.inspect + +  workgroup.custom_fields.seed_by(code: "capacity") do |field| +    field.resource_type = "VehicleJourney" +    field.name = "Bus Capacity" +    field.field_type = "list" +    field.options = { list_values: { "0": "", "1": "48 places", "2": "54 places" }} +  end + +  workgroup.custom_fields.seed_by(code: "company_commercial_name") do |field| +    field.resource_type = "Company" +    field.name = "Nom commercial" +    field.field_type = "list" +    field.options = { list_values: { "0": "", "1": "OuiBus", "2": "Alsa" }} +  end + +  workgroup.custom_fields.seed_by(code: "company_contact_name") do |field| +    field.resource_type = "Company" +    field.name = "Nom du référent" +    field.field_type = "string" +  end + +  workgroup.custom_fields.seed_by(code: "stop_area_test_list") do |field| +    field.resource_type = "StopArea" +    field.name = "Test de Liste" +    field.field_type = "list" +    field.options = { list_values: { "0": "", "1": "Valeur 1", "2": "Valeur 2" }} +  end + +  workgroup.custom_fields.seed_by(code: "stop_area_test_string") do |field| +    field.resource_type = "StopArea" +    field.name = "Test de Texte" +    field.field_type = "string" +  end + +  workgroup.custom_fields.seed_by(code: "stop_area_test_integer") do |field| +    field.resource_type = "StopArea" +    field.name = "Test de Nomber" +    field.field_type = "integer" +  end + +  workgroup.custom_fields.seed_by(code: "stop_area_test_attachment") do |field| +    field.resource_type = "StopArea" +    field.name = "Test de Piece Jointe" +    field.field_type = "attachment" +  end +end diff --git a/db/seeds/development/custom_fields.seeds.rb b/db/seeds/development/custom_fields.seeds.rb new file mode 100644 index 000000000..eb3afc394 --- /dev/null +++ b/db/seeds/development/custom_fields.seeds.rb @@ -0,0 +1,52 @@ +# coding: utf-8 + +require_relative '../seed_helpers' + +Workgroup.find_each do |workgroup| +  puts workgroup.inspect + +  workgroup.custom_fields.seed_by(code: "capacity") do |field| +    field.resource_type = "VehicleJourney" +    field.name = "Bus Capacity" +    field.field_type = "list" +    field.options = { list_values: { "0": "", "1": "48 places", "2": "54 places" }} +  end + +  workgroup.custom_fields.seed_by(code: "company_commercial_name") do |field| +    field.resource_type = "Company" +    field.name = "Nom commercial" +    field.field_type = "list" +    field.options = { list_values: { "0": "", "1": "OuiBus", "2": "Alsa" }} +  end + +  workgroup.custom_fields.seed_by(code: "company_contact_name") do |field| +    field.resource_type = "Company" +    field.name = "Nom du référent" +    field.field_type = "string" +  end + +  workgroup.custom_fields.seed_by(code: "stop_area_test_list") do |field| +    field.resource_type = "StopArea" +    field.name = "Test de Liste" +    field.field_type = "list" +    field.options = { list_values: { "0": "", "1": "Valeur 1", "2": "Valeur 2" }} +  end + +  workgroup.custom_fields.seed_by(code: "stop_area_test_string") do |field| +    field.resource_type = "StopArea" +    field.name = "Test de Texte" +    field.field_type = "string" +  end + +  workgroup.custom_fields.seed_by(code: "stop_area_test_integer") do |field| +    field.resource_type = "StopArea" +    field.name = "Test de Nomber" +    field.field_type = "integer" +  end + +  workgroup.custom_fields.seed_by(code: "stop_area_test_attachment") do |field| +    field.resource_type = "StopArea" +    field.name = "Test de Piece Jointe" +    field.field_type = "attachment" +  end +end diff --git a/db/seeds/seed_helpers.rb b/db/seeds/seed_helpers.rb index 8e47e10bd..708362a6c 100644 --- a/db/seeds/seed_helpers.rb +++ b/db/seeds/seed_helpers.rb @@ -1,6 +1,6 @@  class ActiveRecord::Base    def self.seed_by(key_attribute, &block) -    model = find_or_create_by! key_attribute +    model = find_or_initialize_by key_attribute      print "Seed #{name} #{key_attribute.inspect} "      yield model diff --git a/db/seeds/stif.seeds.rb b/db/seeds/stif.seeds.rb index bb73b0b9c..98192385f 100644 --- a/db/seeds/stif.seeds.rb +++ b/db/seeds/stif.seeds.rb @@ -12,7 +12,7 @@ stop_area_referential = StopAreaReferential.seed_by(name: "Reflex") do |r|  end  line_referential = LineReferential.seed_by(name: "CodifLigne") do |r| -  r.objectid_format = "stif_netex" +  r.objectid_format = "stif_codifligne"    r.add_member stif, owner: true  end diff --git a/lib/tasks/ci.rake b/lib/tasks/ci.rake index 5b2c8ae3c..d025a9bf1 100644 --- a/lib/tasks/ci.rake +++ b/lib/tasks/ci.rake @@ -10,6 +10,7 @@ namespace :ci do    desc "Prepare CI build"    task :setup do +    cp "config/database.yml", "config/database.yml.orig"      cp "config/database/ci.yml", "config/database.yml"      puts "Use #{database_name} database"      sh "RAILS_ENV=test rake db:drop db:create db:migrate" @@ -28,6 +29,7 @@ namespace :ci do    end    def deploy_env +    return ENV["DEPLOY_ENV"] if ENV["DEPLOY_ENV"]      if git_branch == "master"        "dev"      elsif git_branch.in?(deploy_envs) @@ -54,12 +56,12 @@ namespace :ci do    desc "Deploy after CI"    task :deploy do -    return if ENV["CHOUETTE_DEPLOY_DISABLED"] - -    if deploy_env -      sh "cap #{deploy_env} deploy:migrations" -    else -      puts "No deploy for branch #{git_branch}" +    unless ENV["CHOUETTE_DEPLOY_DISABLED"] +      if deploy_env +        sh "cap #{deploy_env} deploy:migrations deploy:seed" +      else +        puts "No deploy for branch #{git_branch}" +      end      end    end @@ -75,6 +77,9 @@ namespace :ci do      task :clean do        puts "Drop #{database_name} database"        sh "RAILS_ENV=test rake db:drop" + +      # Restore projet config/database.yml +      cp "config/database.yml.orig", "config/database.yml" if File.exists?("config/database.yml.orig")      end    end | 
