diff options
| author | teddywing | 2018-03-05 12:57:31 +0100 | 
|---|---|---|
| committer | GitHub | 2018-03-05 12:57:31 +0100 | 
| commit | 272183f191ef72ec67e8e0923f6d5db9772a16c8 (patch) | |
| tree | 714d835604870712bd22bf48bb59d78f71cd3cd9 | |
| parent | 8df512c4b6dfba376b0dea8d493eadb994427b5b (diff) | |
| parent | 9f218edb7e9b2843c82d85118e5caa51290aebb7 (diff) | |
| download | chouette-core-272183f191ef72ec67e8e0923f6d5db9772a16c8.tar.bz2 | |
Merge pull request #358 from af83/new-ccset-affectation
New ccset affectation
| -rw-r--r-- | app/controllers/workbenches_controller.rb | 11 | ||||
| -rw-r--r-- | app/policies/workbench_policy.rb | 11 | ||||
| -rw-r--r-- | app/views/workbenches/_form.html.slim | 9 | ||||
| -rw-r--r-- | app/views/workbenches/edit.html.slim | 8 | ||||
| -rw-r--r-- | app/views/workbenches/show.html.slim | 2 | ||||
| -rw-r--r-- | config/locales/workbenches.en.yml | 15 | ||||
| -rw-r--r-- | config/locales/workbenches.fr.yml | 15 | ||||
| -rw-r--r-- | config/routes.rb | 4 | ||||
| -rw-r--r-- | db/migrate/20180208174834_add_attributes_to_workbench.rb | 9 | ||||
| -rw-r--r-- | db/schema.rb | 17 | 
10 files changed, 87 insertions, 14 deletions
| diff --git a/app/controllers/workbenches_controller.rb b/app/controllers/workbenches_controller.rb index 2a71fe811..35438eaaf 100644 --- a/app/controllers/workbenches_controller.rb +++ b/app/controllers/workbenches_controller.rb @@ -3,7 +3,10 @@ class WorkbenchesController < ChouetteController    include RansackDateFilter    before_action only: [:show] { set_date_time_params("validity_period", Date) }    defaults resource_class: Workbench -  respond_to :html, only: [:show, :index] + +  include PolicyChecker +   +  respond_to :html, except: :destroy    def index      redirect_to dashboard_path @@ -24,7 +27,6 @@ class WorkbenchesController < ChouetteController          current_workbench_id: params[:id]        }      ) -    show!    end    def delete_referentials @@ -38,6 +40,11 @@ class WorkbenchesController < ChouetteController    end    private + +  def workbench_params +    params.require(:workbench).permit(:import_compliance_control_set_id, :merge_compliance_control_set_id) +  end +    def resource      @workbench = current_organisation.workbenches.find params[:id]    end diff --git a/app/policies/workbench_policy.rb b/app/policies/workbench_policy.rb new file mode 100644 index 000000000..7b925e91a --- /dev/null +++ b/app/policies/workbench_policy.rb @@ -0,0 +1,11 @@ +class WorkbenchPolicy < ApplicationPolicy +  class Scope < Scope +    def resolve +      scope +    end +  end + +  def update? +    true +  end +end diff --git a/app/views/workbenches/_form.html.slim b/app/views/workbenches/_form.html.slim new file mode 100644 index 000000000..534a5f378 --- /dev/null +++ b/app/views/workbenches/_form.html.slim @@ -0,0 +1,9 @@ += simple_form_for @workbench, html: { class: 'form-horizontal', id: 'workbench_form' }, wrapper: :horizontal_form do |f| +  .row +    .col-lg-12 +      = f.input :import_compliance_control_set_id, as: :select, collection: current_organisation.compliance_control_sets, value_method: :id +      = f.input :merge_compliance_control_set_id, as: :select, collection: current_organisation.compliance_control_sets, value_method: :id + +  .separator + +  = f.button :submit, t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'workbench_form' diff --git a/app/views/workbenches/edit.html.slim b/app/views/workbenches/edit.html.slim new file mode 100644 index 000000000..893024490 --- /dev/null +++ b/app/views/workbenches/edit.html.slim @@ -0,0 +1,8 @@ +- breadcrumb @workbench +- page_header_content_for @workbench + +.page_content + .container-fluid +   .row +     .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-10.col-sm-offset-1 +       == render 'form' diff --git a/app/views/workbenches/show.html.slim b/app/views/workbenches/show.html.slim index 159aa8ea2..5c2468296 100644 --- a/app/views/workbenches/show.html.slim +++ b/app/views/workbenches/show.html.slim @@ -3,6 +3,8 @@  - content_for :page_header_content do    .row.mb-sm      .col-lg-12.text-right +      - if policy(Workbench).update? +        = link_to t('workbenches.actions.configure'), edit_workbench_path(@workbench), class: 'btn btn-primary'        - if policy(Referential).create?          = link_to t('actions.import'), workbench_imports_path(@workbench), class: 'btn btn-primary'          = link_to t('actions.add'), new_workbench_referential_path(@workbench), class: 'btn btn-primary' diff --git a/config/locales/workbenches.en.yml b/config/locales/workbenches.en.yml index 7f21f47a0..2d9b27045 100644 --- a/config/locales/workbenches.en.yml +++ b/config/locales/workbenches.en.yml @@ -2,6 +2,14 @@ en:    workbenches:      show:        title: "%{name}" +    edit: +      title: "Configure the workbench" +    update: +      title: "Configure the workbench" +    referential_count: +      zero: "There are no referentials in your workbench" +      one: "There is one referential in your workbench" +      other: "There are #{count} referentials in your workbench"      index:        title: "%{organisation} dashboard"        offers: @@ -12,10 +20,9 @@ en:          calendars: "Calendars"          see: "See the list"          no_content: "No content yet." -    referential_count: -      zero: "There is no referential in your workbench" -      one: "There is one referential in your workbench" -      other: "There are #{count} referentials in your workbench" +    actions: +      show_output: "Merge offer" +      affect_ccset: "Configure"    activerecord:      models:        workbench: diff --git a/config/locales/workbenches.fr.yml b/config/locales/workbenches.fr.yml index e7a392e66..8eee1a516 100644 --- a/config/locales/workbenches.fr.yml +++ b/config/locales/workbenches.fr.yml @@ -2,12 +2,27 @@ fr:    workbenches:      show:        title: "%{name}" +    edit: +      title: "Configurer l'espace de travail" +    update: +      title: "Configurer l'espace de travail"      referential_count:        zero: "Aucun jeu de données dans cet espace de travail"        one: "1 jeu de données dans cet espace de travail"        other: "#{count} jeux de données dans cet espace de travail" +    index: +      title: "%{organisation} dashboard" +      offers: +        title: "Offre de transport" +        organisation: "Offres de mon Organisation" +        idf: "Offres IDF" +        referentials: "Jeux de données" +        calendars: "Calendriers" +        see: "Voir la liste" +        no_content: "Aucun contenu"      actions:        show_output: "Finaliser l'Offre" +      configure: "Configurer"    activerecord:      models:        workbench: diff --git a/config/routes.rb b/config/routes.rb index 456cb66f5..a3a21511c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,7 +3,7 @@ require 'sidekiq/web'  ChouetteIhm::Application.routes.draw do    resource :dashboard -  resources :workbenches, only: [:show, :index] do +  resources :workbenches, except: [:destroy] do      delete :referentials, on: :member, action: :delete_referentials      resources :imports do        get :download, on: :member @@ -174,7 +174,7 @@ ChouetteIhm::Application.routes.draw do    namespace :api do      namespace :v1 do -      resources :workbenches, only: [:index, :show] do +      resources :workbenches, except: [:destroy] do          resources :imports, only: [:index, :show, :create]        end        resources :access_links, only: [:index, :show] diff --git a/db/migrate/20180208174834_add_attributes_to_workbench.rb b/db/migrate/20180208174834_add_attributes_to_workbench.rb new file mode 100644 index 000000000..02002a772 --- /dev/null +++ b/db/migrate/20180208174834_add_attributes_to_workbench.rb @@ -0,0 +1,9 @@ +class AddAttributesToWorkbench < ActiveRecord::Migration +  def change +    add_column :workbenches, :import_compliance_control_set_id, :integer, limit: 8 +    add_column :workbenches, :merge_compliance_control_set_id, :integer, limit: 8 + +    add_index :workbenches, :import_compliance_control_set_id +    add_index :workbenches, :merge_compliance_control_set_id +  end +end diff --git a/db/schema.rb b/db/schema.rb index 045fc658d..927c80b15 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -90,6 +90,7 @@ ActiveRecord::Schema.define(version: 20180227151937) do      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 @@ -421,9 +422,9 @@ ActiveRecord::Schema.define(version: 20180227151937) 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 @@ -1007,17 +1008,21 @@ ActiveRecord::Schema.define(version: 20180227151937) do    create_table "workbenches", id: :bigserial, force: :cascade do |t|      t.string   "name" -    t.integer  "organisation_id",          limit: 8 +    t.integer  "organisation_id",                  limit: 8      t.datetime "created_at"      t.datetime "updated_at" -    t.integer  "line_referential_id",      limit: 8 -    t.integer  "stop_area_referential_id", limit: 8 -    t.integer  "output_id",                limit: 8 +    t.integer  "line_referential_id",              limit: 8 +    t.integer  "stop_area_referential_id",         limit: 8 +    t.integer  "output_id",                        limit: 8      t.string   "objectid_format" -    t.integer  "workgroup_id",             limit: 8 +    t.integer  "workgroup_id",                     limit: 8 +    t.integer  "import_compliance_control_set_id", limit: 8 +    t.integer  "merge_compliance_control_set_id",  limit: 8    end +  add_index "workbenches", ["import_compliance_control_set_id"], name: "index_workbenches_on_import_compliance_control_set_id", using: :btree    add_index "workbenches", ["line_referential_id"], name: "index_workbenches_on_line_referential_id", using: :btree +  add_index "workbenches", ["merge_compliance_control_set_id"], name: "index_workbenches_on_merge_compliance_control_set_id", using: :btree    add_index "workbenches", ["organisation_id"], name: "index_workbenches_on_organisation_id", using: :btree    add_index "workbenches", ["stop_area_referential_id"], name: "index_workbenches_on_stop_area_referential_id", using: :btree    add_index "workbenches", ["workgroup_id"], name: "index_workbenches_on_workgroup_id", using: :btree | 
