aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Gemfile1
-rw-r--r--Gemfile.lock9
-rw-r--r--INSTALL.md146
-rw-r--r--app/assets/stylesheets/components/_referential_overview.sass4
-rw-r--r--app/controllers/compliance_check_messages_controller.rb2
-rw-r--r--app/controllers/compliance_check_sets_controller.rb2
-rw-r--r--app/controllers/compliance_checks_controller.rb5
-rw-r--r--app/controllers/compliance_control_sets_controller.rb18
-rw-r--r--app/controllers/import_messages_controller.rb2
-rw-r--r--app/helpers/application_helper.rb2
-rw-r--r--app/helpers/table_builder_helper.rb2
-rw-r--r--app/helpers/table_builder_helper/column.rb16
-rw-r--r--app/models/compliance_check.rb11
-rw-r--r--app/models/compliance_check_message_export.rb4
-rw-r--r--app/models/compliance_control.rb44
-rw-r--r--app/models/concerns/compliance_item_support.rb13
-rw-r--r--app/models/import_message_export.rb4
-rw-r--r--app/models/merge.rb6
-rw-r--r--app/policies/application_policy.rb1
-rw-r--r--app/policies/compliance_control_set_policy.rb4
-rw-r--r--app/views/compliance_check_sets/index.html.slim7
-rw-r--r--app/views/compliance_checks/show.html.slim13
-rw-r--r--app/views/compliance_controls/_filters.html.slim4
-rw-r--r--app/views/compliance_controls/show.html.slim17
-rw-r--r--app/views/lines/show.html.slim10
-rw-r--r--app/views/shared/controls/_metadatas.html.slim15
-rw-r--r--app/views/stop_areas/show.html.slim2
-rw-r--r--config/breadcrumbs.rb7
-rw-r--r--config/locales/compliance_checks.en.yml4
-rw-r--r--config/locales/compliance_checks.fr.yml5
-rw-r--r--config/locales/compliance_controls.en.yml24
-rw-r--r--config/locales/compliance_controls.fr.yml22
-rw-r--r--config/locales/stop_areas.en.yml4
-rw-r--r--config/locales/stop_areas.fr.yml4
-rw-r--r--db/migrate/20180227151937_add_compliance_control_name_to_compliance_checks.rb5
-rw-r--r--db/schema.rb10
-rw-r--r--lib/compliance_control_set_copier.rb5
-rw-r--r--lib/tasks/seeds.rake19
-rw-r--r--spec/helpers/table_builder_helper_spec.rb47
39 files changed, 311 insertions, 209 deletions
diff --git a/Gemfile b/Gemfile
index 5ec53aee4..5cfdb2c6d 100644
--- a/Gemfile
+++ b/Gemfile
@@ -135,7 +135,6 @@ gem 'rabl'
gem 'carrierwave', '~> 1.0'
gem 'sidekiq'
-gem 'sinatra'
gem 'whenever', github: 'af83/whenever', require: false # '~> 0.9'
gem 'rake'
gem 'devise-async'
diff --git a/Gemfile.lock b/Gemfile.lock
index 63d78f9cd..090886f3d 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -368,10 +368,10 @@ GEM
railties (>= 3.1, < 5.0)
rabl (0.13.1)
activesupport (>= 2.3.14)
- rack (1.6.8)
+ rack (1.6.9)
rack-livereload (0.3.16)
rack
- rack-protection (1.5.3)
+ rack-protection (1.5.4)
rack
rack-proxy (0.6.3)
rack
@@ -509,10 +509,6 @@ GEM
simplecov-html (0.10.0)
simplecov-rcov (0.2.3)
simplecov (>= 0.4.1)
- sinatra (1.4.8)
- rack (~> 1.5)
- rack-protection (~> 1.4)
- tilt (>= 1.3, < 3)
sixarm_ruby_unaccent (1.2.0)
slim (3.0.7)
temple (~> 0.7.6)
@@ -700,7 +696,6 @@ DEPENDENCIES
simple_form (~> 3.1.0)
simplecov
simplecov-rcov
- sinatra
slim-rails (~> 3.1)
spring
spring-commands-rspec
diff --git a/INSTALL.md b/INSTALL.md
index e44b072f4..392ef5d9f 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -8,6 +8,17 @@ Example with [rvm](https://rvm.io/) (other solutions : rbenv, packages..):
rvm install 2.3.1
```
+Nokogiri on macOS
+
+http://www.nokogiri.org/tutorials/installing_nokogiri.html tells us that `xz` can cause troubles, here is what to do
+
+```
+brew unlink xz
+gem install nokogiri # or bundle install
+brew link xz
+```
+
+
## Node and Yarn
Yarn needs node. If you use Node Version Manager [NVM](https://github.com/creationix/nvm) you can rely on the content of `.nvmrc`. Otherwise please make sure to use a compatible version, still best to use the same as indicated by `.nvrmc`.
@@ -15,7 +26,7 @@ Yarn needs node. If you use Node Version Manager [NVM](https://github.com/creati
* Install node
```sh
-nvm install 6.12.0
+nvm install 6.13.0
```
* Install [yarn](https://yarnpkg.com/lang/en/docs/install/)
@@ -36,41 +47,6 @@ sudo apt-get update && sudo apt-get install yarn
yarn install
```
-### Installation Caveats
-
-#### Node Related Issue, libv8
-
-`libv8` might cause you troubles, depending on your local configuration. If you have `libv8` installed (probably because of `node.js`) you might need to tell bundler/Rubygems to use the system version.
-
-```sh
-bundle config build.libv8 --with-system-v8
-bundle
-```
-
-or
-
-```sh
-gem install libv8 -v '<version>' -- --with-system-v8
-bundle
-```
-
-You will get the correct value of `<version>` from bundler's error message.
-
-#### Node Related Issue, therubyracer
-
-Even after `libv8` installation working, the gem `therubyracer` might not like the `libv8` version chosen.
-
-In that case however we can let the gem make its own choice:
-
-```sh
-gem uninstall libv8
-gem install therubyracer -v '<version>'
-```
-
-The version to be installed is indicated in the error message bundler gave us in the first place.
-
-This will install an appropriate `libv8` version and we can continue with `bundle`.
-
## Postgres
### Create user
@@ -89,53 +65,12 @@ When promted for the password enter the highly secure string `chouette`.
As documented [here](https://github.com/dryade/georuby-ext/issues/2) we need some more libs before we can start the `rake` setup tasks.
-
On mac/OS :
```sh
brew install postgis
```
-<<<<<<< HEAD
-### Authentication
-
-See `config.chouette_authentication_settings`.
-
-Use the database authentication or get an invitation to [STIF Portail](http://stif-portail-dev.af83.priv/).
-
-### Run seed
-
-Run :
-
- bundle exec rake db:seed
-
-Two users are created : stif-boiv@af83.com/secret and stif-boiv+transporteur@af83.com/secret
-
-If you have access to STIF CodifLigne and Reflex :
-
- bundle exec rake codifligne:sync
- bundle exec rake reflex:sync
-
-To create Referential with some data (Route, JourneyPattern, VehicleJourney, etc) :
-
- bundle exec rake referential:create
-
-# Troubleshooting
-
-If PG complains about illegal type `hstore` in your tests that is probably because the shared extension is not installed, here is what to do:
-
-#### Check installation
-
-* Run tests
-
- bundle exec rake spec
- bundle exec rake teaspoon
-
-* Start local server
-
- bundle exec rails server
-
-=======
On debian/ubuntu system :
```sh
@@ -156,50 +91,34 @@ Go into your local repository and install the gems
bundle install
```
-#### Nokogiri on macOS
-
-http://www.nokogiri.org/tutorials/installing_nokogiri.html tells us that `xz` can cause troubles, here is what to do
-
-```
-brew unlink xz
-gem install nokogiri # or bundle install
-brew link xz
-```
-
### Database
#### Create database
```sh
bundle exec rake db:create db:migrate
-RAILS_ENV=test bundle exec rake db:create db:migrate
```
-#### Load seed datas
->>>>>>> master
+#### Use seed
+
+Run :
```sh
bundle exec rake db:seed:stif
```
-#### Synchronise datas with lines and stop areas referentials
-
-* Launch Sidekiq
-
-```sh
-bundle exec sidekiq
-```
+Two users are created : stif-boiv@af83.com/secret and stif-boiv+transporteur@af83.com/secret
-* Execute the Synchronization Tasks
+#### Synchronize with STIF CODIFLIGNE (Line) and REFLEX (StopArea)
```sh
bundle exec rake codifligne:sync
bundle exec rake reflex:sync
```
-**N.B.** These are asynchronious tasks, you can observe the launched jobs in your [Sidekiq Console](http://localhost:3000/sidekiq)
+**N.B.** These are asynchronous tasks, you can observe the launched jobs in your [Sidekiq Console](http://localhost:3000/sidekiq)
-#### Data in various Apartments (Referentials)
+#### Create Referential
To create `Referential` objects with some data (`Route`, `JourneyPattern`, `VehicleJourney`, etc), you need to wait codifligne and reflex jobs finished. And then you can launch :
@@ -207,33 +126,32 @@ To create `Referential` objects with some data (`Route`, `JourneyPattern`, `Vehi
bundle exec rake referential:create
```
-### Check installation
+### Run tests
-#### Run tests
-
-#### Rspec
+* Rspec (Rails test)
```sh
bundle exec rake spec
-bundle exec rake teaspoon
```
-If Postgres complains about illegal type `hstore` or `unaccent` in your tests that is probably because the shared extension is not installed, here is what to do:
-
- bundle exec rake db:test:purge
-
-Thanks to `lib/tasks/extensions.rake`.
+* Jest (JavaScript tests)
-#### Jest (React integration specs)
+```sh
+grunt jest #to run the whole specs.
+grunt #to watch for changes and automatically run corresponding tests.
+```
-`grunt jest` to run the whole specs.
+### Run
-`grunt` to watch for changes and automatically run corresponding tests.
+Launch Sidekiq
-#### Start local server
+```sh
+bundle exec sidekiq
+```
```sh
bin/webpack-dev-server // Launch webpack server to compile assets on the fly
bundle exec rails server // Launch rails server
```
+
You need to have an account on [STIF Portail](http://stif-portail-dev.af83.priv/) to connect to the Rails application.
diff --git a/app/assets/stylesheets/components/_referential_overview.sass b/app/assets/stylesheets/components/_referential_overview.sass
index 0beb8ab67..fc48411a3 100644
--- a/app/assets/stylesheets/components/_referential_overview.sass
+++ b/app/assets/stylesheets/components/_referential_overview.sass
@@ -22,7 +22,7 @@
box-shadow: 0 0 10px rgba(0,0,0,0.5)
z-index: 1
.time-travel
- padding-top: 4px
+ padding-top: 3px
padding-bottom: 4px
a.btn:first-child
margin-right: 1px
@@ -61,7 +61,7 @@
border-color: $grey
width: auto
flex: 1 1
- padding: 4px 11px 5px
+ padding: 6px 11px
.input-group-btn
right: 10px
&.togglable
diff --git a/app/controllers/compliance_check_messages_controller.rb b/app/controllers/compliance_check_messages_controller.rb
index 7c416584e..36745981e 100644
--- a/app/controllers/compliance_check_messages_controller.rb
+++ b/app/controllers/compliance_check_messages_controller.rb
@@ -7,7 +7,7 @@ class ComplianceCheckMessagesController < ChouetteController
def index
index! do |format|
format.csv {
- send_data ComplianceCheckMessageExport.new(compliance_check_messages: collection).to_csv(:col_sep => "\;", :quote_char=>'"', force_quotes: true, server_url: request.base_url) , :filename => "compliance_check_set_errors_#{line_code}_#{Time.now.to_i}.csv"
+ send_data ComplianceCheckMessageExport.new(compliance_check_messages: collection).to_csv(:col_sep => "\;", :quote_char=>'"', force_quotes: true, server_url: request.base_url) , :filename => "compliance_check_set_errors_#{line_code}_#{Date.today.to_s}.csv"
}
end
end
diff --git a/app/controllers/compliance_check_sets_controller.rb b/app/controllers/compliance_check_sets_controller.rb
index 271598428..62b0e6ba3 100644
--- a/app/controllers/compliance_check_sets_controller.rb
+++ b/app/controllers/compliance_check_sets_controller.rb
@@ -12,7 +12,7 @@ class ComplianceCheckSetsController < ChouetteController
@q_for_form = scope.ransack(params[:q])
format.html {
@compliance_check_sets = ComplianceCheckSetDecorator.decorate(
- @q_for_form.result.order(created_at: :desc)
+ @q_for_form.result.order(created_at: :desc).paginate(page: params[:page], per_page: 30)
)
}
end
diff --git a/app/controllers/compliance_checks_controller.rb b/app/controllers/compliance_checks_controller.rb
index 81749e292..ad32bc538 100644
--- a/app/controllers/compliance_checks_controller.rb
+++ b/app/controllers/compliance_checks_controller.rb
@@ -1,4 +1,5 @@
class ComplianceChecksController < InheritedResources::Base
-
-
+ belongs_to :workbench do
+ belongs_to :compliance_check_set
+ end
end
diff --git a/app/controllers/compliance_control_sets_controller.rb b/app/controllers/compliance_control_sets_controller.rb
index 8f9251155..6461b38c8 100644
--- a/app/controllers/compliance_control_sets_controller.rb
+++ b/app/controllers/compliance_control_sets_controller.rb
@@ -36,11 +36,15 @@ class ComplianceControlSetsController < ChouetteController
private
def collection
- scope = self.ransack_period_range(scope: ComplianceControlSet.all, error_message: t('imports.filters.error_period_filter'), query: :where_updated_at_between)
- @q_for_form = scope.ransack(params[:q])
- compliance_control_sets = @q_for_form.result
- compliance_control_sets = joins_with_associated_objects(compliance_control_sets).order(sort_column + ' ' + sort_direction) if sort_column && sort_direction
- @compliance_control_sets = compliance_control_sets.paginate(page: params[:page], per_page: 30)
+ @compliance_control_sets ||= begin
+ scope = end_of_association_chain.all
+ scope = self.ransack_period_range(scope: scope, error_message: t('imports.filters.error_period_filter'), query: :where_updated_at_between)
+ @q_for_form = scope.ransack(params[:q])
+ compliance_control_sets = @q_for_form.result
+ compliance_control_sets = joins_with_associated_objects(compliance_control_sets).order(sort_column + ' ' + sort_direction) if sort_column && sort_direction
+ compliance_control_sets = compliance_control_sets.paginate(page: params[:page], per_page: 30)
+ end
+
end
def decorate_compliance_control_sets(compliance_control_sets)
@@ -82,9 +86,9 @@ class ComplianceControlSetsController < ChouetteController
case params[:sort]
when 'owner_jdc'
collection.joins("LEFT JOIN organisations ON compliance_control_sets.organisation_id = organisations.id")
- when 'control_numbers'
+ when 'control_numbers'
collection.joins("LEFT JOIN compliance_controls ON compliance_controls.compliance_control_set_id = compliance_control_sets.id").group(:id)
- else
+ else
collection
end
end
diff --git a/app/controllers/import_messages_controller.rb b/app/controllers/import_messages_controller.rb
index 286bb0ce8..4f8fe7a25 100644
--- a/app/controllers/import_messages_controller.rb
+++ b/app/controllers/import_messages_controller.rb
@@ -9,7 +9,7 @@ class ImportMessagesController < ChouetteController
def index
index! do |format|
format.csv {
- send_data ImportMessageExport.new(:import_messages => @import_messages).to_csv(:col_sep => "\;", :quote_char=>'"', force_quotes: true) , :filename => "import_errors_#{@import_resource.name.gsub('.xml', '')}_#{Time.now.to_i}.csv"
+ send_data ImportMessageExport.new(:import_messages => @import_messages).to_csv(:col_sep => "\;", :quote_char=>'"', force_quotes: true) , :filename => "import_errors_#{@import_resource.name.gsub('.xml', '')}_#{Date.today.to_s}.csv"
}
end
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 0058c210d..356c7e69e 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -19,7 +19,7 @@ module ApplicationHelper
return object.full_name
end
- local = "#{object.model_name.name.underscore.pluralize}.#{params[:action]}.title"
+ local = "#{object.model_name.name.underscore.pluralize}.#{params[:action]}.title"
if object.try(:name)
t(local, name: object.name || object.id)
else
diff --git a/app/helpers/table_builder_helper.rb b/app/helpers/table_builder_helper.rb
index 2068dd23c..d16858678 100644
--- a/app/helpers/table_builder_helper.rb
+++ b/app/helpers/table_builder_helper.rb
@@ -224,7 +224,7 @@ module TableBuilderHelper
if column.linkable?
path = column.link_to(item)
- link = link_to(value, path)
+ link = value.present? && path.present? ? link_to(value, path) : ""
if overhead.empty?
bcont << content_tag(:td, link, title: 'Voir')
diff --git a/app/helpers/table_builder_helper/column.rb b/app/helpers/table_builder_helper/column.rb
index 05aa9f563..ff6f2f36f 100644
--- a/app/helpers/table_builder_helper/column.rb
+++ b/app/helpers/table_builder_helper/column.rb
@@ -2,19 +2,21 @@ module TableBuilderHelper
class Column
attr_reader :key, :name, :attribute, :sortable
- def initialize(key: nil, name: '', attribute:, sortable: true, link_to: nil)
+ def initialize(key: nil, name: '', attribute:, sortable: true, link_to: nil, **opts)
if key.nil? && name.empty?
raise ColumnMustHaveKeyOrNameError
end
-
+ opts ||= {}
@key = key
@name = name
@attribute = attribute
@sortable = sortable
@link_to = link_to
+ @condition = opts[:if]
end
def value(obj)
+ return unless check_condition(obj)
if @attribute.is_a?(Proc)
@attribute.call(obj)
else
@@ -36,8 +38,18 @@ module TableBuilderHelper
end
def link_to(obj)
+ return unless check_condition(obj)
@link_to.call(obj)
end
+
+ def check_condition(obj)
+ condition_val = true
+ if @condition.present?
+ condition_val = @condition
+ condition_val = condition_val.call(obj) if condition_val.is_a?(Proc)
+ end
+ !!condition_val
+ end
end
diff --git a/app/models/compliance_check.rb b/app/models/compliance_check.rb
index 55f2ae228..9d817e146 100644
--- a/app/models/compliance_check.rb
+++ b/app/models/compliance_check.rb
@@ -1,14 +1,23 @@
class ComplianceCheck < ActiveRecord::Base
+ include ComplianceItemSupport
self.inheritance_column = nil
extend Enumerize
belongs_to :compliance_check_set
belongs_to :compliance_check_block
-
+
enumerize :criticity, in: %i(warning error), scope: true, default: :warning
validates :criticity, presence: true
validates :name, presence: true
validates :code, presence: true
validates :origin_code, presence: true
+
+ def control_class
+ compliance_control_name.present? ? compliance_control_name.constantize : nil
+ end
+
+ delegate :predicate, to: :control_class, allow_nil: true
+ delegate :prerequisite, to: :control_class, allow_nil: true
+
end
diff --git a/app/models/compliance_check_message_export.rb b/app/models/compliance_check_message_export.rb
index 04e1a9caa..bbaaa8e3f 100644
--- a/app/models/compliance_check_message_export.rb
+++ b/app/models/compliance_check_message_export.rb
@@ -26,12 +26,14 @@ class ComplianceCheckMessageExport
end
def to_csv(options = {})
- CSV.generate(options.slice(:col_sep, :quote_char, :force_quotes)) do |csv|
+ csv_string = CSV.generate(options.slice(:col_sep, :quote_char, :force_quotes)) do |csv|
csv << column_names
compliance_check_messages.each do |compliance_check_message|
csv << [compliance_check_message.compliance_check.criticity, *compliance_check_message.message_attributes.values_at('test_id', 'source_objectid'), options[:server_url] + compliance_check_message.message_attributes['source_object_path'], I18n.t("compliance_check_messages.#{compliance_check_message.message_key}", compliance_check_message.message_attributes.deep_symbolize_keys)]
end
end
+ # We add a BOM to indicate we use UTF-8
+ "\uFEFF" + csv_string
end
def to_zip(temp_file,options = {})
diff --git a/app/models/compliance_control.rb b/app/models/compliance_control.rb
index 298a63ab9..537343005 100644
--- a/app/models/compliance_control.rb
+++ b/app/models/compliance_control.rb
@@ -1,18 +1,16 @@
class ComplianceControl < ActiveRecord::Base
+ include ComplianceItemSupport
class << self
def criticities; %i(warning error) end
def default_code; "" end
- def dynamic_attributes
- stored_attributes[:control_attributes] || []
- end
def policy_class
ComplianceControlPolicy
end
def subclass_patterns
- {
+ {
generic: 'Generic',
journey_pattern: 'JourneyPattern',
line: 'Line',
@@ -30,6 +28,9 @@ class ComplianceControl < ActiveRecord::Base
end
super
end
+
+ def predicate; I18n.t("compliance_controls.#{self.name.underscore}.description") end
+ def prerequisite; I18n.t("compliance_controls.#{self.name.underscore}.prerequisite") end
end
extend Enumerize
@@ -45,26 +46,25 @@ class ComplianceControl < ActiveRecord::Base
validates :compliance_control_set, presence: true
validate def coherent_control_set
- return true if compliance_control_block_id.nil?
- ids = [compliance_control_block.compliance_control_set_id, compliance_control_set_id]
- return true if ids.first == ids.last
- names = ids.map{|id| ComplianceControlSet.find(id).name}
- errors.add(:coherent_control_set,
- I18n.t('compliance_controls.errors.incoherent_control_sets',
- indirect_set_name: names.first,
- direct_set_name: names.last))
-end
-
+ return true if compliance_control_block_id.nil?
+ ids = [compliance_control_block.compliance_control_set_id, compliance_control_set_id]
+ return true if ids.first == ids.last
+ names = ids.map{|id| ComplianceControlSet.find(id).name}
+ errors.add(:coherent_control_set,
+ I18n.t('compliance_controls.errors.incoherent_control_sets',
+ indirect_set_name: names.first,
+ direct_set_name: names.last))
+ end
-def initialize(attributes = {})
- super
- self.name ||= I18n.t("activerecord.models.#{self.class.name.underscore}.one")
- self.code ||= self.class.default_code
- self.origin_code ||= self.class.default_code
-end
+ def initialize(attributes = {})
+ super
+ self.name ||= I18n.t("activerecord.models.#{self.class.name.underscore}.one")
+ self.code ||= self.class.default_code
+ self.origin_code ||= self.class.default_code
+ end
-def predicate; I18n.t("compliance_controls.#{self.class.name.underscore}.description") end
-def prerequisite; I18n.t('compliance_controls.metas.no_prerequisite'); end
+ def predicate; self.class.predicate end
+ def prerequisite; self.class.prerequisite end
end
diff --git a/app/models/concerns/compliance_item_support.rb b/app/models/concerns/compliance_item_support.rb
new file mode 100644
index 000000000..f44f5719f
--- /dev/null
+++ b/app/models/concerns/compliance_item_support.rb
@@ -0,0 +1,13 @@
+module ComplianceItemSupport
+ extend ActiveSupport::Concern
+ included do
+
+ end
+
+ module ClassMethods
+ def dynamic_attributes
+ stored_attributes[:control_attributes] || []
+ end
+ end
+
+end
diff --git a/app/models/import_message_export.rb b/app/models/import_message_export.rb
index 05f8a2cc7..991eb0f61 100644
--- a/app/models/import_message_export.rb
+++ b/app/models/import_message_export.rb
@@ -26,12 +26,14 @@ class ImportMessageExport
end
def to_csv(options = {})
- CSV.generate(options) do |csv|
+ csv_string = CSV.generate(options) do |csv|
csv << column_names
import_messages.each do |import_message|
csv << [import_message.criticity, import_message.message_key, I18n.t("import_messages.#{import_message.message_key}", import_message.message_attributes.deep_symbolize_keys), *import_message.resource_attributes.values_at("filename", "line_number", "column_number") ]
end
end
+ # We add a BOM to indicate we use UTF-8
+ "\uFEFF" + csv_string
end
def to_zip(temp_file,options = {})
diff --git a/app/models/merge.rb b/app/models/merge.rb
index 62bf581d6..d42d882ac 100644
--- a/app/models/merge.rb
+++ b/app/models/merge.rb
@@ -152,7 +152,7 @@ class Merge < ActiveRecord::Base
route_stop_points = referential_stop_points_by_route[route.id]
# Stop Points
- route_stop_points.each do |stop_point|
+ route_stop_points.sort_by(&:position).each do |stop_point|
objectid = Chouette::StopPoint.where(objectid: stop_point.objectid).exists? ? nil : stop_point.objectid
attributes = stop_point.attributes.merge(
id: nil,
@@ -166,7 +166,7 @@ class Merge < ActiveRecord::Base
new_route.save!
if new_route.checksum != route.checksum
- raise "Checksum has changed: #{route.inspect} #{new_route.inspect}"
+ raise "Checksum has changed: \"#{route.checksum}\", \"#{route.checksum_source}\" -> \"#{new_route.checksum}\", \"#{new_route.checksum_source}\""
end
end
end
@@ -221,7 +221,7 @@ class Merge < ActiveRecord::Base
new_journey_pattern = new.journey_patterns.create! attributes
if new_journey_pattern.checksum != journey_pattern.checksum
- raise "Checksum has changed for #{journey_pattern.inspect}: #{journey_pattern.checksum_source} #{new_journey_pattern.checksum_source} "
+ raise "Checksum has changed for #{journey_pattern.inspect}: \"#{journey_pattern.checksum_source}\" -> \"#{new_journey_pattern.checksum_source}\""
end
end
end
diff --git a/app/policies/application_policy.rb b/app/policies/application_policy.rb
index c44937c9e..33d88660c 100644
--- a/app/policies/application_policy.rb
+++ b/app/policies/application_policy.rb
@@ -95,7 +95,6 @@ class ApplicationPolicy
referential.try(:organisation_id) || record.try(:organisation_id)
end
-
#
# Helpers
# -------
diff --git a/app/policies/compliance_control_set_policy.rb b/app/policies/compliance_control_set_policy.rb
index 011f6c0c7..55507ffd9 100644
--- a/app/policies/compliance_control_set_policy.rb
+++ b/app/policies/compliance_control_set_policy.rb
@@ -5,6 +5,10 @@ class ComplianceControlSetPolicy < ApplicationPolicy
end
end
+ def show?
+ organisation_match?
+ end
+
def destroy?
user.has_permission?('compliance_control_sets.destroy')
end
diff --git a/app/views/compliance_check_sets/index.html.slim b/app/views/compliance_check_sets/index.html.slim
index 31ad31e5b..9abd95dd1 100644
--- a/app/views/compliance_check_sets/index.html.slim
+++ b/app/views/compliance_check_sets/index.html.slim
@@ -23,9 +23,10 @@
), \
TableBuilderHelper::Column.new( \
key: :associated_object, \
- attribute: Proc.new{|n| n.referential.present? ? n.referential.name : ''}, \
+ if: ->(compliance_check_set){ compliance_check_set.referential.present? }, \
+ attribute: Proc.new{|n| n.referential.name}, \
link_to: lambda do |compliance_check_set| \
- compliance_check_set.referential.present? ? referential_path(compliance_check_set.referential_id) : '#' \
+ referential_path(compliance_check_set.referential_id) \
end \
), \
TableBuilderHelper::Column.new( \
@@ -42,6 +43,8 @@
],
sortable: true,
cls: 'table has-filter has-search'
+
+ = new_pagination @compliance_check_sets, 'pull-right'
- unless @compliance_check_sets.any?
.row.mt-xs
.col-lg-12
diff --git a/app/views/compliance_checks/show.html.slim b/app/views/compliance_checks/show.html.slim
new file mode 100644
index 000000000..8dd699c65
--- /dev/null
+++ b/app/views/compliance_checks/show.html.slim
@@ -0,0 +1,13 @@
+- breadcrumb :compliance_check, @workbench, resource
+- page_header_content_for resource
+
+
+.page_content
+ .container-fluid
+ .row
+ .col-lg-6.col-md-6.col-sm-12.col-xs-12
+ = render partial: "shared/controls/metadatas"
+ - if resource.compliance_check_block
+ = definition_list t('compliance_controls.show.metadatas.compliance_check_block'),
+ I18n.t('activerecord.attributes.compliance_control_blocks.transport_mode') => I18n.t("enumerize.transport_mode.#{resource.compliance_check_block.transport_mode}"),
+ I18n.t('activerecord.attributes.compliance_control_blocks.transport_submode') => I18n.t("enumerize.transport_submode.#{resource.compliance_check_block.transport_submode}")
diff --git a/app/views/compliance_controls/_filters.html.slim b/app/views/compliance_controls/_filters.html.slim
index f6b9970f2..a16d2c33d 100644
--- a/app/views/compliance_controls/_filters.html.slim
+++ b/app/views/compliance_controls/_filters.html.slim
@@ -5,8 +5,8 @@
class: 'form form-filter' do |f|
.ffg-row
- .input-group.search_bar class=filter_item_class(params[:q], :name_cont)
- = f.search_field :name_cont,
+ .input-group.search_bar class=filter_item_class(params[:q], :name_or_code_cont)
+ = f.search_field :name_or_code_cont,
class: 'form-control',
placeholder: t('compliance_controls.filters.name')
span.input-group-btn
diff --git a/app/views/compliance_controls/show.html.slim b/app/views/compliance_controls/show.html.slim
index ab25747a9..6e7a45d12 100644
--- a/app/views/compliance_controls/show.html.slim
+++ b/app/views/compliance_controls/show.html.slim
@@ -6,22 +6,7 @@
.container-fluid
.row
.col-lg-6.col-md-6.col-sm-12.col-xs-12
- /- @compliance_control.control_attributes.each_with_index do |(key,value), index|
- = definition_list t('metadatas'),
- { \
- ComplianceControl.human_attribute_name(:name) => @compliance_control.name,
- ComplianceControl.human_attribute_name(:code) => @compliance_control.code,
- ComplianceControl.human_attribute_name(:criticity) => @compliance_control.criticity,
- ComplianceControl.human_attribute_name(:comment) => @compliance_control.comment,
- I18n.t('activerecord.attributes.compliance_control.predicate') => @compliance_control.predicate,
- I18n.t('activerecord.attributes.compliance_control.prerequisite') => @compliance_control.prerequisite,
- }.merge( \
- {}.tap do |hash| \
- @compliance_control.class.dynamic_attributes.each do |attribute| \
- hash[ComplianceControl.human_attribute_name(attribute)] = @compliance_control.send(attribute) \
- end \
- end \
- )
+ = render partial: "shared/controls/metadatas"
- if @compliance_control.compliance_control_block
= definition_list t('compliance_controls.show.metadatas.compliance_control_block'),
I18n.t('activerecord.attributes.compliance_control_blocks.transport_mode') => I18n.t("enumerize.transport_mode.#{@compliance_control.compliance_control_block.transport_mode}"),
diff --git a/app/views/lines/show.html.slim b/app/views/lines/show.html.slim
index 34b907bdd..96bb5bb0d 100644
--- a/app/views/lines/show.html.slim
+++ b/app/views/lines/show.html.slim
@@ -6,13 +6,13 @@
.row
.col-lg-6.col-md-6.col-sm-12.col-xs-12
= definition_list t('metadatas'),
- { 'ID Codif' => @line.get_objectid.short_id,
- 'Activé' => (@line.deactivated? ? t('false') : t('true')),
+ { t('id_codif') => @line.get_objectid.short_id,
+ @line.human_attribute_name(:deactivated) => (@line.deactivated? ? t('false') : t('true')),
@line.human_attribute_name(:network_id) => (@line.network.nil? ? t('lines.index.unset') : @line.network.name),
@line.human_attribute_name(:company_id) => (@line.company.nil? ? t('lines.index.unset') : @line.company.name),
- 'Transporteur(s) secondaire(s)' => (@line.secondary_companies.nil? ? t('lines.index.unset') : array_to_html_list(@line.secondary_companies.collect(&:name))),
- 'Nom court' => @line.number,
- 'Code public' => (@line.registration_number ? @line.registration_number : '-'),
+ @line.human_attribute_name(:secondary_companies) => (@line.secondary_companies.nil? ? t('lines.index.unset') : array_to_html_list(@line.secondary_companies.collect(&:name))),
+ @line.human_attribute_name(:number) => @line.number,
+ @line.human_attribute_name(:registration_number) => (@line.registration_number ? @line.registration_number : '-'),
@line.human_attribute_name(:transport_mode) => (@line.transport_mode.present? ? t("enumerize.transport_mode.#{@line.transport_mode}") : '-'),
@line.human_attribute_name(:transport_submode) => (@line.transport_submode.present? ? t("enumerize.transport_submode.#{@line.transport_submode}") : '-'),
@line.human_attribute_name(:url) => (@line.url ? @line.url : '-'),
diff --git a/app/views/shared/controls/_metadatas.html.slim b/app/views/shared/controls/_metadatas.html.slim
new file mode 100644
index 000000000..49df06166
--- /dev/null
+++ b/app/views/shared/controls/_metadatas.html.slim
@@ -0,0 +1,15 @@
+= definition_list t('metadatas'),
+ { \
+ ComplianceControl.human_attribute_name(:name) => resource.name,
+ ComplianceControl.human_attribute_name(:code) => resource.code,
+ ComplianceControl.human_attribute_name(:criticity) => resource.criticity,
+ ComplianceControl.human_attribute_name(:comment) => resource.comment,
+ I18n.t('activerecord.attributes.compliance_control.predicate') => resource.predicate,
+ I18n.t('activerecord.attributes.compliance_control.prerequisite') => resource.prerequisite,
+ }.merge( \
+ {}.tap do |hash| \
+ resource.class.dynamic_attributes.each do |attribute| \
+ hash[ComplianceControl.human_attribute_name(attribute)] = resource.send(attribute) \
+ end \
+ end \
+ )
diff --git a/app/views/stop_areas/show.html.slim b/app/views/stop_areas/show.html.slim
index a4e14a272..34b872e91 100644
--- a/app/views/stop_areas/show.html.slim
+++ b/app/views/stop_areas/show.html.slim
@@ -20,7 +20,7 @@
@stop_area.human_attribute_name(:zip_code) => @stop_area.zip_code,
@stop_area.human_attribute_name(:city_name) => @stop_area.city_name,
@stop_area.human_attribute_name(:country_code) => @stop_area.country_code.presence || '-',
- 'Etat' => (@stop_area.deleted_at ? 'Supprimé' : 'Actif'),
+ t('activerecord.attributes.stop_area.state') => (@stop_area.deleted_at ? t('stop_areas.show.state.deactivated') : t('stop_areas.show.state.active')),
@stop_area.human_attribute_name(:comment) => @stop_area.try(:comment),
})
= definition_list t('metadatas'), attributes
diff --git a/config/breadcrumbs.rb b/config/breadcrumbs.rb
index 00ccf16bd..adcbb0b6f 100644
--- a/config/breadcrumbs.rb
+++ b/config/breadcrumbs.rb
@@ -8,7 +8,7 @@ end
crumb :workbench_output do |workbench|
link I18n.t('workbench_outputs.show.title'), workbench_output_path(workbench)
- parent :workbench, current_offer_workbench
+ parent :workbench, mutual_workbench(workbench)
end
crumb :merges do |workbench|
@@ -96,6 +96,11 @@ crumb :compliance_check_set do |workbench, compliance_check_set|
parent :compliance_check_sets, workbench
end
+crumb :compliance_check do |workbench, compliance_check|
+ link breadcrumb_name(compliance_check), workbench_compliance_check_set_compliance_check_path(workbench, compliance_check.compliance_check_set, compliance_check)
+ parent :compliance_check_set_executed, workbench, compliance_check.compliance_check_set
+end
+
crumb :compliance_check_set_executed do |workbench, compliance_check_set|
link I18n.t('compliance_check_sets.executed.title', name: compliance_check_set.name), executed_workbench_compliance_check_set_path(workbench, compliance_check_set)
parent :compliance_check_sets, workbench
diff --git a/config/locales/compliance_checks.en.yml b/config/locales/compliance_checks.en.yml
index 177c87852..f960755da 100644
--- a/config/locales/compliance_checks.en.yml
+++ b/config/locales/compliance_checks.en.yml
@@ -8,3 +8,7 @@ en:
subclass: Object
criticity: Severity
name: Name
+ show:
+ title: "Compliance check"
+ metadatas:
+ compliance_control_block: "Control block informations"
diff --git a/config/locales/compliance_checks.fr.yml b/config/locales/compliance_checks.fr.yml
index d11d37003..041ab4f43 100644
--- a/config/locales/compliance_checks.fr.yml
+++ b/config/locales/compliance_checks.fr.yml
@@ -11,4 +11,7 @@ fr:
subclass: Objet
criticity: Criticité
name: Nom
-
+ show:
+ title: "Consulter un contrôle"
+ metadatas:
+ compliance_control_block: "Informations sur le groupe de contrôle"
diff --git a/config/locales/compliance_controls.en.yml b/config/locales/compliance_controls.en.yml
index ca9d83872..f7d461fdb 100644
--- a/config/locales/compliance_controls.en.yml
+++ b/config/locales/compliance_controls.en.yml
@@ -29,8 +29,6 @@ en:
title: "Add a new compliance control"
edit:
title: "Update compliance control"
- metas:
- no_prerequisite: "None"
actions:
new: Add
edit: Edit
@@ -41,6 +39,7 @@ en:
messages:
3_route_1: "The route with %{source_objectid} objectid connect the stop points %{target_0_label} (%{target_0_objectid}) and %{target_1_label} (%{target_1_objectid}) which belong to the same ZDL"
description: "Two stop points which belong to the same ZDL cannot follow one another in a route"
+ prerequisite: "None"
route_control/opposite_route:
messages:
3_route_2: "The route with %{source_objectid} objectid references an incoherent oppposite route %{target_0_objectid}"
@@ -53,10 +52,12 @@ en:
messages:
3_route_3: "The route with %{source_objectid} objectid doesn't have any journey pattern"
description: "A route must have at least one journey pattern"
+ prerequisite: "None"
route_control/duplicates:
messages:
3_route_4: "The route with %{source_objectid} objectid is identical with another route %{target_0_objectid}"
description: "2 routes cannot connect the same stop points with the same order and the same boarding and alighting characteristics"
+ prerequisite: "None"
route_control/opposite_route_terminus:
messages:
3_route_5: "The route with %{source_objectid} objectid has a first stop from the %{target_0_label} ZDL whereas its oppoite route's last stop is from the ZDL %{target_1_label}"
@@ -66,78 +67,95 @@ en:
messages:
3_route_6: "The route with %{source_objectid} objectid does not connect enough stop points (required 2 stop points)"
description: "A route must have at least 2 stop points"
+ prerequisite: "None"
route_control/stop_points_in_journey_pattern:
messages:
3_route_8: "The stop point %{target_0_label} (%{target_0_objectid}) of the route %{source_objectid} is not used by any journey pattern"
description: "The stop points of a route must be used by at least one journey pattern"
+ prerequisite: "None"
route_control/omnibus_journey_pattern:
messages:
3_route_9: "The route with %{source_objectid} objectid does not have a journey pattern that connect all of its stop points"
description: "A journey pattern of a route should connect all of a route's stop points"
+ prerequisite: "None"
route_control/unactivated_stop_point:
messages:
3_route_10: "L'itinéraire %{source_objectid} référence un arrêt (ZDEp) désactivé %{target_0_label} (%{target_0_objectid})"
description: "Les arrêts d'un itinéraire ne doivent pas être désactivés"
+ prerequisite: "None"
journey_pattern_control/duplicates:
messages:
3_journeypattern_1: "The journey pattern with objectid %{source_objectid} is identical with another one %{target_0_objectid}"
description: "Two journey patterns belonging to the same line must not connect the same stop points in the same order"
+ prerequisite: "None"
journey_pattern_control/vehicle_journey:
messages:
3_journeypattern_2: "The journey pattern with %{source_objectid} objectid doesn't have any vehicle journey"
description: "A journey pattern must have at least one vehicle journey"
+ prerequisite: "None"
vehicle_journey_control/waiting_time:
messages:
3_vehiclejourney_1: "On the following vehicle journey %{source_objectid}, the waiting time %{error_value} a this stop point %{target_0_label} (%{target_0_objectid}) is greater than the threshold (%{reference_value})"
description: "The waiting time, in minutes, at a specific stop point cannot be too big"
+ prerequisite: "None"
vehicle_journey_control/speed:
messages:
3_vehiclejourney_2_1: "On the following vehicle journey %{source_objectid}, the computed speed %{error_value} between the stop points %{target_0_label} (%{target_0_objectid}) and %{target_1_label} (%{target_1_objectid}) is greater than the threshold (%{reference_value})"
3_vehiclejourney_2_2: "On the following vehicle journey %{source_objectid}, the computed speed %{error_value} between the stop points %{target_0_label} (%{target_0_objectid}) and %{target_1_label} (%{target_1_objectid}) is smaller than the threshold (%{reference_value})"
description: "The speed between 2 stop points should be confined between thresholds"
+ prerequisite: "None"
vehicle_journey_control/delta:
messages:
3_vehiclejourney_3: "The travel time on the vehicle journey with %{source_objectid} objectid between the stop points %{target_0_label} (%{target_0_objectid}) and %{target_1_label} (%{target_1_objectid}) is too far off %{error_value} the average waiting on the journey pattern"
description: "The travel time between two following stop points must be close to all the vehicle journey of a journey pattern"
+ prerequisite: "None"
vehicle_journey_control/time_table:
messages:
3_vehiclejourney_4: "The vehicle journey with %{source_objectid} objectid does not have a timetable"
description: "A vehicle journey must have at least one timetable"
+ prerequisite: "None"
vehicle_journey_control/vehicle_journey_at_stops:
messages:
3_vehiclejourney_5_1: "The vehicle journey with %{source_objectid} objectid has an arrival time %{error_value} greater than the departure time %{reference_value} at the stop point %{target_0_label} (%{target_0_objectid})"
3_vehiclejourney_5_2: "The vehicle journey with %{source_objectid} objectid has an departure time %{error_value} at stop point %{target_0_label} (%{target_0_objectid}) greater than the arrival %{reference_value} at the next stop point"
description: "The arrival time of a stop point must be smaller than the departure time of this stop point AND the departure time of the stop points must be in chronological order"
+ prerequisite: "None"
routing_constraint_zone_control/vehicle_journey_at_stops:
messages:
3_routingconstraint_1: "The Routing Constraint Zone %{source_objectid} references an unactivated stop point (ZDEp) %{target_0_label} (%{target_0_objectid})"
description: "The stop points of a Routing Constraint Zone must be activated"
+ prerequisite: "None"
routing_constraint_zone_control/maximum_length:
messages:
3_routingconstraint_2: "The Routing Constraint Zone %{source_objectid} covers all the stop points of its related route : %{target_0_objectid}."
description: "A Routing Constraint Zone cannot cover all the stop points of a route"
+ prerequisite: "None"
routing_constraint_zone_control/minimum_length:
messages:
3_routingconstraint_3: "The Routing Constraint Zone %{source_objectid} has less than 2 stop points"
description: "A Routing Constraint Zone must have at least 2 stop points"
+ prerequisite: "None"
line_control/route:
messages:
3_line_1: "On line :%{source_label} (%{source_objectid}), no route has an opposite route"
description: "The routes of a line must have an opposite route"
- prerequisite: Lign has multiple routes
+ prerequisite: Line has multiple routes
generic_attribute_control/pattern:
messages:
3_generic_1: "%{source_objectid} : the %{source_attribute} attribute value (%{error_value}) does not respect the following pattern : %{reference_value}"
description: "The object attribute must respect a patten (regular expression)"
+ prerequisite: "None"
generic_attribute_control/min_max:
messages:
3_generic_2_1: "%{source_objectid} : the %{source_attribute} attributes's value (%{error_value}) is greater than the authorized maximum value : %{reference_value}"
3_generic_2_2: "%{source_objectid} : the %{source_attribute} attributes's value (%{error_value}) is smaller than the authorized minimum value %{reference_value}"
description: "The numeric value of an attribute must be contained between 2 values"
+ prerequisite: "None"
generic_attribute_control/uniqueness:
messages:
3_generic_3: "%{source_objectid} : the %{source_attribute} attribute (%{error_value}) has a value shared with : %{target_0_objectid}"
description: "The attribute's value must be unique compared to the other objects ofthe same type (related to the same line)"
+ prerequisite: "None"
shape_control:
3_shape_1: "Tracé %{source_objectid} : le tracé passe trop loin de l'arrêt %{target_0_label} (%{target_0_objectid}) : %{error_value} > %{reference_value}"
3_shape_2: "Tracé %{source_objectid} : le tracé n'est pas défini entre les arrêts %{target_0_label} (%{target_0_objectid}) et %{target_1_label} (%{target_1_objectid})"
diff --git a/config/locales/compliance_controls.fr.yml b/config/locales/compliance_controls.fr.yml
index f5f7e351f..44d01a973 100644
--- a/config/locales/compliance_controls.fr.yml
+++ b/config/locales/compliance_controls.fr.yml
@@ -28,8 +28,6 @@ fr:
title: "Editer un contrôle"
select_type:
title: "Sélectionner un type de contrôle"
- metas:
- no_prerequisite: "Aucun"
actions:
new: Ajouter
edit: Editer
@@ -40,6 +38,7 @@ fr:
messages:
3_route_1: "L'itinéraire %{source_objectid} dessert successivement les arrêts %{target_0_label} (%{target_0_objectid}) et %{target_1_label} (%{target_1_objectid}) de la même zone de lieu"
description: "Deux arrêts d’une même ZDL ne peuvent pas se succéder dans un itinéraire"
+ prerequisite: "Aucun"
route_control/opposite_route:
messages:
3_route_2: "L'itinéraire %{source_objectid} référence un itinéraire retour %{target_0_objectid} incohérent"
@@ -52,10 +51,12 @@ fr:
messages:
3_route_3: "L'itinéraire %{source_objectid} n'a pas de mission"
description: "Un itinéraire doit avoir au moins une mission"
+ prerequisite: "Aucun"
route_control/duplicates:
messages:
3_route_4: "L'itinéraire %{source_objectid} est identique à l'itinéraire %{target_0_objectid}"
description: "2 itinéraires ne doivent pas desservir strictement les mêmes arrêts dans le même ordre avec les mêmes critères de monté/descente"
+ prerequisite: "Aucun"
route_control/opposite_route_terminus:
messages:
3_route_5: "L'itinéraire %{source_objectid} dessert au départ un arrêt de la ZDL %{target_0_label} alors que l'itinéraire inverse dessert à l'arrivée un arrêt de la ZDL %{target_1_label}"
@@ -65,60 +66,74 @@ fr:
messages:
3_route_6: "L'itinéraire %{source_objectid} ne dessert pas assez d'arrêts (minimum 2 requis)"
description: "Un itinéraire doit référencer au moins 2 arrêts"
+ prerequisite: "Aucun"
route_control/stop_points_in_journey_pattern:
messages:
3_route_8: "l'arrêt %{target_0_label} (%{target_0_objectid}) de l'itinéraire %{source_objectid} n'est desservi par aucune mission"
description: "Les arrêts de l'itinéraire doivent être desservis par au moins une mission"
+ prerequisite: "Aucun"
route_control/omnibus_journey_pattern:
messages:
3_route_9: "L'itinéraire %{source_objectid} n'a aucune mission desservant l'ensemble de ses arrêts"
description: "Une mission de l'itinéraire devrait desservir l'ensemble des arrêts de celui-ci"
+ prerequisite: "Aucun"
route_control/unactivated_stop_point:
messages:
3_route_10: "L'itinéraire %{source_objectid} référence un arrêt (ZDEp) désactivé %{target_0_label} (%{target_0_objectid})"
description: "Les arrêts d'un itinéraire ne doivent pas être désactivés"
+ prerequisite: "Aucun"
journey_pattern_control/duplicates:
messages:
3_journeypattern_1: "La mission %{source_objectid} est identique à la mission %{target_0_objectid}"
description: "Deux missions de la même ligne ne doivent pas desservir les mêmes arrêts dans le même ordre"
+ prerequisite: "Aucun"
journey_pattern_control/vehicle_journey:
messages:
3_journeypattern_2: "La mission %{source_objectid} n'a pas de course"
description: "Une mission doit avoir au moins une course"
+ prerequisite: "Aucun"
vehicle_journey_control/waiting_time:
messages:
3_vehiclejourney_1: "Sur la course %{source_objectid}, le temps d'attente %{error_value} à l'arrêt %{target_0_label} (%{target_0_objectid}) est supérieur au seuil toléré (%{reference_value})"
description: "La durée d’attente, en minutes, à un arrêt ne doit pas être trop grande"
+ prerequisite: "Aucun"
vehicle_journey_control/speed:
messages:
3_vehiclejourney_2_1: "Sur la course %{source_objectid}, la vitesse calculée %{error_value} entre les arrêts %{target_0_label} (%{target_0_objectid}) et %{target_1_label} (%{target_1_objectid}) est supérieure au seuil toléré (%{reference_value})"
3_vehiclejourney_2_2: "Sur la course %{source_objectid}, la vitesse calculée %{error_value} entre les arrêts %{target_0_label} (%{target_0_objectid}) et %{target_1_label} (%{target_1_objectid}) est inférieure au seuil toléré (%{reference_value})"
description: "La vitesse entre deux arrêts doit être dans une fourchette paramétrable"
+ prerequisite: "Aucun"
vehicle_journey_control/delta:
messages:
3_vehiclejourney_3: "Le temps de parcours sur la course %{source_objectid} entre les arrêts %{target_0_label} (%{target_0_objectid}) et %{target_1_label} (%{target_1_objectid}) s'écarte de %{error_value} du temps moyen constaté sur la mission"
description: "Les temps de parcours entre 2 arrêts successifs doivent être similaires pour toutes les courses d’une même mission"
+ prerequisite: "Aucun"
vehicle_journey_control/time_table:
messages:
3_vehiclejourney_4: "La course %{source_objectid} n'a pas de calendrier d'application"
description: "Une course doit avoir au moins un calendrier d’application"
+ prerequisite: "Aucun"
vehicle_journey_control/vehicle_journey_at_stops:
messages:
3_vehiclejourney_5_1: "La course %{source_objectid} a un horaire d'arrivé %{error_value} supérieur à l'horaire de départ %{reference_value} à l'arrêt %{target_0_label} (%{target_0_objectid})"
3_vehiclejourney_5_2: "La course %{source_objectid} a un horaire de départ %{error_value} à l'arrêt %{target_0_label} (%{target_0_objectid}) supérieur à l'horaire d'arrivé %{reference_value} à l'arrêt suivant"
description: "L'horaire d'arrivée à un arrêt doit être antérieur à l'horaire de départ de cet arrêt ET les horaires de départ aux arrêts doivent être dans l'ordre chronologique croissant."
+ prerequisite: "Aucun"
routing_constraint_zone_control/unactivated_stop_point:
messages:
3_routingconstraint_1: "L'ITL %{source_objectid} référence un arrêt (ZDEp) désactivé %{target_0_label} (%{target_0_objectid})"
description: "Les arrêts d'une ITL ne doivent pas être désactivés"
+ prerequisite: "Aucun"
routing_constraint_zone_control/maximum_length:
messages:
3_routingconstraint_2: "L'ITL %{source_objectid} couvre tous les arrêts de l'itinéraire %{target_0_objectid}."
description: "Une ITL ne peut pas couvrir l'ensemble des arrêts de l'itinéraire"
+ prerequisite: "Aucun"
routing_constraint_zone_control/minimum_length:
messages:
3_routingconstraint_3: "L'ITL %{source_objectid} n'a pas suffisament d'arrêts (minimum 2 arrêts requis)"
description: "Une ITL doit référencer au moins 2 arrêts"
+ prerequisite: "Aucun"
line_control/route:
messages:
3_line_1: "Sur la ligne %{source_label} (%{source_objectid}), aucun itinéraire n'a d'itinéraire inverse"
@@ -128,15 +143,18 @@ fr:
messages:
3_generic_1: "%{source_objectid} : l'attribut %{source_attribute} a une valeur %{error_value} qui ne respecte pas le motif %{reference_value}"
description: "l'attribut de l'objet doit respecter un motif (expression régulière)"
+ prerequisite: "Aucun"
generic_attribute_control/min_max:
messages:
3_generic_2_1: "%{source_objectid} : l'attribut %{source_attribute} a une valeur %{error_value} supérieure à la valeur maximale autorisée %{reference_value}"
3_generic_2_2: "%{source_objectid} : l'attribut %{source_attribute} a une valeur %{error_value} inférieure à la valeur minimale autorisée %{reference_value}"
description: "La valeur numérique de l'attribut doit rester comprise entre 2 valeurs"
+ prerequisite: "Aucun"
generic_attribute_control/uniqueness:
messages:
3_generic_3: "%{source_objectid} : l'attribut %{source_attribute} a une valeur %{error_value} partagée avec %{target_0_objectid}"
description: "La valeur de l'attribut doit être unique au sein des objets de la ligne"
+ prerequisite: "Aucun"
shape_control:
3_shape_1: "Tracé %{source_objectid} : le tracé passe trop loin de l'arrêt %{target_0_label} (%{target_0_objectid}) : %{error_value} > %{reference_value}"
3_shape_2: "Tracé %{source_objectid} : le tracé n'est pas défini entre les arrêts %{target_0_label} (%{target_0_objectid}) et %{target_1_label} (%{target_1_objectid})"
diff --git a/config/locales/stop_areas.en.yml b/config/locales/stop_areas.en.yml
index c1ced1094..ac3dce280 100644
--- a/config/locales/stop_areas.en.yml
+++ b/config/locales/stop_areas.en.yml
@@ -66,6 +66,9 @@ en:
access_managment: "Access Points and Links managment"
access_points: "Access Points"
not_editable: "Le type d'arrêt est non modifiable"
+ state:
+ active: Active
+ deactivated: Deactivated
genealogical:
genealogical: "Links between stop area"
genealogical_routing: "Routing constraint's links"
@@ -139,6 +142,7 @@ en:
created_at: Created at
updated_at: Updated at
waiting_time: Waiting time (minutes)
+ state: State
formtastic:
titles:
stop_area:
diff --git a/config/locales/stop_areas.fr.yml b/config/locales/stop_areas.fr.yml
index ede1aada6..f75c4ebe7 100644
--- a/config/locales/stop_areas.fr.yml
+++ b/config/locales/stop_areas.fr.yml
@@ -67,6 +67,9 @@ fr:
access_managment: "Gestion des accès et liens associés"
access_points: "Points d'accès"
not_editable: "Le type d'arrêt est non modifiable"
+ state:
+ active: Actif
+ deactivated: Désactivé
genealogical:
genealogical: "Lien entre arrêts"
genealogical_routing: "Liens de l'ITL"
@@ -141,6 +144,7 @@ fr:
created_at: "Créé le"
updated_at: "Edité le"
waiting_time: Temps de desserte (minutes)
+ state: État
formtastic:
titles:
stop_area:
diff --git a/db/migrate/20180227151937_add_compliance_control_name_to_compliance_checks.rb b/db/migrate/20180227151937_add_compliance_control_name_to_compliance_checks.rb
new file mode 100644
index 000000000..49ab0da11
--- /dev/null
+++ b/db/migrate/20180227151937_add_compliance_control_name_to_compliance_checks.rb
@@ -0,0 +1,5 @@
+class AddComplianceControlNameToComplianceChecks < ActiveRecord::Migration
+ def change
+ add_column :compliance_checks, :compliance_control_name, :string
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index c709290f5..045fc658d 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,12 +11,12 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20180202170009) do
+ActiveRecord::Schema.define(version: 20180227151937) 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"
create_table "access_links", id: :bigserial, force: :cascade do |t|
@@ -90,9 +90,9 @@ ActiveRecord::Schema.define(version: 20180202170009) 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
end
add_index "calendars", ["organisation_id"], name: "index_calendars_on_organisation_id", using: :btree
@@ -119,7 +119,6 @@ ActiveRecord::Schema.define(version: 20180202170009) 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
@@ -221,6 +220,7 @@ ActiveRecord::Schema.define(version: 20180202170009) do
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "origin_code"
+ t.string "compliance_control_name"
end
add_index "compliance_checks", ["compliance_check_block_id"], name: "index_compliance_checks_on_compliance_check_block_id", using: :btree
@@ -421,9 +421,9 @@ ActiveRecord::Schema.define(version: 20180202170009) 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
diff --git a/lib/compliance_control_set_copier.rb b/lib/compliance_control_set_copier.rb
index 58d40cdbf..06622f302 100644
--- a/lib/compliance_control_set_copier.rb
+++ b/lib/compliance_control_set_copier.rb
@@ -21,7 +21,7 @@ class ComplianceControlSetCopier
# Workers
# -------
def check_organisation_coherence!
- return true if cc_set.organisation_id == referential.organisation_id
+ return true if cc_set.organisation_id == referential.organisation_id
raise ArgumentError, "Incoherent organisation of referential"
end
@@ -66,7 +66,8 @@ class ComplianceControlSetCopier
name: name_with_refid(compliance_control.name),
comment: compliance_control.comment,
code: compliance_control.code,
- origin_code: compliance_control.origin_code
+ origin_code: compliance_control.origin_code,
+ compliance_control_name: compliance_control.class.name
).tap do | compliance_check |
control_id_to_check.update compliance_control.id => compliance_check
end
diff --git a/lib/tasks/seeds.rake b/lib/tasks/seeds.rake
new file mode 100644
index 000000000..9038b64f9
--- /dev/null
+++ b/lib/tasks/seeds.rake
@@ -0,0 +1,19 @@
+namespace :db do
+
+ include Seedbank::DSL
+
+ base_dependencies = ['db:seed:original']
+ override_dependency = ['db:seed:common']
+
+ namespace :seed do
+ seeds_environment = ENV.fetch("SEED_ENV", Rails.env)
+ glob_seed_files_matching('/*/').each do |directory|
+ environment = File.basename(directory)
+ override_dependency << "db:seed:#{environment}" if defined?(Rails) && seeds_environment == environment
+ end
+ end
+
+ # Override db:seed to run all the common and environments seeds plus the original db:seed.
+ desc 'Load the seed data from db/seeds.rb, db/seeds/*.seeds.rb and db/seeds/ENVIRONMENT/*.seeds.rb. ENVIRONMENT is the env var SEED_ENV or the current environment in Rails.env.'
+ override_seed_task :seed => override_dependency
+end
diff --git a/spec/helpers/table_builder_helper_spec.rb b/spec/helpers/table_builder_helper_spec.rb
index 478875118..b0c17859f 100644
--- a/spec/helpers/table_builder_helper_spec.rb
+++ b/spec/helpers/table_builder_helper_spec.rb
@@ -441,6 +441,53 @@ describe TableBuilderHelper, type: :helper do
allow(helper).to receive(:mutual_workbench).and_return(referential.workbench)
}
+ context "with a condition" do
+ let(:columns){
+ [
+ TableBuilderHelper::Column.new(
+ key: :name,
+ attribute: 'name',
+ if: condition
+ ),
+ ]
+ }
+
+ context "when the condition is true" do
+ let(:condition){ ->(obj){true} }
+ it "should show the value" do
+ items.each do |i|
+ tr = helper.send(:tr, i, columns, selectable, links, overhead, model_name, :index)
+ klass = "#{TableBuilderHelper.item_row_class_name([referential])}-#{i.id}"
+ expect(tr).to include(i.name)
+ end
+ end
+ end
+
+ context "when the condition depends on the object" do
+ let(:condition){ ->(obj){ obj == referential } }
+ it "should show the value accordingly" do
+ tr = helper.send(:tr, item, columns, selectable, links, overhead, model_name, :index)
+ klass = "#{TableBuilderHelper.item_row_class_name([referential])}-#{referential.id}"
+ expect(tr).to include(referential.name)
+ tr = helper.send(:tr, other_item, columns, selectable, links, overhead, model_name, :index)
+ klass = "#{TableBuilderHelper.item_row_class_name([referential])}-#{other_referential.id}"
+ expect(tr).to_not include(other_referential.name)
+ end
+ end
+
+ context "when the condition is false" do
+ let(:condition){ ->(obj){false} }
+ it "should not show the value" do
+ items.each do |i|
+ tr = helper.send(:tr, i, columns, selectable, links, overhead, model_name, :index)
+ klass = "#{TableBuilderHelper.item_row_class_name([referential])}-#{i.id}"
+ expect(tr).to_not include(i.name)
+ end
+ end
+ end
+
+ end
+
context "with all rows non-selectable" do
let(:selectable){ false }
it "sets all rows as non selectable" do