From 11dad45ee79f4a662db892fa5cb74010303d838e Mon Sep 17 00:00:00 2001 From: Guillaume Date: Wed, 4 Oct 2017 10:46:26 +0200 Subject: temporarily decorate @compliance_control_set for table builder links Refs #4663 --- app/views/compliance_control_sets/show.html.slim | 2 +- db/schema.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/compliance_control_sets/show.html.slim b/app/views/compliance_control_sets/show.html.slim index 54f95bb34..9a23a679c 100644 --- a/app/views/compliance_control_sets/show.html.slim +++ b/app/views/compliance_control_sets/show.html.slim @@ -70,7 +70,7 @@ .row .col-lg-12 .select_table - = table_builder_2 block.compliance_controls, + = table_builder_2 ModelDecorator.decorate(block.compliance_controls, with: ComplianceControlDecorator), [ \ TableBuilderHelper::Column.new( \ key: :code, \ diff --git a/db/schema.rb b/db/schema.rb index 4a1ad3749..7f02a342d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -407,9 +407,9 @@ ActiveRecord::Schema.define(version: 20171003133042) 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 -- cgit v1.2.3 From 383a0d823ebf875baa08f77ccb0eb8a0f06b866e Mon Sep 17 00:00:00 2001 From: Xinhui Date: Wed, 4 Oct 2017 11:57:25 +0200 Subject: ComplianceControls#new add association field compliance_control_block Refs #4689 --- app/controllers/compliance_controls_controller.rb | 2 +- app/models/compliance_control_block.rb | 3 +++ app/views/compliance_controls/_form.html.slim | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/compliance_controls_controller.rb b/app/controllers/compliance_controls_controller.rb index fc4322c76..d7d84afb3 100644 --- a/app/controllers/compliance_controls_controller.rb +++ b/app/controllers/compliance_controls_controller.rb @@ -25,7 +25,7 @@ class ComplianceControlsController < BreadcrumbController end def compliance_control_params - base = [:name, :code, :origin_code, :criticity, :comment, :control_attributes, :type] + base = [:name, :code, :origin_code, :criticity, :comment, :control_attributes, :type, :compliance_control_block_id] permited = base + dynamic_attributes_params params.require(:compliance_control).permit(permited) end diff --git a/app/models/compliance_control_block.rb b/app/models/compliance_control_block.rb index 5721c00f4..2be8d98a0 100644 --- a/app/models/compliance_control_block.rb +++ b/app/models/compliance_control_block.rb @@ -12,4 +12,7 @@ class ComplianceControlBlock < ActiveRecord::Base validates :transport_mode, presence: true validates :compliance_control_set, presence: true + def label_method + [transport_mode, transport_submode].compact.map {|x| "[#{x}]"}.join + end end diff --git a/app/views/compliance_controls/_form.html.slim b/app/views/compliance_controls/_form.html.slim index 3928f3550..1e56a63b9 100644 --- a/app/views/compliance_controls/_form.html.slim +++ b/app/views/compliance_controls/_form.html.slim @@ -5,6 +5,7 @@ = f.input :type, as: :select, collection: ComplianceControl.subclasses = f.input :code = f.input :criticity + = f.association :compliance_control_block, collection: @compliance_control_set.compliance_control_blocks, label_method: :label_method = f.input :comment - f.object.class.dynamic_attributes.each do |attribute| -- cgit v1.2.3 From 7927a067f575c40a7ab7712485cf37c0f3356ad2 Mon Sep 17 00:00:00 2001 From: Luc Donnet Date: Wed, 4 Oct 2017 13:17:41 +0200 Subject: Rename app/models/route_control/speed.rb -> app/models/vehicle_journey_control/speed.rb and fix variables name in compliance control subclasses Refs #4690 --- app/models/compliance_control.rb | 4 ++-- app/models/generic_attribute_control/min_max.rb | 3 ++- app/models/generic_attribute_control/pattern.rb | 3 ++- app/models/generic_attribute_control/uniqueness.rb | 3 ++- app/models/route_control/speed.rb | 8 -------- app/models/vehicle_journey_control/delta.rb | 2 +- app/models/vehicle_journey_control/speed.rb | 7 +++++++ app/models/vehicle_journey_control/waiting_time.rb | 1 + config/initializers/apartment.rb | 2 +- spec/factories/compliance_controls/route_control_factories.rb | 4 ---- .../compliance_controls/vehicle_journey_control_factories.rb | 4 ++++ 11 files changed, 22 insertions(+), 19 deletions(-) delete mode 100644 app/models/route_control/speed.rb create mode 100644 app/models/vehicle_journey_control/speed.rb diff --git a/app/models/compliance_control.rb b/app/models/compliance_control.rb index e859aaba0..33a075e40 100644 --- a/app/models/compliance_control.rb +++ b/app/models/compliance_control.rb @@ -3,7 +3,7 @@ class ComplianceControl < ActiveRecord::Base belongs_to :compliance_control_set belongs_to :compliance_control_block - enumerize :criticity, in: %i(info warning error), scope: true, default: :info + enumerize :criticity, in: %i(warning error), scope: true, default: :warning hstore_accessor :control_attributes, {} validates :criticity, presence: true @@ -55,7 +55,6 @@ require_dependency 'route_control/minimum_length' require_dependency 'route_control/omnibus_journey_pattern' require_dependency 'route_control/opposite_route_terminus' require_dependency 'route_control/opposite_route' -require_dependency 'route_control/speed' require_dependency 'route_control/stop_points_in_journey_pattern' require_dependency 'route_control/time_table' require_dependency 'route_control/unactivated_stop_points' @@ -66,3 +65,4 @@ require_dependency 'routing_constraint_zone_control/minimum_length' require_dependency 'routing_constraint_zone_control/unactivated_stop_point' require_dependency 'vehicle_journey_control/delta' require_dependency 'vehicle_journey_control/waiting_time' +require_dependency 'vehicle_journey_control/speed' diff --git a/app/models/generic_attribute_control/min_max.rb b/app/models/generic_attribute_control/min_max.rb index 452d1d889..876f56eed 100644 --- a/app/models/generic_attribute_control/min_max.rb +++ b/app/models/generic_attribute_control/min_max.rb @@ -1,6 +1,6 @@ module GenericAttributeControl class MinMax < ComplianceControl - hstore_accessor :control_attributes, minimum: :integer, maximum: :integer + hstore_accessor :control_attributes, minimum: :integer, maximum: :integer, target: :string validate :min_max_values def min_max_values @@ -8,6 +8,7 @@ module GenericAttributeControl end class << self + def attribute_type; :integer end def default_criticity; :warning end def default_code; "3-Generic-2" end end diff --git a/app/models/generic_attribute_control/pattern.rb b/app/models/generic_attribute_control/pattern.rb index 72bb1770a..6796da84f 100644 --- a/app/models/generic_attribute_control/pattern.rb +++ b/app/models/generic_attribute_control/pattern.rb @@ -1,6 +1,6 @@ module GenericAttributeControl class Pattern < ComplianceControl - hstore_accessor :control_attributes, value: :string, pattern: :string + hstore_accessor :control_attributes, pattern: :string, target: :string validate :pattern_match def pattern_match @@ -8,6 +8,7 @@ module GenericAttributeControl end class << self + def attribute_type; :string end def default_criticity; :warning end def default_code; "3-Generic-3" end end diff --git a/app/models/generic_attribute_control/uniqueness.rb b/app/models/generic_attribute_control/uniqueness.rb index 6ffe78565..f227bf8b6 100644 --- a/app/models/generic_attribute_control/uniqueness.rb +++ b/app/models/generic_attribute_control/uniqueness.rb @@ -1,6 +1,6 @@ module GenericAttributeControl class Uniqueness < ComplianceControl - hstore_accessor :control_attributes, name: :string + hstore_accessor :control_attributes, target: :string validate :unique_values def unique_values @@ -8,6 +8,7 @@ module GenericAttributeControl end class << self + def attribute_type; :string end def default_criticity; :warning end def default_code; "3-Generic-3" end end diff --git a/app/models/route_control/speed.rb b/app/models/route_control/speed.rb deleted file mode 100644 index d5798d153..000000000 --- a/app/models/route_control/speed.rb +++ /dev/null @@ -1,8 +0,0 @@ -module RouteControl - class Speed < ComplianceControl - - hstore_accessor :control_attributes, minimum: :integer, maximum: :integer - - def self.default_code; "3-VehicleJourney-2" end - end -end diff --git a/app/models/vehicle_journey_control/delta.rb b/app/models/vehicle_journey_control/delta.rb index 797072fdd..7be0db261 100644 --- a/app/models/vehicle_journey_control/delta.rb +++ b/app/models/vehicle_journey_control/delta.rb @@ -1,7 +1,7 @@ module VehicleJourneyControl class Delta < ComplianceControl - hstore_accessor :control_attributes, delta: :integer + hstore_accessor :control_attributes, maximum: :integer def self.default_code; "3-VehicleJourney-3" end end diff --git a/app/models/vehicle_journey_control/speed.rb b/app/models/vehicle_journey_control/speed.rb new file mode 100644 index 000000000..cc46ee1f9 --- /dev/null +++ b/app/models/vehicle_journey_control/speed.rb @@ -0,0 +1,7 @@ +module VehicleJourneyControl + class Speed < ComplianceControl + hstore_accessor :control_attributes, minimum: :integer, maximum: :integer + + def self.default_code; "3-VehicleJourney-2" end + end +end diff --git a/app/models/vehicle_journey_control/waiting_time.rb b/app/models/vehicle_journey_control/waiting_time.rb index 614f401bb..da35bc4a1 100644 --- a/app/models/vehicle_journey_control/waiting_time.rb +++ b/app/models/vehicle_journey_control/waiting_time.rb @@ -1,5 +1,6 @@ module VehicleJourneyControl class WaitingTime < ComplianceControl + hstore_accessor :control_attributes, maximum: :integer def self.default_code; "3-VehicleJourney-1" end end diff --git a/config/initializers/apartment.rb b/config/initializers/apartment.rb index ade871138..9954c9b3e 100644 --- a/config/initializers/apartment.rb +++ b/config/initializers/apartment.rb @@ -61,7 +61,6 @@ Apartment.configure do |config| 'RouteControl::OmnibusJourneyPattern', 'RouteControl::OppositeRouteTerminus', 'RouteControl::OppositeRoute', - 'RouteControl::Speed', 'RouteControl::StopPointsInJourneyPattern', 'RouteControl::TimeTable', 'RouteControl::UnactivatedStopPoints', @@ -72,6 +71,7 @@ Apartment.configure do |config| 'RoutingConstraintZoneControl::UnactivatedStopPoint', 'VehicleJourneyControl::Delta', 'VehicleJourneyControl::WaitingTime', + 'VehicleJourneyControl::Speed', 'ComplianceControlSet', 'ComplianceControlBlock', 'ComplianceCheck', diff --git a/spec/factories/compliance_controls/route_control_factories.rb b/spec/factories/compliance_controls/route_control_factories.rb index 654a67b46..763a197ee 100644 --- a/spec/factories/compliance_controls/route_control_factories.rb +++ b/spec/factories/compliance_controls/route_control_factories.rb @@ -36,10 +36,6 @@ FactoryGirl.define do association :compliance_control_set end - factory :route_control_speed, class: 'RouteControl::Speed' do - association :compliance_control_set - end - factory :route_control_time_table, class: 'RouteControl::TimeTable' do association :compliance_control_set end diff --git a/spec/factories/compliance_controls/vehicle_journey_control_factories.rb b/spec/factories/compliance_controls/vehicle_journey_control_factories.rb index 3871f80a5..3775624db 100644 --- a/spec/factories/compliance_controls/vehicle_journey_control_factories.rb +++ b/spec/factories/compliance_controls/vehicle_journey_control_factories.rb @@ -7,4 +7,8 @@ FactoryGirl.define do factory :vehicle_journey_control_delta, class: 'VehicleJourneyControl::Delta' do association :compliance_control_set end + + factory :vehicle_journey_control_speed, class: 'VehicleJourneyControl::Speed' do + association :compliance_control_set + end end -- cgit v1.2.3 From 458b841fbeed0fee9a1f6db981c3b18f47a84905 Mon Sep 17 00:00:00 2001 From: Luc Donnet Date: Wed, 4 Oct 2017 13:29:01 +0200 Subject: Rename spec test for compliance_control Refs #4690 --- .../route_control/speed_cccld_spec.rb | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 spec/models/compliance_control_class_level_defaults/route_control/speed_cccld_spec.rb diff --git a/spec/models/compliance_control_class_level_defaults/route_control/speed_cccld_spec.rb b/spec/models/compliance_control_class_level_defaults/route_control/speed_cccld_spec.rb deleted file mode 100644 index ad2b67960..000000000 --- a/spec/models/compliance_control_class_level_defaults/route_control/speed_cccld_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ - -RSpec.describe RouteControl::Speed, type: :model do - let( :default_code ){ "3-VehicleJourney-2" } - let( :factory ){ :route_control_speed } - - it_behaves_like 'ComplianceControl Class Level Defaults' -end -- cgit v1.2.3