From 82f611cd417d7e3a98f4fa7d21e2f94e6bc9a011 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Mon, 25 Sep 2017 18:19:21 +0200 Subject: add compliance_check_sets structure Refs #3564 --- .../compliance_check_sets_controller.rb | 54 ++++++++++++++++++++++ app/decorators/compliance_check_set_decorator.rb | 8 ++++ app/helpers/compliance_check_set_helper.rb | 2 + app/models/compliance_check_set.rb | 5 ++ app/models/workbench.rb | 1 + app/policies/compliance_check_set_policy.rb | 7 +++ app/views/compliance_check_sets/_filters.html.slim | 24 ++++++++++ app/views/compliance_check_sets/index.html.slim | 54 ++++++++++++++++++++++ app/views/compliance_check_sets/show.html.slim | 12 +++++ .../layouts/navigation/_main_nav_left.html.slim | 2 +- config/locales/compliance_check_sets.en.yml | 24 ++++++++++ config/locales/compliance_check_sets.fr.yml | 24 ++++++++++ config/routes.rb | 4 +- ...0170905135646_create_compliance_check_blocks.rb | 2 +- .../20170906084628_create_compliance_checks.rb | 2 +- lib/stif/permission_translator.rb | 8 +++- .../compliance_check_sets_controller_spec.rb | 24 ++++++++++ .../compliance_check_set_decorator_spec.rb | 4 ++ spec/helpers/compliance_check_set_helper_spec.rb | 15 ++++++ 19 files changed, 270 insertions(+), 6 deletions(-) create mode 100644 app/controllers/compliance_check_sets_controller.rb create mode 100644 app/decorators/compliance_check_set_decorator.rb create mode 100644 app/helpers/compliance_check_set_helper.rb create mode 100644 app/policies/compliance_check_set_policy.rb create mode 100644 app/views/compliance_check_sets/_filters.html.slim create mode 100644 app/views/compliance_check_sets/index.html.slim create mode 100644 app/views/compliance_check_sets/show.html.slim create mode 100644 config/locales/compliance_check_sets.en.yml create mode 100644 config/locales/compliance_check_sets.fr.yml create mode 100644 spec/controllers/compliance_check_sets_controller_spec.rb create mode 100644 spec/decorators/compliance_check_set_decorator_spec.rb create mode 100644 spec/helpers/compliance_check_set_helper_spec.rb diff --git a/app/controllers/compliance_check_sets_controller.rb b/app/controllers/compliance_check_sets_controller.rb new file mode 100644 index 000000000..989db1aeb --- /dev/null +++ b/app/controllers/compliance_check_sets_controller.rb @@ -0,0 +1,54 @@ +class ComplianceCheckSetsController < BreadcrumbController + defaults resource_class: ComplianceCheckSet + before_action :ransack_created_at_params, only: [:index] + respond_to :html + + belongs_to :workbench + + def index + index! do |format| + scope = ransack_period @compliance_check_sets + @q_for_form = scope.ransack(params[:q]) + format.html { + @compliance_check_sets = decorate_compliance_check_sets(@q_for_form.result) + } + end + end + + def decorate_compliance_check_sets(compliance_check_sets) + ModelDecorator.decorate( + compliance_check_sets, + with: ComplianceCheckSetDecorator + ) + end + + private + + def ransack_created_at_params + start_date = [] + end_date = [] + + if params[:q] && params[:q][:created_at] && !params[:q][:created_at].has_value?(nil) && !params[:q][:created_at].has_value?("") + [1, 2, 3].each do |key| + start_date << params[:q][:created_at]["begin(#{key}i)"].to_i + end_date << params[:q][:created_at]["end(#{key}i)"].to_i + end + params[:q].delete([:created_at]) + @begin_range = DateTime.new(*start_date, 0, 0, 0) rescue nil + @end_range = DateTime.new(*end_date, 23, 59, 59) rescue nil + end + end + + # Fake ransack filter + def ransack_period scope + return scope unless !!@begin_range && !!@end_range + + if @begin_range > @end_range + flash.now[:error] = t('imports.filters.error_period_filter') + else + scope = scope.where_created_at_between(@begin_range, @end_range) + end + scope + end + +end \ No newline at end of file diff --git a/app/decorators/compliance_check_set_decorator.rb b/app/decorators/compliance_check_set_decorator.rb new file mode 100644 index 000000000..5f3821cbe --- /dev/null +++ b/app/decorators/compliance_check_set_decorator.rb @@ -0,0 +1,8 @@ +class ComplianceCheckSetDecorator < Draper::Decorator + delegate_all + + def action_links + links = [] + end + +end diff --git a/app/helpers/compliance_check_set_helper.rb b/app/helpers/compliance_check_set_helper.rb new file mode 100644 index 000000000..82680b304 --- /dev/null +++ b/app/helpers/compliance_check_set_helper.rb @@ -0,0 +1,2 @@ +module ComplianceCheckSetHelper +end diff --git a/app/models/compliance_check_set.rb b/app/models/compliance_check_set.rb index 7b6400a21..3c62221f0 100644 --- a/app/models/compliance_check_set.rb +++ b/app/models/compliance_check_set.rb @@ -7,4 +7,9 @@ class ComplianceCheckSet < ActiveRecord::Base belongs_to :parent, polymorphic: true enumerize :status, in: %w[new pending successful warning failed running aborted canceled] + + scope :where_created_at_between, ->(start_date, end_date) do + where('created_at BETWEEN ? AND ?', start_date, end_date) + end + end diff --git a/app/models/workbench.rb b/app/models/workbench.rb index 30692e625..cd90f8253 100644 --- a/app/models/workbench.rb +++ b/app/models/workbench.rb @@ -10,6 +10,7 @@ class Workbench < ActiveRecord::Base has_many :stop_areas, through: :stop_area_referential has_many :imports has_many :workbench_imports + has_many :compliance_check_sets validates :name, presence: true validates :organisation, presence: true diff --git a/app/policies/compliance_check_set_policy.rb b/app/policies/compliance_check_set_policy.rb new file mode 100644 index 000000000..3f715649e --- /dev/null +++ b/app/policies/compliance_check_set_policy.rb @@ -0,0 +1,7 @@ +class ComplianceCheckSetPolicy < ApplicationPolicy + class Scope < Scope + def resolve + scope + end + end +end diff --git a/app/views/compliance_check_sets/_filters.html.slim b/app/views/compliance_check_sets/_filters.html.slim new file mode 100644 index 000000000..b589e381f --- /dev/null +++ b/app/views/compliance_check_sets/_filters.html.slim @@ -0,0 +1,24 @@ += search_form_for @q_for_form, url: workbench_compliance_check_sets_path(current_offer_workbench), builder: SimpleForm::FormBuilder, class: 'form form-filter' do |f| + .ffg-row + .input-group.search_bar + = f.search_field :referential_name_cont, class: 'form-control', placeholder: t('compliance_check_sets.filters.name') + span.input-group-btn + button.btn.btn-default type='submit' + span.fa.fa-search + + .ffg-row + .form-group.togglable + = f.label t('activerecord.attributes.compliance_check_set.assignment'), required: false, class: 'control-label' + = f.input :parent_type_eq_any, collection: ComplianceCheckSet.order('parent_type'), as: :check_boxes, label: false, label_method: lambda {|w| ("#{w}").html_safe}, required: false, wrapper_html: {class: 'checkbox_list'} + + .form-group.togglable + = f.label Import.human_attribute_name(:created_at), required: false, class: 'control-label' + .filter_menu + = f.simple_fields_for :created_at do |p| + = p.input :begin, as: :date, label: false, wrapper_html: {class: 'date smart_date filter_menu-item'}, default: @begin_range, include_blank: @begin_range ? false : true + = p.input :end, as: :date, label: false, wrapper_html: {class: 'date smart_date filter_menu-item'}, default: @end_range, include_blank: @end_range ? false : true + + .actions + = link_to t('actions.erase'), @compliance_checks_sets, class: 'btn btn-link' + = f.submit t('actions.filter'), class: 'btn btn-default', id: 'referential_filter_btn' + diff --git a/app/views/compliance_check_sets/index.html.slim b/app/views/compliance_check_sets/index.html.slim new file mode 100644 index 000000000..cad20172b --- /dev/null +++ b/app/views/compliance_check_sets/index.html.slim @@ -0,0 +1,54 @@ +/ PageHeader +- header_params = ['jeux-de-donnees', + t('compliance_check_sets.index.title'), + ''] += pageheader(*header_params) do + + / Below is secundary actions & optional contents (filters, ...) + .row.mb-sm + .col-lg-12.text-right + +/ PageContent +.page_content + .container-fluid + .row + .col-lg-12 + = render 'filters' + .row + .col-lg-12 + .select_table + = table_builder_2 @compliance_check_sets, + [ \ + TableBuilderHelper::Column.new( \ + key: :ref, \ + attribute: 'referential_id' \ + ), \ + TableBuilderHelper::Column.new( \ + key: :creation_date, \ + attribute: Proc.new { |n| l(n.created_at, format: :long) if n.created_at } \ + ), \ + TableBuilderHelper::Column.new( \ + key: :associated_object, \ + attribute: Proc.new{|n| n.referential.name}, \ + link_to: lambda do |referential| \ + referential_path(referential, current_workbench_id: params[:id]) \ + end \ + ), \ + TableBuilderHelper::Column.new( \ + key: :assignment, \ + attribute: 'parent_type' \ + ), \ + TableBuilderHelper::Column.new(\ + key: :control_game, \ + attribute: 'control_game' \ + ), \ + ], + sortable: true, + links: [:show], + cls: 'table has-filter has-search' + - unless @compliance_check_sets.any? + .row.mt-xs + .col-lg-12 + = replacement_msg t('compliance_check_sets.search_no_results') + + diff --git a/app/views/compliance_check_sets/show.html.slim b/app/views/compliance_check_sets/show.html.slim new file mode 100644 index 000000000..1b96b70fc --- /dev/null +++ b/app/views/compliance_check_sets/show.html.slim @@ -0,0 +1,12 @@ +/ PageHeader += pageheader 'jeux-de-donnees', + @compliance_check_set.referential.name, + 'Lorem ipsum dolor sit amet' +/ PageContent +.page_content + .container-fluid + .row + .col-lg-6.col-md-6.col-sm-12.col-xs-12 + = definition_list t('metadatas'), + ComplianceCheckSet.human_attribute_name(:id) => @compliance_check_set.referential.id, + ComplianceCheckSet.human_attribute_name(:name) => @compliance_check_set.referential.name \ No newline at end of file diff --git a/app/views/layouts/navigation/_main_nav_left.html.slim b/app/views/layouts/navigation/_main_nav_left.html.slim index 12139c93b..062c9383c 100644 --- a/app/views/layouts/navigation/_main_nav_left.html.slim +++ b/app/views/layouts/navigation/_main_nav_left.html.slim @@ -37,7 +37,7 @@ span Import = link_to calendars_path, class: 'list-group-item' do span Modèles de calendrier - = link_to '#', class: 'list-group-item' do + = link_to workbench_compliance_check_sets_path(current_offer_workbench), class: 'list-group-item' do span Rapport de contrôle = link_to compliance_control_sets_path, class: 'list-group-item' do span Jeux de contrôle diff --git a/config/locales/compliance_check_sets.en.yml b/config/locales/compliance_check_sets.en.yml new file mode 100644 index 000000000..d18381e33 --- /dev/null +++ b/config/locales/compliance_check_sets.en.yml @@ -0,0 +1,24 @@ +fr: + compliance_check_sets: + index: + title: Control reports + new: Creating a Control Report + edit: Editing a Control Report + actions: + new: Add + edit: Edit + destroy: Delete + destroy_confirm: Are you sure to delete this control report ? + filters: + name: Specify a control report name... + search_no_results: No control reports match your search + activerecord: + models: + compliance_check_set: Calendrier + attributes: + compliance_check_set: + ref: réf + creation_date: Date and time of creation + associated_object: Associated object + assignment: Affectation + control_game: Control Game diff --git a/config/locales/compliance_check_sets.fr.yml b/config/locales/compliance_check_sets.fr.yml new file mode 100644 index 000000000..f5aabe89d --- /dev/null +++ b/config/locales/compliance_check_sets.fr.yml @@ -0,0 +1,24 @@ +fr: + compliance_check_sets: + index: + title: Rapports de contrôle + new: Création d'un rapport de contrôle + edit: Édition d'un rapport de contrôle + actions: + new: Ajouter + edit: Editer + destroy: Supprimer + destroy_confirm: Etes vous sûr de supprimer ce rapport de contrôle ? + filters: + name: Indiquez un nom d'un objet associé... + search_no_results: Aucun rapport de contrôle ne correspond à votre recherche + activerecord: + models: + compliance_check_set: Calendrier + attributes: + compliance_check_set: + ref: réf + creation_date: Date et heure de création + associated_object: Objet associé + assignment: Affectation + control_game: jeu de contrôle diff --git a/config/routes.rb b/config/routes.rb index ef625db1f..b976e6a6b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -8,7 +8,9 @@ ChouetteIhm::Application.routes.draw do resources :import_resources, only: [:index] do resources :import_messages, only: [:index] end - + end + resources :compliance_check_sets, :only => [:index, :show] do + resources :compliance_checks, :only => [:show] end end diff --git a/db/migrate/20170905135646_create_compliance_check_blocks.rb b/db/migrate/20170905135646_create_compliance_check_blocks.rb index c461e656b..741a8b6e6 100644 --- a/db/migrate/20170905135646_create_compliance_check_blocks.rb +++ b/db/migrate/20170905135646_create_compliance_check_blocks.rb @@ -3,7 +3,7 @@ class CreateComplianceCheckBlocks < ActiveRecord::Migration create_table :compliance_check_blocks do |t| t.string :name t.hstore :condition_attributes - t.references :compliance_check_set, index: true, foreign_key: true + t.references :compliance_check_sets, index: true, foreign_key: true t.timestamps null: false end diff --git a/db/migrate/20170906084628_create_compliance_checks.rb b/db/migrate/20170906084628_create_compliance_checks.rb index 1d6bdaaf2..a4c9ad5fd 100644 --- a/db/migrate/20170906084628_create_compliance_checks.rb +++ b/db/migrate/20170906084628_create_compliance_checks.rb @@ -1,7 +1,7 @@ class CreateComplianceChecks < ActiveRecord::Migration def change create_table :compliance_checks do |t| - t.references :compliance_check_set, index: true, foreign_key: true + t.references :compliance_check_sets, index: true, foreign_key: true t.references :compliance_check_block, index: true, foreign_key: true t.string :type t.json :control_attributes diff --git a/lib/stif/permission_translator.rb b/lib/stif/permission_translator.rb index 2bc565968..9a82e733c 100644 --- a/lib/stif/permission_translator.rb +++ b/lib/stif/permission_translator.rb @@ -17,14 +17,18 @@ module Stif def all_resources %w[ access_points - connection_links calendars + connection_links + calendars footnotes journey_patterns - referentials routes routing_constraint_zones + referentials routes + routing_constraint_zones time_tables vehicle_journeys api_keys compliance_controls + compliance_controls_sets + compliance_check_sets ] end diff --git a/spec/controllers/compliance_check_sets_controller_spec.rb b/spec/controllers/compliance_check_sets_controller_spec.rb new file mode 100644 index 000000000..5f5cea82f --- /dev/null +++ b/spec/controllers/compliance_check_sets_controller_spec.rb @@ -0,0 +1,24 @@ +require 'rails_helper' + +RSpec.describe ComplianceCheckSetsController, type: :controller do + login_user + + let(:compliance_check_set) { create :compliance_check_set } + + workbench_compliance_check_sets_path(current_offer_workbench) + + describe "GET show" do + it 'should be successful' do + get :show, id: compliance_check_set.id + expect(response).to be_success + end + end + + describe "GET index" do + it 'should be successful' do + get :index, id: compliance_check_set.id + expect(response).to be_success + end + end + +end diff --git a/spec/decorators/compliance_check_set_decorator_spec.rb b/spec/decorators/compliance_check_set_decorator_spec.rb new file mode 100644 index 000000000..d1252f509 --- /dev/null +++ b/spec/decorators/compliance_check_set_decorator_spec.rb @@ -0,0 +1,4 @@ +require 'spec_helper' + +describe ComplianceCheckSetDecorator do +end diff --git a/spec/helpers/compliance_check_set_helper_spec.rb b/spec/helpers/compliance_check_set_helper_spec.rb new file mode 100644 index 000000000..675ab872d --- /dev/null +++ b/spec/helpers/compliance_check_set_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the ComplianceCheckSetHelper. For example: +# +# describe ComplianceCheckSetHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe ComplianceCheckSetHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end -- cgit v1.2.3 From efce9eac3812c005409ce87028877e4a40724949 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Tue, 26 Sep 2017 16:29:20 +0200 Subject: show compliance_control_set in compliance_check_set table, fix compliance_check_set spec --- app/views/compliance_check_sets/index.html.slim | 2 +- spec/controllers/compliance_check_sets_controller_spec.rb | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/views/compliance_check_sets/index.html.slim b/app/views/compliance_check_sets/index.html.slim index cad20172b..e33905fce 100644 --- a/app/views/compliance_check_sets/index.html.slim +++ b/app/views/compliance_check_sets/index.html.slim @@ -40,7 +40,7 @@ ), \ TableBuilderHelper::Column.new(\ key: :control_game, \ - attribute: 'control_game' \ + attribute: Proc.new{ |n| (n.compliance_control_set.name) if n.compliance_control_set} \ ), \ ], sortable: true, diff --git a/spec/controllers/compliance_check_sets_controller_spec.rb b/spec/controllers/compliance_check_sets_controller_spec.rb index 5f5cea82f..804b0a658 100644 --- a/spec/controllers/compliance_check_sets_controller_spec.rb +++ b/spec/controllers/compliance_check_sets_controller_spec.rb @@ -5,18 +5,16 @@ RSpec.describe ComplianceCheckSetsController, type: :controller do let(:compliance_check_set) { create :compliance_check_set } - workbench_compliance_check_sets_path(current_offer_workbench) - describe "GET show" do it 'should be successful' do - get :show, id: compliance_check_set.id + get :show, workbench_id: compliance_check_set.workbench.id, id: compliance_check_set.id expect(response).to be_success end end describe "GET index" do it 'should be successful' do - get :index, id: compliance_check_set.id + get :index, workbench_id: compliance_check_set.workbench.id, id: compliance_check_set.id expect(response).to be_success end end -- cgit v1.2.3 From 9b83abfc89b9b1bb1d55f8728ecf7d59ac971b99 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Thu, 28 Sep 2017 11:01:41 +0200 Subject: fix review for pull request --- app/controllers/compliance_check_sets_controller.rb | 13 +++++-------- app/views/compliance_check_sets/index.html.slim | 8 ++++---- config/locales/compliance_check_sets.en.yml | 1 + config/locales/compliance_check_sets.fr.yml | 1 + config/routes.rb | 4 ++-- spec/decorators/compliance_check_set_decorator_spec.rb | 4 ---- spec/helpers/compliance_check_set_helper_spec.rb | 15 --------------- 7 files changed, 13 insertions(+), 33 deletions(-) delete mode 100644 spec/decorators/compliance_check_set_decorator_spec.rb delete mode 100644 spec/helpers/compliance_check_set_helper_spec.rb diff --git a/app/controllers/compliance_check_sets_controller.rb b/app/controllers/compliance_check_sets_controller.rb index 989db1aeb..7d964731d 100644 --- a/app/controllers/compliance_check_sets_controller.rb +++ b/app/controllers/compliance_check_sets_controller.rb @@ -10,17 +10,14 @@ class ComplianceCheckSetsController < BreadcrumbController scope = ransack_period @compliance_check_sets @q_for_form = scope.ransack(params[:q]) format.html { - @compliance_check_sets = decorate_compliance_check_sets(@q_for_form.result) + @compliance_check_sets = ModelDecorator.decorate( + @q_for_form.result, + with: ComplianceCheckSetDecorator + ) } end end - def decorate_compliance_check_sets(compliance_check_sets) - ModelDecorator.decorate( - compliance_check_sets, - with: ComplianceCheckSetDecorator - ) - end private @@ -44,7 +41,7 @@ class ComplianceCheckSetsController < BreadcrumbController return scope unless !!@begin_range && !!@end_range if @begin_range > @end_range - flash.now[:error] = t('imports.filters.error_period_filter') + flash.now[:error] = t('compliance_check_sets.filters.error_period_filter') else scope = scope.where_created_at_between(@begin_range, @end_range) end diff --git a/app/views/compliance_check_sets/index.html.slim b/app/views/compliance_check_sets/index.html.slim index e33905fce..3e9b05393 100644 --- a/app/views/compliance_check_sets/index.html.slim +++ b/app/views/compliance_check_sets/index.html.slim @@ -18,7 +18,7 @@ .col-lg-12 .select_table = table_builder_2 @compliance_check_sets, - [ \ + [ \ TableBuilderHelper::Column.new( \ key: :ref, \ attribute: 'referential_id' \ @@ -43,9 +43,9 @@ attribute: Proc.new{ |n| (n.compliance_control_set.name) if n.compliance_control_set} \ ), \ ], - sortable: true, - links: [:show], - cls: 'table has-filter has-search' + sortable: true, + links: [:show], + cls: 'table has-filter has-search' - unless @compliance_check_sets.any? .row.mt-xs .col-lg-12 diff --git a/config/locales/compliance_check_sets.en.yml b/config/locales/compliance_check_sets.en.yml index d18381e33..b4b9aa1a1 100644 --- a/config/locales/compliance_check_sets.en.yml +++ b/config/locales/compliance_check_sets.en.yml @@ -11,6 +11,7 @@ fr: destroy_confirm: Are you sure to delete this control report ? filters: name: Specify a control report name... + error_period_filter: End date must be greater or equal than begin date search_no_results: No control reports match your search activerecord: models: diff --git a/config/locales/compliance_check_sets.fr.yml b/config/locales/compliance_check_sets.fr.yml index f5aabe89d..d50bdbfa3 100644 --- a/config/locales/compliance_check_sets.fr.yml +++ b/config/locales/compliance_check_sets.fr.yml @@ -11,6 +11,7 @@ fr: destroy_confirm: Etes vous sûr de supprimer ce rapport de contrôle ? filters: name: Indiquez un nom d'un objet associé... + error_period_filter: La date de fin doit être supérieure ou égale à la date de début search_no_results: Aucun rapport de contrôle ne correspond à votre recherche activerecord: models: diff --git a/config/routes.rb b/config/routes.rb index b976e6a6b..6477cc145 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -9,8 +9,8 @@ ChouetteIhm::Application.routes.draw do resources :import_messages, only: [:index] end end - resources :compliance_check_sets, :only => [:index, :show] do - resources :compliance_checks, :only => [:show] + resources :compliance_check_sets, only: [:index, :show] do + resources :compliance_checks, only: [:show] end end diff --git a/spec/decorators/compliance_check_set_decorator_spec.rb b/spec/decorators/compliance_check_set_decorator_spec.rb deleted file mode 100644 index d1252f509..000000000 --- a/spec/decorators/compliance_check_set_decorator_spec.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'spec_helper' - -describe ComplianceCheckSetDecorator do -end diff --git a/spec/helpers/compliance_check_set_helper_spec.rb b/spec/helpers/compliance_check_set_helper_spec.rb deleted file mode 100644 index 675ab872d..000000000 --- a/spec/helpers/compliance_check_set_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rails_helper' - -# Specs in this file have access to a helper object that includes -# the ComplianceCheckSetHelper. For example: -# -# describe ComplianceCheckSetHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# expect(helper.concat_strings("this","that")).to eq("this that") -# end -# end -# end -RSpec.describe ComplianceCheckSetHelper, type: :helper do - pending "add some examples to (or delete) #{__FILE__}" -end -- cgit v1.2.3 From 290516ea175158ffb388734375c17143dfb794f5 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Thu, 28 Sep 2017 11:11:08 +0200 Subject: revert wrong modifications migrations --- db/migrate/20170905135646_create_compliance_check_blocks.rb | 2 +- db/migrate/20170906084628_create_compliance_checks.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/db/migrate/20170905135646_create_compliance_check_blocks.rb b/db/migrate/20170905135646_create_compliance_check_blocks.rb index 741a8b6e6..c461e656b 100644 --- a/db/migrate/20170905135646_create_compliance_check_blocks.rb +++ b/db/migrate/20170905135646_create_compliance_check_blocks.rb @@ -3,7 +3,7 @@ class CreateComplianceCheckBlocks < ActiveRecord::Migration create_table :compliance_check_blocks do |t| t.string :name t.hstore :condition_attributes - t.references :compliance_check_sets, index: true, foreign_key: true + t.references :compliance_check_set, index: true, foreign_key: true t.timestamps null: false end diff --git a/db/migrate/20170906084628_create_compliance_checks.rb b/db/migrate/20170906084628_create_compliance_checks.rb index a4c9ad5fd..1d6bdaaf2 100644 --- a/db/migrate/20170906084628_create_compliance_checks.rb +++ b/db/migrate/20170906084628_create_compliance_checks.rb @@ -1,7 +1,7 @@ class CreateComplianceChecks < ActiveRecord::Migration def change create_table :compliance_checks do |t| - t.references :compliance_check_sets, index: true, foreign_key: true + t.references :compliance_check_set, index: true, foreign_key: true t.references :compliance_check_block, index: true, foreign_key: true t.string :type t.json :control_attributes -- cgit v1.2.3 From 2867f7b992ea38934f69e86dd8d6dc9cc95b0afe Mon Sep 17 00:00:00 2001 From: Guillaume Date: Thu, 28 Sep 2017 12:32:09 +0200 Subject: fix locales translations, remove unused array for date filters --- app/controllers/compliance_check_sets_controller.rb | 2 +- app/views/compliance_check_sets/_filters.html.slim | 2 +- app/views/compliance_check_sets/index.html.slim | 4 ++-- app/views/compliance_check_sets/show.html.slim | 3 +-- app/views/compliance_control_sets/index.html.slim | 10 +++++----- config/locales/compliance_check_sets.en.yml | 20 +++++++++----------- config/locales/compliance_check_sets.fr.yml | 8 +++----- config/locales/compliance_control_sets.en.yml | 2 +- config/locales/compliance_control_sets.fr.yml | 2 +- lib/stif/permission_translator.rb | 3 ++- 10 files changed, 26 insertions(+), 30 deletions(-) diff --git a/app/controllers/compliance_check_sets_controller.rb b/app/controllers/compliance_check_sets_controller.rb index 7d964731d..d61fbafdb 100644 --- a/app/controllers/compliance_check_sets_controller.rb +++ b/app/controllers/compliance_check_sets_controller.rb @@ -30,7 +30,7 @@ class ComplianceCheckSetsController < BreadcrumbController start_date << params[:q][:created_at]["begin(#{key}i)"].to_i end_date << params[:q][:created_at]["end(#{key}i)"].to_i end - params[:q].delete([:created_at]) + params[:q].delete(:created_at) @begin_range = DateTime.new(*start_date, 0, 0, 0) rescue nil @end_range = DateTime.new(*end_date, 23, 59, 59) rescue nil end diff --git a/app/views/compliance_check_sets/_filters.html.slim b/app/views/compliance_check_sets/_filters.html.slim index b589e381f..609754eec 100644 --- a/app/views/compliance_check_sets/_filters.html.slim +++ b/app/views/compliance_check_sets/_filters.html.slim @@ -8,7 +8,7 @@ .ffg-row .form-group.togglable - = f.label t('activerecord.attributes.compliance_check_set.assignment'), required: false, class: 'control-label' + = f.label t('activerecord.attributes.compliance_check_set.assigned_to'), required: false, class: 'control-label' = f.input :parent_type_eq_any, collection: ComplianceCheckSet.order('parent_type'), as: :check_boxes, label: false, label_method: lambda {|w| ("#{w}").html_safe}, required: false, wrapper_html: {class: 'checkbox_list'} .form-group.togglable diff --git a/app/views/compliance_check_sets/index.html.slim b/app/views/compliance_check_sets/index.html.slim index 3e9b05393..38c4babcf 100644 --- a/app/views/compliance_check_sets/index.html.slim +++ b/app/views/compliance_check_sets/index.html.slim @@ -35,11 +35,11 @@ end \ ), \ TableBuilderHelper::Column.new( \ - key: :assignment, \ + key: :assigned_to, \ attribute: 'parent_type' \ ), \ TableBuilderHelper::Column.new(\ - key: :control_game, \ + key: :compliance_control_set, \ attribute: Proc.new{ |n| (n.compliance_control_set.name) if n.compliance_control_set} \ ), \ ], diff --git a/app/views/compliance_check_sets/show.html.slim b/app/views/compliance_check_sets/show.html.slim index 1b96b70fc..4e965947d 100644 --- a/app/views/compliance_check_sets/show.html.slim +++ b/app/views/compliance_check_sets/show.html.slim @@ -1,7 +1,6 @@ / PageHeader = pageheader 'jeux-de-donnees', - @compliance_check_set.referential.name, - 'Lorem ipsum dolor sit amet' + @compliance_check_set.referential.name / PageContent .page_content .container-fluid diff --git a/app/views/compliance_control_sets/index.html.slim b/app/views/compliance_control_sets/index.html.slim index aee1595ef..ecb4eb75b 100644 --- a/app/views/compliance_control_sets/index.html.slim +++ b/app/views/compliance_control_sets/index.html.slim @@ -19,7 +19,7 @@ .col-lg-12 .select_table = table_builder_2 @compliance_control_sets, - [ \ + [ \ TableBuilderHelper::Column.new( \ key: :name, \ attribute: 'name', \ @@ -28,7 +28,7 @@ end \ ), \ TableBuilderHelper::Column.new( \ - key: :assignment, \ + key: :assigned_to, \ attribute: 'assignment' \ ), \ TableBuilderHelper::Column.new( \ @@ -44,9 +44,9 @@ attribute: Proc.new { |n| l(n.updated_at, format: :long) if n.updated_at }, \ ) \ ], - sortable: true, - links: [:show], - cls: 'table has-filter has-search' + sortable: true, + links: [:show], + cls: 'table has-filter has-search' - unless @compliance_control_sets.any? .row.mt-xs .col-lg-12 diff --git a/config/locales/compliance_check_sets.en.yml b/config/locales/compliance_check_sets.en.yml index b4b9aa1a1..89c142a49 100644 --- a/config/locales/compliance_check_sets.en.yml +++ b/config/locales/compliance_check_sets.en.yml @@ -1,25 +1,23 @@ -fr: +en: compliance_check_sets: index: title: Control reports new: Creating a Control Report - edit: Editing a Control Report + edit: Update a Control Report actions: - new: Add - edit: Edit + new: Add a control report + edit: Edit a control report destroy: Delete - destroy_confirm: Are you sure to delete this control report ? + destroy_confirm: Are you sure you want to delete this control report? filters: name: Specify a control report name... - error_period_filter: End date must be greater or equal than begin date + error_period_filter: End date must be greater than or equal to begin date search_no_results: No control reports match your search activerecord: - models: - compliance_check_set: Calendrier attributes: compliance_check_set: ref: réf - creation_date: Date and time of creation + creation_date: Created at associated_object: Associated object - assignment: Affectation - control_game: Control Game + assigned_to: Assigned to + compliance_control_set: Compliance control set diff --git a/config/locales/compliance_check_sets.fr.yml b/config/locales/compliance_check_sets.fr.yml index d50bdbfa3..8c21f33fd 100644 --- a/config/locales/compliance_check_sets.fr.yml +++ b/config/locales/compliance_check_sets.fr.yml @@ -11,15 +11,13 @@ fr: destroy_confirm: Etes vous sûr de supprimer ce rapport de contrôle ? filters: name: Indiquez un nom d'un objet associé... - error_period_filter: La date de fin doit être supérieure ou égale à la date de début + error_period_filter: La date de fin doit être supérieure ou égale à la date de début0 search_no_results: Aucun rapport de contrôle ne correspond à votre recherche activerecord: - models: - compliance_check_set: Calendrier attributes: compliance_check_set: ref: réf creation_date: Date et heure de création associated_object: Objet associé - assignment: Affectation - control_game: jeu de contrôle + assigned_to: Affectation + compliance_control_set: jeu de contrôle diff --git a/config/locales/compliance_control_sets.en.yml b/config/locales/compliance_control_sets.en.yml index 497ca50c3..5426233bd 100644 --- a/config/locales/compliance_control_sets.en.yml +++ b/config/locales/compliance_control_sets.en.yml @@ -18,7 +18,7 @@ fr: attributes: compliance_control_set: name: Name - assignment: Affectation + assigned_to: Assigned to owner_jdc: Owner of the control game control_numbers: Nb contrôle updated_at: Update \ No newline at end of file diff --git a/config/locales/compliance_control_sets.fr.yml b/config/locales/compliance_control_sets.fr.yml index f5bb7c67b..42baf0fcf 100644 --- a/config/locales/compliance_control_sets.fr.yml +++ b/config/locales/compliance_control_sets.fr.yml @@ -18,7 +18,7 @@ fr: attributes: compliance_control_set: name: Nom - assignment: Affectation + assigned_to: Affectation owner_jdc: Propriétaire du jeu de contrôle control_numbers: Nb contrôle updated_at: Mis a jour \ No newline at end of file diff --git a/lib/stif/permission_translator.rb b/lib/stif/permission_translator.rb index 9a82e733c..d8f898b62 100644 --- a/lib/stif/permission_translator.rb +++ b/lib/stif/permission_translator.rb @@ -21,7 +21,8 @@ module Stif calendars footnotes journey_patterns - referentials routes + referentials + routes routing_constraint_zones time_tables vehicle_journeys -- cgit v1.2.3 From 1f9f3ec31464293a7720562f26c48c53f89e7206 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Thu, 28 Sep 2017 14:25:42 +0200 Subject: remove empty helper --- app/helpers/compliance_check_set_helper.rb | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 app/helpers/compliance_check_set_helper.rb diff --git a/app/helpers/compliance_check_set_helper.rb b/app/helpers/compliance_check_set_helper.rb deleted file mode 100644 index 82680b304..000000000 --- a/app/helpers/compliance_check_set_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module ComplianceCheckSetHelper -end -- cgit v1.2.3