aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuc Donnet2015-05-18 12:41:13 +0200
committerLuc Donnet2015-05-18 12:41:13 +0200
commit3a997856387b2d50178c29c5bd728b133f2dcd84 (patch)
treeff0af160b83933dc42aafc593cfa4f31befd0a0b
parent1ee52cce4c325a58368f3e28e8070f7b3bb4f4f2 (diff)
downloadchouette-core-3a997856387b2d50178c29c5bd728b133f2dcd84.tar.bz2
Fix bugs Refs #0035525 #0035531 #0035523
-rw-r--r--app/assets/javascripts/application.js1
-rw-r--r--app/assets/javascripts/compliance_checks/show.js.coffee43
-rw-r--r--app/assets/stylesheets/main/compliance_checks.css.scss24
-rw-r--r--app/assets/stylesheets/modules/links.css.scss2
-rw-r--r--app/controllers/compliance_check_results_controller.rb47
-rw-r--r--app/controllers/compliance_checks_controller.rb35
-rw-r--r--app/controllers/imports_controller.rb20
-rw-r--r--app/helpers/breadcrumb_helper.rb3
-rw-r--r--app/helpers/compliance_check_results_helper.rb17
-rw-r--r--app/helpers/compliance_checks_helper.rb64
-rw-r--r--app/helpers/validation_results_helper.rb66
-rw-r--r--app/models/compliance_check.rb20
-rw-r--r--app/models/compliance_check_export.rb2
-rw-r--r--app/models/compliance_check_result.rb68
-rw-r--r--app/models/import.rb24
-rw-r--r--app/models/rule_parameter_set.rb3
-rw-r--r--app/views/compliance_check_results/_compliance_check_result.erb21
-rw-r--r--app/views/compliance_check_results/index.js.coffee8
-rw-r--r--app/views/compliance_checks/_compliance_check.html.erb4
-rw-r--r--app/views/compliance_checks/_compliance_check_results.erb (renamed from app/views/compliance_check_results/index.html.erb)46
-rw-r--r--app/views/compliance_checks/detailed_errors_index.csv.erb2
-rw-r--r--app/views/compliance_checks/show.html.erb53
-rw-r--r--app/views/compliance_checks/show.js.coffee52
-rw-r--r--app/views/compliance_checks/show_for_import.js.coffee52
-rw-r--r--app/views/compliance_checks/summary_errors_index.csv.erb4
-rw-r--r--app/views/imports/_import.erb1
-rw-r--r--app/views/imports/rule_parameter_set.html.erb161
-rw-r--r--app/views/imports/show.html.erb1
-rw-r--r--config/locales/compliance_check_results.yml4
-rw-r--r--config/routes.rb9
30 files changed, 258 insertions, 599 deletions
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index e3a32bf6b..b8e391129 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -24,6 +24,7 @@
//= require_directory ./vehicle_journeys
//= require_directory ./import_tasks
//= require_directory ./compliance_check_tasks
+//= require_directory ./compliance_checks
//= require_directory ./export_tasks
//= require_directory ./exports
//= require_directory ./lines
diff --git a/app/assets/javascripts/compliance_checks/show.js.coffee b/app/assets/javascripts/compliance_checks/show.js.coffee
new file mode 100644
index 000000000..8b3c2d6ca
--- /dev/null
+++ b/app/assets/javascripts/compliance_checks/show.js.coffee
@@ -0,0 +1,43 @@
+$(".compliance_checks.show, .imports.compliance_check").ready ->
+
+ get_compliance_check_results = (html_container, css_class) ->
+ html_container.each ->
+ if( $( this ).hasClass(css_class) )
+ $( this ).show()
+ else
+ $( this ).hide()
+
+ Morris.Donut({
+ element: 'error',
+ data: [
+ { label: $(".table").data('title-nok'), value: $("tr.nok_error").size() },
+ { label: $(".table").data('title-uncheck'), value: $("tr.uncheck_error").size() },
+ { label: $(".table").data('title-ok'), value: $("tr.ok_error").size() }
+ ],
+ colors: [ "#e22b1b", "#898e7f", "#8fc861" ]
+ }).on('click', update = (i, row) ->
+ switch i
+ when 0 then get_compliance_check_results( $(".report tbody tr"), "nok_error")
+ when 1 then get_compliance_check_results( $(".report tbody tr"), "uncheck_error")
+ when 2 then get_compliance_check_results( $(".report tbody tr"), "ok_error") )
+
+ Morris.Donut({
+ element: 'warning',
+ data: [
+ { label: $(".table").data('title-nok'), value: $("tr.nok_warning").size() },
+ { label: $(".table").data('title-uncheck'), value: $("tr.uncheck_warning").size() },
+ { label: $(".table").data('title-ok'), value: $("tr.ok_warning").size() }
+ ],
+ colors: [ "#ffbd2b", "#898e7f", "#8fc861" ]
+ }).on('click', update = (i, row) ->
+ switch i
+ when 0 then get_compliance_check_results( $(".report tbody tr"), "nok_warning")
+ when 1 then get_compliance_check_results( $(".report tbody tr"), "uncheck_warning")
+ when 2 then get_compliance_check_results( $(".report tbody tr"), "ok_warning") )
+
+ $(".notice").popover({ container: "body", html: false, trigger: "focus", placement: "bottom" })
+ # Hide and show error details
+ $(".title_error").each ->
+ $( this ).click ->
+ $(this).next(".details_error").toggle()
+ $(this).children("i").toggleClass("fa-plus-square fa-minus-square")
diff --git a/app/assets/stylesheets/main/compliance_checks.css.scss b/app/assets/stylesheets/main/compliance_checks.css.scss
index e3ba53937..35d0de92e 100644
--- a/app/assets/stylesheets/main/compliance_checks.css.scss
+++ b/app/assets/stylesheets/main/compliance_checks.css.scss
@@ -2,23 +2,17 @@
{
}
-#workspace.compliance_checks.show {
+#workspace.compliance_checks.show, #workspace.imports.compliance_check{
@import "../modules/job_status_colors";
+ @import "../modules/links";
+
+ h2{
+ i{ margin: 0 5px 0 0; }
+ }
.status {
margin-left: 10px;
- }
-
- .status_failed { color: #a94442;}
- .status_pending { color: #31708f;}
- .status_processing { color: #31708f;}
- .status_completed { color: #3c763d;}
-
- .links{
- margin: 0px 0 20px 0;
-
- img{ margin: 0 5px 0 15px; }
- }
+ }
.order{
margin-bottom: 10px;
@@ -29,11 +23,11 @@
.status_ok_error { color: #8fc861; }
.status_nok_error { color: #e22b1b; }
- .status_na_error { color: #898e7f; }
+ .status_uncheck_error { color: #898e7f; }
.status_ok_warning { color: #8fc861; }
.status_nok_warning { color: #ffbd2b; }
- .status_na_warning { color: #898e7f; }
+ .status_uncheck_warning { color: #898e7f; }
.resume {
&:after{
diff --git a/app/assets/stylesheets/modules/links.css.scss b/app/assets/stylesheets/modules/links.css.scss
index ab9e1fbaf..b97927988 100644
--- a/app/assets/stylesheets/modules/links.css.scss
+++ b/app/assets/stylesheets/modules/links.css.scss
@@ -1,4 +1,6 @@
.links{
+ @include clearfix();
+
margin: 0 0 20px 0;
i{
color: $gray;
diff --git a/app/controllers/compliance_check_results_controller.rb b/app/controllers/compliance_check_results_controller.rb
deleted file mode 100644
index d1f445e45..000000000
--- a/app/controllers/compliance_check_results_controller.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-class ComplianceCheckResultsController < ChouetteController
-
- defaults :resource_class => ComplianceCheckResult
-
- respond_to :json
- respond_to :js, :only => :index
-
- def index
- index! do |format|
- format.html { render :layout => false }
- end
- end
-
- protected
-
- def compliance_check_service
- ComplianceCheckService.new(@referential)
- end
-
- def compliance_check
- @compliance_check ||= compliance_check_service.find( params[:compliance_check_id] )
- end
-
- def import_service
- import_service = ImportService.new(@referential)
- end
-
- def import
- @import = import_service.find(params[:import_id])
- end
-
- def compliance_check_validation_report
- if params[:import_id]
- compliance_check_validation_report ||= import.compliance_check_validation_report
- else
- compliance_check_validation_report ||= compliance_check.compliance_check_validation_report
- end
- end
-
- def collection
- @compliance_check_validation_reports ||= compliance_check_validation_report.all(params[:status], params[:severity]) #.paginate(:page => params[:page])
- end
-
- def rule_parameter_set
- @rule_parameter_set = RuleParameterSet.new.tap { |rps| rps.parameters = resource.parameter_set }
- end
-end
diff --git a/app/controllers/compliance_checks_controller.rb b/app/controllers/compliance_checks_controller.rb
index 976ced921..9a6657e5c 100644
--- a/app/controllers/compliance_checks_controller.rb
+++ b/app/controllers/compliance_checks_controller.rb
@@ -20,11 +20,9 @@ class ComplianceChecksController < ChouetteController
end
def show
- @import = resource if resource.kind_of?(Import)
begin
show! do |format|
build_breadcrumb :show
- format.js { render 'show_for_import.js.coffee' if @import}
end
rescue Ievkit::Error => error
logger.error("Iev failure : #{error.message}")
@@ -43,14 +41,14 @@ class ComplianceChecksController < ChouetteController
end
def rule_parameter_set
- @rule_parameter_set = resource.rule_parameter_set
- build_breadcrumb :edit
- render "rule_parameter_sets/show"
- end
-
- def create
- create! do |success, failure|
- success.html { flash[:notice] = I18n.t('compliance_checks.new.flash'); redirect_to referential_compliance_checks_path(@referential) }
+ begin
+ @rule_parameter_set = resource.rule_parameter_set
+ build_breadcrumb :rule_parameter_set
+ render "rule_parameter_sets/show"
+ rescue Ievkit::Error => error
+ logger.error("Iev failure : #{error.message}")
+ flash[:error] = t('iev.failure')
+ redirect_to referential_path(@referential)
end
end
@@ -64,25 +62,12 @@ class ComplianceChecksController < ChouetteController
alias_method :compliance_check, :resource
- def compliance_check_service
+ def compliance_check_service
ComplianceCheckService.new(@referential)
end
-
- def import_service
- ImportService.new(@referential)
- end
-
- def build_resource(attributes = {})
- @compliance_check ||= ComplianceCheck.new
- end
def resource
- compliance_check ||= compliance_check_service.find(params[:id])
- if compliance_check.datas[:action] == "importer"
- @importer = import_service.find(params[:id])
- else
- @compliance_check = compliance_check
- end
+ @compliance_check ||= compliance_check_service.find(params[:id])
end
def collection
diff --git a/app/controllers/imports_controller.rb b/app/controllers/imports_controller.rb
index 3b02c9026..2c6ba9511 100644
--- a/app/controllers/imports_controller.rb
+++ b/app/controllers/imports_controller.rb
@@ -23,9 +23,7 @@ class ImportsController < ChouetteController
def show
begin
- show! do
- build_breadcrumb :show
- end
+ show!
rescue Ievkit::Error => error
logger.error("Iev failure : #{error.message}")
flash[:error] = t('iev.failure')
@@ -59,9 +57,9 @@ class ImportsController < ChouetteController
def rule_parameter_set
begin
- build_breadcrumb :show
- @rule_parameter_set = RuleParameterSet.new(:name => "").tap{ |rps| rps.parameters = resource.rule_parameter_set["validation"] }
- render "rule_parameter_set"
+ @rule_parameter_set = resource.rule_parameter_set
+ build_breadcrumb :rule_parameter_set
+ render "rule_parameter_sets/show"
rescue Ievkit::Error => error
logger.error("Iev failure : #{error.message}")
flash[:error] = t('iev.failure')
@@ -69,10 +67,16 @@ class ImportsController < ChouetteController
end
end
+ def export
+ respond_to do |format|
+ format.zip { send_file ComplianceCheckExport.new(resource, @referential.id, request).export, :type => :zip }
+ end
+ end
+
def compliance_check
begin
- build_breadcrumb :show
- @import = resource
+ @compliance_check = resource
+ build_breadcrumb :compliance_check
render "compliance_checks/show"
rescue Ievkit::Error => error
logger.error("Iev failure : #{error.message}")
diff --git a/app/helpers/breadcrumb_helper.rb b/app/helpers/breadcrumb_helper.rb
index d99d4a068..ca7b7d946 100644
--- a/app/helpers/breadcrumb_helper.rb
+++ b/app/helpers/breadcrumb_helper.rb
@@ -137,6 +137,8 @@ module BreadcrumbHelper
def import_breadcrumb (action)
referential_breadcrumb
add_breadcrumb Referential.human_attribute_name("imports"), referential_imports_path(@referential) unless action == :index
+ add_breadcrumb @rule_parameter_set.import.name, compliance_check_referential_import_path(@referential, @rule_parameter_set.import.id) if action == :rule_parameter_set
+ add_breadcrumb @compliance_check.name, referential_import_path(@referential, @compliance_check.id) if action == :compliance_check
end
def export_breadcrumb (action)
@@ -147,6 +149,7 @@ module BreadcrumbHelper
def compliance_check_breadcrumb (action)
referential_breadcrumb
add_breadcrumb Referential.human_attribute_name("compliance_checks"), referential_compliance_checks_path(@referential) unless action == :index
+ add_breadcrumb @rule_parameter_set.compliance_check.name, referential_compliance_check_path(@referential, @rule_parameter_set.compliance_check.id) if action == :rule_parameter_set
end
def compliance_check_task_breadcrumb (action)
diff --git a/app/helpers/compliance_check_results_helper.rb b/app/helpers/compliance_check_results_helper.rb
deleted file mode 100644
index c2099562a..000000000
--- a/app/helpers/compliance_check_results_helper.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-module ComplianceCheckResultsHelper
-
- def status_icon( compliance_check_result_status, compliance_check_result_severity )
- if compliance_check_result_status == "na"
- ("<i class='fa fa-ban status_" + compliance_check_result_status + "_" + compliance_check_result_severity + "'></i>").html_safe
- elsif compliance_check_result_status == "ok"
- ("<i class='fa fa-check status_" + compliance_check_result_status + "_" + compliance_check_result_severity + "'></i>").html_safe
- else
- ("<i class='fa fa-times status_" + compliance_check_result_status + "_" + compliance_check_result_severity + "'></i>").html_safe
- end
- end
-
- def test_definition (compliance_check_result_code)
- Rails.application.config.validation_spec + I18n.locale.to_s + "/" + compliance_check_result_code +".html"
- end
-
-end
diff --git a/app/helpers/compliance_checks_helper.rb b/app/helpers/compliance_checks_helper.rb
index d3172fc31..897259853 100644
--- a/app/helpers/compliance_checks_helper.rb
+++ b/app/helpers/compliance_checks_helper.rb
@@ -23,5 +23,69 @@ module ComplianceChecksHelper
end
end
end
+
+ def status_icon( compliance_check_result_status, compliance_check_result_severity )
+ if compliance_check_result_status == "uncheck"
+ ("<i class='fa fa-ban status_" + compliance_check_result_status + "_" + compliance_check_result_severity + "'></i>").html_safe
+ elsif compliance_check_result_status == "ok"
+ ("<i class='fa fa-check status_" + compliance_check_result_status + "_" + compliance_check_result_severity + "'></i>").html_safe
+ else
+ ("<i class='fa fa-times status_" + compliance_check_result_status + "_" + compliance_check_result_severity + "'></i>").html_safe
+ end
+ end
+
+ def test_definition (compliance_check_result_code)
+ Rails.application.config.validation_spec + I18n.locale.to_s + "/" + compliance_check_result_code +".html"
+ end
+
+ def object_url (referential_id, error)
+ location = "/referentials/" + referential_id.to_s
+ object_path = error[:source].object_path
+ if object_path.first[:type] == "vehicle_journey"
+ object_path.delete_at 1
+ end
+ object_path.reverse.each { |sub_path| location = location + "/" + sub_path[:type].to_s.pluralize + "/" + sub_path[:id].to_s }
+ return location
+ end
+
+ def object_labels_hash (error)
+ ### THE error HASH STRUCTURE
+ # 1. error[:source]
+ # 0..1 file
+ # 1 filename
+ # 0..1 line_number
+ # 0..1 column_number
+ # 0..1 objectid
+ # 0..1 label
+ # 0.. object_path
+ # 1 type
+ # 1 id
+ # 0.. error[:target]
+ # 0..1 error[:error_value]
+ # 0..1 error[:reference_value]
+ object_labels_hash = Hash.new
+ object_labels_hash[:source_objectid] = error[:source].objectid if error[:source].objectid.present?
+ object_labels_hash[:source_label] = error[:source].label if error[:source].label.present?
+ if error[:source].file.present?
+ object_labels_hash[:filename] = error[:source].file.filename
+ object_labels_hash[:line_number] = error[:source].file.line_number if error[:source].file.line_number.present?
+ object_labels_hash[:column_number] = error[:source].file.column_number if error[:source].file.column_number.present?
+ end
+
+ if error[:target].present?
+ error[:target].each_with_index do |target, index|
+ object_labels_hash["target_#{index}_objectid".to_sym] = target[:objectid] if target[:objectid]
+ object_labels_hash["target_#{index}_label".to_sym] = target[:label] if target[:label]
+ end
+ end
+ if error[:error_value].present?
+ object_labels_hash[:error_value] = error[:error_value]
+ end
+ if error[:reference_value].present?
+ object_labels_hash[:reference_value] = error[:reference_value]
+ end
+ return object_labels_hash
+ end
+
end
diff --git a/app/helpers/validation_results_helper.rb b/app/helpers/validation_results_helper.rb
deleted file mode 100644
index 3c7c31e00..000000000
--- a/app/helpers/validation_results_helper.rb
+++ /dev/null
@@ -1,66 +0,0 @@
-module ValidationResultsHelper
-
- def status_icon( validation_result_result, validation_result_severity )
- if validation_result_result == "UNCHECK"
- ("<i class='fa fa-ban status_na_" + validation_result_severity.downcase + "'></i>").html_safe
- elsif validation_result_result == "OK"
- ("<i class='fa fa-check status_ok_" + validation_result_severity.downcase + "'></i>").html_safe
- else
- ("<i class='fa fa-times status_nok_" + validation_result_severity.downcase + "'></i>").html_safe
- end
- end
-
- def test_definition (validation_result_code)
- Rails.application.config.validation_spec + I18n.locale.to_s + "/" + validation_result_code +".html"
- end
-
- def object_url (referential_id, error)
- location = "/referentials/" + referential_id.to_s
- object_path = error[:source].object_path
- if object_path.first[:type] == "vehicle_journey"
- object_path.delete_at 1
- end
- object_path.reverse.each { |sub_path| location = location + "/" + sub_path[:type].to_s.pluralize + "/" + sub_path[:id].to_s }
- return location
- end
-
- def object_labels_hash (error)
- ### THE error HASH STRUCTURE
- # 1. error[:source]
- # 0..1 file
- # 1 filename
- # 0..1 line_number
- # 0..1 column_number
- # 0..1 objectid
- # 0..1 label
- # 0.. object_path
- # 1 type
- # 1 id
- # 0.. error[:target]
- # 0..1 error[:error_value]
- # 0..1 error[:reference_value]
- object_labels_hash = Hash.new
- object_labels_hash[:source_objectid] = error[:source].objectid if error[:source].objectid.present?
- object_labels_hash[:source_label] = error[:source].label if error[:source].label.present?
- if error[:source].file.present?
- object_labels_hash[:filename] = error[:source].file.filename
- object_labels_hash[:line_number] = error[:source].file.line_number if error[:source].file.line_number.present?
- object_labels_hash[:column_number] = error[:source].file.column_number if error[:source].file.column_number.present?
- end
-
- if error[:target].present?
- error[:target].each_with_index do |target, index|
- object_labels_hash["target_#{index}_objectid".to_sym] = target[:objectid] if target[:objectid]
- object_labels_hash["target_#{index}_label".to_sym] = target[:label] if target[:label]
- end
- end
- if error[:error_value].present?
- object_labels_hash[:error_value] = error[:error_value]
- end
- if error[:reference_value].present?
- object_labels_hash[:reference_value] = error[:reference_value]
- end
- return object_labels_hash
- end
-
-end
diff --git a/app/models/compliance_check.rb b/app/models/compliance_check.rb
index f0a78839f..110433a8c 100644
--- a/app/models/compliance_check.rb
+++ b/app/models/compliance_check.rb
@@ -1,6 +1,10 @@
class ComplianceCheck
include JobConcern
+ def report?
+ links["action_report"].present?
+ end
+
def report
Rails.cache.fetch("#{cache_key}/action_report", expires_in: cache_expiration) do
report_path = links["action_report"]
@@ -12,6 +16,10 @@ class ComplianceCheck
end
end
end
+
+ def compliance_check_validation_report?
+ links["validation_report"].present?
+ end
def compliance_check_validation_report
Rails.cache.fetch("#{cache_key}/validation_report", expires_in: cache_expiration) do
@@ -25,12 +33,16 @@ class ComplianceCheck
end
end
+ def rule_parameter_set?
+ links["validation_params"].present?
+ end
+
def rule_parameter_set
Rails.cache.fetch("#{cache_key}/validation_params", expires_in: cache_expiration) do
- rule_parameter_set = links["validation_params"]
- if rule_parameter_set
- response = Ievkit.get(rule_parameter_set)
- rule_parameter_set = RuleParameterSet.new.tap { |rps| rps.parameters = response.validation }
+ rule_parameter_set_path = links["validation_params"]
+ if rule_parameter_set_path
+ response = Ievkit.get(rule_parameter_set_path)
+ rule_parameter_set = RuleParameterSet.new(:name => "", :compliance_check => self).tap { |rps| rps.parameters = response.validation }
else
nil
end
diff --git a/app/models/compliance_check_export.rb b/app/models/compliance_check_export.rb
index eede11d58..5f0e26890 100644
--- a/app/models/compliance_check_export.rb
+++ b/app/models/compliance_check_export.rb
@@ -2,7 +2,7 @@ require 'tempfile'
class ComplianceCheckExport
include ERB::Util
- include ValidationResultsHelper
+ include ComplianceChecksHelper
require 'zip'
diff --git a/app/models/compliance_check_result.rb b/app/models/compliance_check_result.rb
index 8eb7b82aa..399f406a9 100644
--- a/app/models/compliance_check_result.rb
+++ b/app/models/compliance_check_result.rb
@@ -3,62 +3,78 @@ class ComplianceCheckResult
extend ActiveModel::Translation
include ActiveModel::Model
- attr_reader :datas
+ attr_accessor :datas
def initialize(response)
- @datas = response[:validation_report].tests.sort_by { |hash| [ hash[:severity], hash[:result], hash[:test_id]] }
+ @datas = response.validation_report
+ end
+
+ def tests?
+ datas.tests?
end
def ok_error
- @datas.select { |test| (test[:result] == "OK" && test[:severity] == "ERROR") }
+ tests? ? tests.select { |test| (test.result == "OK" && test.severity == "ERROR") } : []
end
def nok_error
- @datas.select { |test| (test[:result] == "NOK" && test[:severity] == "ERROR")}
+ tests? ? tests.select { |test| (test.result == "NOK" && test.severity == "ERROR")} : []
end
def na_error
- @datas.select { |test| (test[:result] == "UNCHECK" && test[:severity] == "ERROR")}
+ tests? ? tests.select { |test| (test.result == "UNCHECK" && test.severity == "ERROR")} : []
end
def ok_warning
- @datas.select { |test| (test[:result] == "OK" && test[:severity] == "WARNING")}
+ tests? ? tests.select { |test| (test.result == "OK" && test.severity == "WARNING")} : []
end
def nok_warning
- @datas.select { |test| (test[:result] == "NOK" && test[:severity] == "WARNING")}
+ tests? ? tests.select { |test| (test.result == "NOK" && test.severity == "WARNING")} : []
end
def na_warning
- @datas.select { |test| (test[:result] == "UNCHECK" && test[:severity] == "WARNING")}
+ tests? ? tests.select { |test| (test.result == "UNCHECK" && test.severity == "WARNING")} : []
end
- def mandatory_tests
- @datas.select { |test| test[:severity] == "ERROR"}
+ def all(status, severity)
+ tests? ? tests.select { |test| ( test.result == status && test.severity == severity ) } : []
end
- def optional_tests
- @datas.select { |test| test[:severity] == "WARNING"}
+ def tests
+ [].tap do |tests|
+ datas.tests.each do |test|
+ tests << Test.new(test)
+ end if datas.tests?
+ end
end
- def ok_tests
- @datas.select { |test| test[:result] == "OK"}
- end
+ class Test
+ attr_reader :options
+
+ def initialize( options )
+ @options = options
+ end
- def nok_tests
- @datas.select { |test| test[:result] == "NOK"}
- end
+ def test_id
+ options.test_id if options.test_id?
+ end
+
+ def severity
+ options.severity.downcase if options.severity?
+ end
- def uncheck_tests
- @datas.select { |test| test[:result] == "UNCHECK"}
- end
+ def result
+ options.result.downcase if options.result?
+ end
- def all(status, severity)
- @datas.select { |test| ( test[:result] == status && test[:severity] == severity ) }
- end
+ def errors
+ options.errors if options.errors?
+ end
- def results
- return @datas
+ def error_count
+ options.error_count if options.error_count?
+ end
end
end
diff --git a/app/models/import.rb b/app/models/import.rb
index 733795bd8..2a3ee18db 100644
--- a/app/models/import.rb
+++ b/app/models/import.rb
@@ -3,21 +3,6 @@ require 'open-uri'
class Import
include JobConcern
- # def compliance_check_validation_report?
- # end
-
- # def compliance_check_validation_report
- # Rails.cache.fetch("#{cache_key}/validation_report", expires_in: cache_expiration) do
- # report_path = links["validation_report"]
- # if report_path
- # response = Ievkit.get(report_path)
- # ComplianceCheckResult.new(response)
- # else
- # raise Ievkit::IevError("Impossible to access report path link for validation of import")
- # end
- # end
- # end
-
def report?
links["action_report"].present?
end
@@ -42,7 +27,8 @@ class Import
Rails.cache.fetch("#{cache_key}/validation_params", expires_in: cache_expiration) do
rule_parameter_set_path = links["validation_params"]
if rule_parameter_set_path
- ::JSON.load( open(rule_parameter_set_path).read )
+ response = Ievkit.get(rule_parameter_set_path)
+ rule_parameter_set = RuleParameterSet.new(:name => "", :import => self).tap { |rps| rps.parameters = response.validation }
else
nil
end
@@ -53,11 +39,13 @@ class Import
links["validation_report"].present?
end
- def compliance_check
+ def compliance_check_validation_report
+ puts "compliance_check_validation_report"
Rails.cache.fetch("#{cache_key}/validation_report", expires_in: cache_expiration) do
compliance_check_path = links["validation_report"]
if compliance_check_path
- ::JSON.load( open(compliance_check_path).read )
+ response = Ievkit.get(compliance_check_path)
+ ComplianceCheckResult.new(response)
else
nil
end
diff --git a/app/models/rule_parameter_set.rb b/app/models/rule_parameter_set.rb
index cd5a5d976..dca36a729 100644
--- a/app/models/rule_parameter_set.rb
+++ b/app/models/rule_parameter_set.rb
@@ -4,6 +4,9 @@ class RuleParameterSet < ActiveRecord::Base
#validates_presence_of :referential
validates_presence_of :name
+ # Access to parent object
+ attr_accessor :import, :compliance_check
+
serialize :parameters, JSON
#attr_accessible :name, :organisation_id
diff --git a/app/views/compliance_check_results/_compliance_check_result.erb b/app/views/compliance_check_results/_compliance_check_result.erb
deleted file mode 100644
index afd94f62e..000000000
--- a/app/views/compliance_check_results/_compliance_check_result.erb
+++ /dev/null
@@ -1,21 +0,0 @@
- <div class="severity_<%= compliance_check_result.severity %> status_<%= compliance_check_result.status %>">
- <div class="status_icon">
- <%= image_tag "icons/status_#{compliance_check_result.status}.png", :class => "status" %>
- </div>
- <div class="status_text">
- <div class="code">
- <%= compliance_check_result.rule_code %>
- </div>
- <div class="severity">
- [ <%= ComplianceCheckResult.human_attribute_name(:severity) %> : <%= t compliance_check_result.severity, :scope => "compliance_check_result.severities" %> ]
- </div>
- <div class="explanation">
- <%= ComplianceCheckResult.human_attribute_name(compliance_check_result.rule_code) %>
- </div>
- <div class="attributes">
- <% if compliance_check_result.violation_count > 0 %>
- <%= ComplianceCheckResult.human_attribute_name(:violation_count) %> :
- <% end %>
- </div>
- </div>
-</div>
diff --git a/app/views/compliance_check_results/index.js.coffee b/app/views/compliance_check_results/index.js.coffee
deleted file mode 100644
index 10821a031..000000000
--- a/app/views/compliance_check_results/index.js.coffee
+++ /dev/null
@@ -1,8 +0,0 @@
-jQuery ->
- $(".notice").popover({ container: "body", html: false, trigger: "focus", placement: "bottom" })
-
- # Hide and show error details
- $(".title_error").each ->
- $( this ).click ->
- $(this).next(".details_error").toggle()
- $(this).children("i").toggleClass("fa-plus-square fa-minus-square") \ No newline at end of file
diff --git a/app/views/compliance_checks/_compliance_check.html.erb b/app/views/compliance_checks/_compliance_check.html.erb
index 2e0dbb333..6581d9d48 100644
--- a/app/views/compliance_checks/_compliance_check.html.erb
+++ b/app/views/compliance_checks/_compliance_check.html.erb
@@ -14,9 +14,7 @@
</div>
</div>
<div class="panel-body">
- <% if compliance_check.rule_parameter_set %>
- <p><%= link_to( image_tag('icons/link_page.png') + t("compliance_checks.actions.rule_parameter_set"), rule_parameter_set_referential_compliance_check_path(@referential, compliance_check.id)) %></p>
- <% end %>
+ <p><%= link_to( font_awesome_classic_tag("fa-external-link") + t("compliance_checks.actions.rule_parameter_set"), rule_parameter_set_referential_compliance_check_path(@referential, compliance_check.id)) if compliance_check.rule_parameter_set? %></p>
</div>
<div class="panel-footer">
<div class="history">
diff --git a/app/views/compliance_check_results/index.html.erb b/app/views/compliance_checks/_compliance_check_results.erb
index 5198c4330..d240cac2c 100644
--- a/app/views/compliance_check_results/index.html.erb
+++ b/app/views/compliance_checks/_compliance_check_results.erb
@@ -1,31 +1,26 @@
-<table class="table table-hover">
+<table class="table table-hover" data-title-nok="<%= t 'nok', :scope => 'compliance_check_result.statuses' %>", data-title-uncheck="<%= t 'uncheck', :scope => 'compliance_check_result.statuses' %>", data-title-ok="<%= t 'ok', :scope => 'compliance_check_result.statuses' %>" >
<thead>
<tr>
- <th>#</th>
<th><%= ComplianceCheckResult.human_attribute_name(:status) %></th>
<th><%= ComplianceCheckResult.human_attribute_name(:severity) %></th>
<th><%= ComplianceCheckResult.human_attribute_name(:rule_code) %></th>
- <% if @compliance_check_validation_reports && @compliance_check_validation_reports.first.result == "NOK" %>
- <th><%= ComplianceCheckResult.human_attribute_name(:detail) %></th>
- <% end %>
+ <th><%= ComplianceCheckResult.human_attribute_name(:detail) %></th>
</tr>
</thead>
<tbody>
- <% @compliance_check_validation_reports.each_with_index do |compliance_check_validation_report, index| %>
- <tr>
- <td><%= index + 1 %></td>
- <td><%= status_icon( compliance_check_validation_report.result, compliance_check_validation_report.severity ) %> </td>
- <td><%= t("compliance_check_result.severities." + compliance_check_validation_report.severity.downcase + "_txt") %></td>
+ <% compliance_check_validation_report.tests.each_with_index do |test, index| %>
+ <tr class='<%= "#{test.result}_#{test.severity}" %>'>
+ <td><%= status_icon( test.result, test.severity ) %> </td>
+ <td><%= t("compliance_check_result.severities." + test.severity + "_txt") %></td>
<td>
- <% data_content = t ( "activemodel.attributes.compliance_check_result." + compliance_check_validation_report.test_id ) %>
+ <% data_content = t ( "activemodel.attributes.compliance_check_result." + test.test_id ) %>
<% data_title = t ( "activemodel.attributes.compliance_check_result.title" ) %>
<button data-content='<%= data_content %>' data-title='<%= data_title %>' rel="popover" data-toggle="popover" class="notice btn btn-info btn-xs" ><i class="fa fa-info"></i></button>
- <%= link_to compliance_check_validation_report.test_id, test_definition(compliance_check_validation_report.test_id), :title => ComplianceCheckResult.human_attribute_name(compliance_check_validation_report.test_id), :target => "compliance_check" %></td>
- <% if @compliance_check_validation_reports && @compliance_check_validation_reports.first.result == "NOK" %>
+ <%= link_to test.test_id, test_definition(test.test_id), :title => ComplianceCheckResult.human_attribute_name(test.test_id), :target => "compliance_check" %></td>
<td class="td_error">
- <% if compliance_check_validation_report.errors.present? %>
+ <% if test.errors.present? %>
<span class="title_error">
- <i class="fa fa-plus-square"></i><%= compliance_check_validation_report.error_count.to_s + " " + ComplianceCheckResult.human_attribute_name(:violation_count) %>
+ <i class="fa fa-plus-square"></i><%= test.error_count.to_s + " " + ComplianceCheckResult.human_attribute_name(:violation_count) %>
</span>
@@ -44,11 +39,11 @@
0..1 error_value (string)
0..1 reference_value (striung) -->
<div class="details_error">
- <% compliance_check_validation_report.errors.first(10).each do |error| %>
+ <% test.errors.first(10).each do |error| %>
<p class="detail_error">
<% if error["source"].present? %>
<% if error["source"].objectid.present? %>
- <% data_content_1 = t("activemodel.attributes.compliance_check_result." + compliance_check_validation_report.test_id) + ". " +
+ <% data_content_1 = t("activemodel.attributes.compliance_check_result." + test.test_id) + ". " +
t("compliance_check_result.details.detail_" + error[:error_id], object_labels_hash(error) ) %>
<% data_title_1 = t("activemodel.attributes.compliance_check_result.detail") %>
|- <button data-content='<%= data_content_1 %>' data-title='<%= data_title_1 %>' data-toggle="popover" class="notice btn btn-info btn-xs"><i class="fa fa-info"></i></button>
@@ -67,9 +62,9 @@
<% end %>
<% if error[:source].file.present? %>
<% if error[:source].objectid.present? %>
- <%= "#{error[:source].objectid}" %>
- <p>
+ <%= "#{error[:source].objectid}" %>
<% end %>
+ <p class="file_error">
<%= error[:source].file.filename %>
<% if error[:source].file.line_number.present? %>
<%= ", li: #{error[:source].file.line_number}" %>
@@ -77,21 +72,14 @@
<% if error[:source].file.column_number.present? %>
<%= ", co: #{error[:source].file.column_number}" %>
<% end %>
- <% end %>
-
- <% end %>
- </p>
+ </p>
+ <% end %>
+ <% end %>
<% end %>
</div>
<% end %>
</td>
- <% end %>
</tr>
<% end %>
</tbody>
</table>
-<% if @import %>
- <%= javascript_include_tag referential_import_compliance_check_results_path(@referential, @import.id, :format => :js) %>
-<% else %>
- <%= javascript_include_tag referential_compliance_check_compliance_check_results_path(@referential, @compliance_check.id, :format => :js) %>
-<% end %>
diff --git a/app/views/compliance_checks/detailed_errors_index.csv.erb b/app/views/compliance_checks/detailed_errors_index.csv.erb
index 24d4c8877..17fb6f2c3 100644
--- a/app/views/compliance_checks/detailed_errors_index.csv.erb
+++ b/app/views/compliance_checks/detailed_errors_index.csv.erb
@@ -1,2 +1,2 @@
<%= I18n.t("activemodel.attributes.compliance_check_result.severity") %>;<%= I18n.t("activemodel.attributes.compliance_check_result.rule_code") %>;<%= I18n.t("activemodel.attributes.compliance_check_result.object") %>;<%= I18n.t("activemodel.attributes.compliance_check_result.resource") %>;<%= I18n.t("activemodel.attributes.compliance_check_result.title") %>;<%= I18n.t("activemodel.attributes.compliance_check_result.detail") %>
-<% @compliance_check.compliance_check_validation_report.results.each do |r| %><% if r.errors.present? %><% r.errors.first(10).each do |error| %><% case r.severity %><% when "WARNING" %><%= I18n.t "compliance_check_result.severities.warning_txt" %><% when "ERROR" %><%= I18n.t "compliance_check_result.severities.error_txt" %><% end %>;<%= r.test_id %>;<% if error["source"].present? %><%= error["source"]["objectid"] if error["source"]["objectid"].present? %>;<% if error["source"]["object_path"].present? %><%= object_url(@referential_id, error) %><% elsif error["source"]["file"].present? %><%= File.basename(error["source"]["file"]["filename"]) +" - " %><%= I18n.t "compliance_check_results.index.column" %>:<%= error["source"]["file"]["column_number"] %>,<%= I18n.t "compliance_check_results.index.line" %>:<%= error["source"]["file"]["line_number"] %><% end %>;<% else %>;;<% end %><%= I18n.t("activemodel.attributes.compliance_check_result."+r.test_id) %>;<%= I18n.t("compliance_check_result.details.detail_" + error["error_id"], object_labels_hash(error) )%><%= "\n" %><% end %><% end %><% end %> \ No newline at end of file
+<% @compliance_check.compliance_check_validation_report.tests.each do |r| %><% if r.errors.present? %><% r.errors.first(10).each do |error| %><% case r.severity %><% when "warning" %><%= I18n.t "compliance_check_result.severities.warning_txt" %><% when "error" %><%= I18n.t "compliance_check_result.severities.error_txt" %><% end %>;<%= r.test_id %>;<% if error["source"].present? %><%= error["source"]["objectid"] if error["source"]["objectid"].present? %>;<% if error["source"]["object_path"].present? %><%= object_url(@referential_id, error) %><% elsif error["source"]["file"].present? %><%= File.basename(error["source"]["file"]["filename"]) +" - " %><%= I18n.t "compliance_check_results.index.column" %>:<%= error["source"]["file"]["column_number"] %>,<%= I18n.t "compliance_check_results.index.line" %>:<%= error["source"]["file"]["line_number"] %><% end %>;<% else %>;;<% end %><%= I18n.t("activemodel.attributes.compliance_check_result."+r.test_id) %>;<%= I18n.t("compliance_check_result.details.detail_" + error["error_id"], object_labels_hash(error) )%><%= "\n" %><% end %><% end %><% end %>
diff --git a/app/views/compliance_checks/show.html.erb b/app/views/compliance_checks/show.html.erb
index a1793d585..ad2c3cd90 100644
--- a/app/views/compliance_checks/show.html.erb
+++ b/app/views/compliance_checks/show.html.erb
@@ -1,28 +1,28 @@
-<% if @import %>
- <%= title_tag "#{t('imports.show.compliance_check_of')} #{title} #{@import.name} <span class='status status_#{@import.status}'>(#{ t('imports.statuses.'+ @import.status) })</span>" %>
- <% @title = "#{@import.name}" %>
-<% else %>
- <%= title_tag job_status_title(@compliance_check) %>
-<% end %>
+<%= title_tag job_status_title(@compliance_check) %>
-<% if !@compliance_check.aborted? %>
<div class="compliance_check_show">
<div class="links">
- <% if !@import && @compliance_check.rule_parameter_set %>
- <%= link_to image_tag('icons/link_page.png') + t("compliance_checks.rule_parameter_set"), rule_parameter_set_referential_compliance_check_path(@referential, @compliance_check.id) %>
- <% end %>
+ <% if @compliance_check.class == Import %>
+ <%= link_to font_awesome_classic_tag("fa-external-link") + t("compliance_checks.rule_parameter_set"), rule_parameter_set_referential_import_path(@referential, @compliance_check.id) if @compliance_check.rule_parameter_set? %>
+ <% else %>
+ <%= link_to font_awesome_classic_tag("fa-external-link") + t("compliance_checks.rule_parameter_set"), rule_parameter_set_referential_compliance_check_path(@referential, @compliance_check.id) if @compliance_check.rule_parameter_set? %>
+ <% end %>
<div class="btn-group pull-right">
- <% if !@import %>
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<%= t(".export") %> <span class="caret"></span>
</button>
- <ul class="dropdown-menu" role="menu">
- <li><%= link_to t(".export_csv"), export_referential_compliance_check_path(@referential, @compliance_check.id) %></li>
- <% end %>
+ <ul class="dropdown-menu" role="menu">
+ <li>
+ <% if @compliance_check.class == Import %>
+ <%= link_to t(".export_csv"), export_referential_import_path(@referential, @compliance_check.id) %>
+ <% else %>
+ <%= link_to t(".export_csv"), export_referential_compliance_check_path(@referential, @compliance_check.id) %>
+ <% end %>
+ </li>
</ul>
</div>
</div>
- <% if (@import && @import.status == 'terminated') || @compliance_check.status == 'terminated'%>
+
<div class="resume">
<div class="col1">
<div class="caption"><%= t "error", :scope => "compliance_check_result.severities" %></div>
@@ -33,32 +33,21 @@
<div class="graph" id="warning"></div>
</div>
</div>
- <div class="order" style="display: none;">
- Filtre : <!-- %= select_tag "order", ("<option value='severity'>" + ComplianceCheckResult.human_attribute_name(:severity) +"</option><option value='status'>" + ComplianceCheckResult.human_attribute_name(:status) + "</option>").html_safe, :include_blank => false % -->
- </div>
- <div class="report"></div>
- <% end %>
- <% if @import %>
- <%= javascript_include_tag referential_compliance_check_path(@referential, @import.id,:format => :js) %>
- <% else %>
- <%= javascript_include_tag referential_compliance_check_path(@referential, @compliance_check.id,:format => :js) %>
- <% end %>
+ <div class="report">
+ <%= render :partial => "compliance_checks/compliance_check_results", :locals => { :compliance_check_validation_report => @compliance_check.compliance_check_validation_report } %>
+ </div>
</div>
-<% end %>
+
<% content_for :sidebar do %>
<ul class="actions">
<li>
- <% if @import %>
- <%= link_to image_tag("icons/link_page.png") + t("imports.show.import_of_validation"), referential_import_path(@referential, @import.id) %>
- <% else %>
+ <% if @compliance_check.class != Import %>
<%= link_to t('compliance_checks.actions.destroy'), referential_compliance_check_path(@referential, @compliance_check.id), :method => :delete, :data => {:confirm => t('compliance_checks.actions.destroy_confirm')}, :class => "remove" %>
<% end %>
</li>
</ul>
-<% if !@import %>
- <%= history_tag(@compliance_check) %>
-<% end %>
+<%= history_tag(@compliance_check) %>
<% end %>
diff --git a/app/views/compliance_checks/show.js.coffee b/app/views/compliance_checks/show.js.coffee
deleted file mode 100644
index 830f8f69b..000000000
--- a/app/views/compliance_checks/show.js.coffee
+++ /dev/null
@@ -1,52 +0,0 @@
-jQuery ->
-
- get_compliance_check_results = (html_container, status, severity) ->
- h = new Object()
- h["status"] = status if status
- h["severity"] = severity if severity
-
- $.get(
- "<%= @compliance_check.id %>/compliance_check_results",
- h,
- update = (data) ->
- html_container.empty()
- html_container.append(data)
- )
-
- Morris.Donut({
- element: 'error',
- data: [
- {label: "<%= t 'nok', :scope => 'compliance_check_result.statuses' %>", value: <%= @compliance_check.compliance_check_validation_report.nok_error.count %>},
- {label: "<%= t 'na', :scope => 'compliance_check_result.statuses' %>", value: <%= @compliance_check.compliance_check_validation_report.na_error.count %>},
- {label: "<%= t 'ok', :scope => 'compliance_check_result.statuses' %>", value: <%= @compliance_check.compliance_check_validation_report.ok_error.count %>}
- ]
- colors: [ "#e22b1b", "#898e7f", "#8fc861" ]
- }).on('click', update = (i, row) ->
- switch i
- when 0 then get_compliance_check_results( $(".report"), "NOK", "ERROR")
- when 1 then get_compliance_check_results( $(".report"), "UNCHECK", "ERROR")
- when 2 then get_compliance_check_results( $(".report"), "OK", "ERROR")
- else console.log "Error no other value for donut chart")
-
- Morris.Donut({
- element: 'warning',
- data: [
- {label: "<%= t 'nok', :scope => 'compliance_check_result.statuses' %>", value: <%= @compliance_check.compliance_check_validation_report.nok_warning.count %>},
- {label: "<%= t 'na', :scope => 'compliance_check_result.statuses' %>", value: <%= @compliance_check.compliance_check_validation_report.na_warning.count %>},
- {label: "<%= t 'ok', :scope => 'compliance_check_result.statuses' %>", value: <%= @compliance_check.compliance_check_validation_report.ok_warning.count %>}
- ]
- colors: [ "#ffbd2b", "#898e7f", "#8fc861" ]
- }).on('click', update = (i, row) ->
- switch i
- when 0 then get_compliance_check_results( $(".report"), "NOK", "WARNING")
- when 1 then get_compliance_check_results( $(".report"), "UNCHECK", "WARNING")
- when 2 then get_compliance_check_results( $(".report"), "OK", "WARNING")
- else console.log "Error no other value for donut chart")
-
- $(".resume .col1 .caption").click ->
- get_compliance_check_results( $(".report"), null, "ERROR")
-
- $(".resume .col2 .caption").click ->
- get_compliance_check_results( $(".report"), null, "WARNING")
-
-
diff --git a/app/views/compliance_checks/show_for_import.js.coffee b/app/views/compliance_checks/show_for_import.js.coffee
deleted file mode 100644
index 0a268740e..000000000
--- a/app/views/compliance_checks/show_for_import.js.coffee
+++ /dev/null
@@ -1,52 +0,0 @@
-jQuery ->
-
- get_compliance_check_results = (html_container, status, severity) ->
- h = new Object()
- h["status"] = status if status
- h["severity"] = severity if severity
-
- $.get(
- "compliance_check_results",
- h,
- update = (data) ->
- html_container.empty()
- html_container.append(data)
- )
-
- Morris.Donut({
- element: 'error',
- data: [
- {label: "<%= t 'nok', :scope => 'compliance_check_result.statuses' %>", value: <%= @import.compliance_check_validation_report.nok_error.count %>},
- {label: "<%= t 'na', :scope => 'compliance_check_result.statuses' %>", value: <%= @import.compliance_check_validation_report.na_error.count %>},
- {label: "<%= t 'ok', :scope => 'compliance_check_result.statuses' %>", value: <%= @import.compliance_check_validation_report.ok_error.count %>}
- ]
- colors: [ "#e22b1b", "#898e7f", "#8fc861" ]
- }).on('click', update = (i, row) ->
- switch i
- when 0 then get_compliance_check_results( $(".report"), "NOK", "ERROR")
- when 1 then get_compliance_check_results( $(".report"), "UNCHECK", "ERROR")
- when 2 then get_compliance_check_results( $(".report"), "OK", "ERROR")
- else console.log "Error no other value for donut chart")
-
- Morris.Donut({
- element: 'warning',
- data: [
- {label: "<%= t 'nok', :scope => 'compliance_check_result.statuses' %>", value: <%= @import.compliance_check_validation_report.nok_warning.count %>},
- {label: "<%= t 'na', :scope => 'compliance_check_result.statuses' %>", value: <%= @import.compliance_check_validation_report.na_warning.count %>},
- {label: "<%= t 'ok', :scope => 'compliance_check_result.statuses' %>", value: <%= @import.compliance_check_validation_report.ok_warning.count %>}
- ]
- colors: [ "#ffbd2b", "#898e7f", "#8fc861" ]
- }).on('click', update = (i, row) ->
- switch i
- when 0 then get_compliance_check_results( $(".report"), "NOK", "WARNING")
- when 1 then get_compliance_check_results( $(".report"), "UNCHECK", "WARNING")
- when 2 then get_compliance_check_results( $(".report"), "OK", "WARNING")
- else console.log "Error no other value for donut chart")
-
- $(".resume .col1 .caption").click ->
- get_compliance_check_results( $(".report"), null, "ERROR")
-
- $(".resume .col2 .caption").click ->
- get_compliance_check_results( $(".report"), null, "WARNING")
-
-
diff --git a/app/views/compliance_checks/summary_errors_index.csv.erb b/app/views/compliance_checks/summary_errors_index.csv.erb
index 8d7a31948..ff915f700 100644
--- a/app/views/compliance_checks/summary_errors_index.csv.erb
+++ b/app/views/compliance_checks/summary_errors_index.csv.erb
@@ -1,3 +1,3 @@
<%= I18n.t("activemodel.attributes.compliance_check_result.severity") %>;<%= I18n.t("activemodel.attributes.compliance_check_result.status") %>;<%= I18n.t("activemodel.attributes.compliance_check_result.rule_code") %>;<%= I18n.t("activemodel.attributes.compliance_check_result.title") %>;<%= I18n.t("activemodel.attributes.compliance_check_result.url") %>;<%= I18n.t("activemodel.attributes.compliance_check_result.violation_count_txt") %>;<%= I18n.t("activemodel.attributes.compliance_check_result.objects") %>
-<% @compliance_check.compliance_check_validation_report.results.each do |r| %><% case r.severity %><% when "WARNING" %><%= I18n.t "compliance_check_result.severities.warning_txt" %><% when "ERROR" %><%= I18n.t "compliance_check_result.severities.error_txt" %><% end %>;<%= r.result %>;<%= r.test_id %>;<%= I18n.t("activemodel.attributes.compliance_check_result."+r.test_id) %>;<%= Rails.application.config.validation_spec + I18n.locale.to_s + "/" + r.test_id + ".html" %>;<%= r.error_count %><% if r.error_count > 0 %><% if r.errors.present? %>;<% r.errors.first(10).each do |error| %><% if error["source"] %><%= error["source"]["objectid"] + " " %><% else %><%= " " %><% end %><% end %><% end %><% end %>
-<% end %> \ No newline at end of file
+<% @compliance_check.compliance_check_validation_report.tests.each do |r| %><% case r.severity %><% when "warning" %><%= I18n.t "compliance_check_result.severities.warning_txt" %><% when "error" %><%= I18n.t "compliance_check_result.severities.error_txt" %><% end %>;<%= r.result %>;<%= r.test_id %>;<%= I18n.t("activemodel.attributes.compliance_check_result."+r.test_id) %>;<%= Rails.application.config.validation_spec + I18n.locale.to_s + "/" + r.test_id + ".html" %>;<%= r.error_count %><% if r.error_count > 0 %><% if r.errors.present? %>;<% r.errors.first(10).each do |error| %><% if error["source"] %><%= error["source"]["objectid"] + " " %><% else %><%= " " %><% end %><% end %><% end %><% end %>
+<% end %>
diff --git a/app/views/imports/_import.erb b/app/views/imports/_import.erb
index b74c59e17..e08511762 100644
--- a/app/views/imports/_import.erb
+++ b/app/views/imports/_import.erb
@@ -15,7 +15,6 @@
</div>
<div class="panel-body">
<p><%= link_to font_awesome_classic_tag("fa-file-#{import.filename_extension}-o") + t("imports.show.imported_file"), imported_file_referential_import_path(@referential, import.id) if import.file_path? %></p>
- <p><%= link_to font_awesome_classic_tag("fa-external-link") + t("imports.show.rule_parameter_set"), rule_parameter_set_referential_import_path(@referential, import.id) if import.rule_parameter_set? %></p>
<p><%= link_to font_awesome_classic_tag("fa-external-link") + t("imports.show.compliance_check"), compliance_check_referential_import_path(@referential, import.id) if import.compliance_check? %></p>
</div>
<div class="panel-footer">
diff --git a/app/views/imports/rule_parameter_set.html.erb b/app/views/imports/rule_parameter_set.html.erb
deleted file mode 100644
index 7c3677140..000000000
--- a/app/views/imports/rule_parameter_set.html.erb
+++ /dev/null
@@ -1,161 +0,0 @@
-<%= title_tag t('rule_parameter_sets.show.title', :rule_parameter_set => @rule_parameter_set.name ) %>
-
-<div class="rule_parameter_set_show">
-
- <div class="summary">
- <p>
- <label><%= RuleParameterSet.human_attribute_name("stop_areas_area") %>: </label>
- <%= @rule_parameter_set.stop_areas_area %>
- </p>
- <div class="attributes_group" >
- <span class="title"><%= t(".min_distance") %></span>
- <div class="columns">
- <div class="two_columns">
- <label><%= t(".inter_stop_area_distance_min") %> : </label>
- <span class="value"><%= @rule_parameter_set.inter_stop_area_distance_min %></span>
- </div>
- <div class="two_columns">
- <label><%= t(".inter_access_point_distance_min") %> : </label>
- <span class="value"><%= @rule_parameter_set.inter_access_point_distance_min %></span>
- </div>
- </div>
- </div>
- <div class="attributes_group" >
- <span class="title"><%= t(".max_distance") %></span>
- <div class="columns">
- <div class="two_columns">
- <label><%= t(".parent_stop_area_distance_max") %>: </label>
- <span class="value"><%= @rule_parameter_set.parent_stop_area_distance_max %></span>
- </div>
- <div class="two_columns">
- <label><%= t(".inter_connection_link_distance_max") %>: </label>
- <span class="value"><%= @rule_parameter_set.inter_connection_link_distance_max %></span>
- </div>
- </div>
- <div class="columns">
- <div class="two_columns">
- <label><%= t(".inter_access_link_distance_max") %>: </label>
- <span class="value"><%= @rule_parameter_set.inter_access_link_distance_max %></span>
- </div>
- <div class="two_columns">
- <label><%= t(".facility_stop_area_distance_max") %>: </label>
- <span class="value"><%= @rule_parameter_set.facility_stop_area_distance_max %></span>
- </div>
- </div>
- </div>
- <div class="attributes_group" >
- <span class="title"><%= t(".walk_speed") %></span>
- <div class="columns">
- <div class="four_columns">
- <label><%= t(".walk_default_speed_max") %>: </label>
- <span class="value"><%= @rule_parameter_set.walk_default_speed_max %></span>
- </div>
- <div class="four_columns">
- <label><%= t(".walk_occasional_traveller_speed_max") %>: </label>
- <span class="value"><%= @rule_parameter_set.walk_occasional_traveller_speed_max %></span>
- </div>
- <div class="four_columns">
- <label><%= t(".walk_frequent_traveller_speed_max") %>: </label>
- <span class="value"><%= @rule_parameter_set.walk_frequent_traveller_speed_max %></span>
- </div>
- <div class="four_columns">
- <label><%= t(".walk_mobility_restricted_traveller_speed_max") %>: </label>
- <span class="value"><%= @rule_parameter_set.walk_mobility_restricted_traveller_speed_max %></span>
- </div>
- </div>
- </div>
- <p>
- <label><%= t(".inter_stop_duration_max") %>: </label>
- <%= @rule_parameter_set.inter_stop_duration_max %>
- </p>
-
- <p>
- <label><%= RuleParameterSet.human_attribute_name("check_lines_in_groups") %>: </label>
- <%= boolean_value(@rule_parameter_set.check_lines_in_groups)%>
- </p>
-
- <p>
- <label><%= RuleParameterSet.human_attribute_name("check_line_routes") %>: </label>
- <%= boolean_value(@rule_parameter_set.check_line_routes) %>
- </p>
-
- <p>
- <label><%= RuleParameterSet.human_attribute_name("check_stop_parent") %>: </label>
- <%= boolean_value(@rule_parameter_set.check_stop_parent) %>
- </p>
-
- <p>
- <label><%= RuleParameterSet.human_attribute_name("check_connection_link_on_physical") %>: </label>
- <%= boolean_value(@rule_parameter_set.check_connection_link_on_physical) %>
- </p>
-
- </p>
- <label><%= RuleParameterSet.human_attribute_name("check_allowed_transport_modes") %>: </label>
- <%= boolean_value(@rule_parameter_set.check_allowed_transport_modes) %>
- </p>
-
-
- <div class="rule_parameter_by_mode">
- <label><%= t(".rule_parameter_by_mode") %>
- <%= t(".modes_allowed") if @rule_parameter_set.check_allowed_transport_modes %>
- </label>
- <table class="table table-striped table-condensed">
- <tr>
- <th><%= t("transport_modes.name") %></th>
- <% RuleParameterSet.mode_attribute_prefixes.each do |prefix| %>
- <% unless prefix == "allowed_transport" %>
- <th><%= RuleParameterSet.human_attribute_name(prefix) %></th>
- <% end %>
- <% end %>
- </tr>
- <% Chouette::Line.transport_modes.map(&:to_s).each do |mode| %>
- <% if @rule_parameter_set.allowed(mode) %>
- <tr>
- <td><%= t("transport_modes.label.#{mode}") %></td>
- <% RuleParameterSet.mode_attribute_prefixes.each do |prefix| %>
-
- <% unless prefix == "allowed_transport" %>
- <td><%= @rule_parameter_set.send "#{prefix}_mode_#{mode}" %></td>
- <% end %>
- <% end %>
- </tr>
- <% end %>
- <% end %>
- </table>
- </div>
- <div class="rule_parameter_by_object">
- <label><%= t("rule_parameter_sets.labels.columns_restrictions") %> </label>
- <table class="table table-bordered table-condensed">
- <% RuleParameterSet.validable_objects.each do |obj| %>
- <% if @rule_parameter_set.selected(obj.table_name.singularize) %>
- <thead>
- <tr>
- <th> <%= t("activerecord.models.#{obj.table_name.singularize}.one") %></th>
- <th><%= RuleParameterSet.human_attribute_name("attribute") %></th>
- <th><%= RuleParameterSet.human_attribute_name("unique") %></th>
- <th><%= RuleParameterSet.human_attribute_name("string_type") %></th>
- <th><%= RuleParameterSet.human_attribute_name("min_size") %></th>
- <th><%= RuleParameterSet.human_attribute_name("max_size") %></th>
- </tr>
- </thead>
- <tbody>
- <% RuleParameterSet.validable_columns[obj.table_name.singularize].each do |col| %>
- <% if @rule_parameter_set.selected_column(obj.table_name.singularize,col)%>
- <tr>
- <td></td>
- <td><%= t("activerecord.attributes.#{obj.table_name.singularize}.#{col}") %></td>
- <% suffix = "column_#{col}_object_#{obj.table_name.singularize}"%>
- <td><%= unique(@rule_parameter_set.send "unique_#{suffix}".to_sym) %></td>
- <td><%= pattern(@rule_parameter_set.send "pattern_#{suffix}".to_sym) %></td>
- <td><%= @rule_parameter_set.send "min_size_#{suffix}".to_sym %></td>
- <td><%= @rule_parameter_set.send "max_size_#{suffix}".to_sym %></td>
- </tr>
- <% end %>
- <% end %>
- </tbody>
- <% end %>
- <% end %>
- </table>
- </div>
- </div>
-</div>
diff --git a/app/views/imports/show.html.erb b/app/views/imports/show.html.erb
index 025580c34..1923d8c53 100644
--- a/app/views/imports/show.html.erb
+++ b/app/views/imports/show.html.erb
@@ -5,7 +5,6 @@
<div class="import_show">
<div class="links">
<%= link_to font_awesome_classic_tag("fa-file-#{@import.filename_extension}-o") + t("imports.show.imported_file"), imported_file_referential_import_path(@referential, @import.id) if @import.file_path? %>
- <%= link_to font_awesome_classic_tag("fa-external-link") + t("imports.show.rule_parameter_set"), rule_parameter_set_referential_import_path(@referential, @import.id) if @import.rule_parameter_set? %>
<%= link_to font_awesome_classic_tag("fa-external-link") + t("imports.show.compliance_check"), compliance_check_referential_import_path(@referential, @import.id) if @import.compliance_check? %>
</div>
<%= render( :partial => "shared/ie_report.html", :locals => { :referential => @referential, :job => @import} ) %>
diff --git a/config/locales/compliance_check_results.yml b/config/locales/compliance_check_results.yml
index c439b64d9..d5c839638 100644
--- a/config/locales/compliance_check_results.yml
+++ b/config/locales/compliance_check_results.yml
@@ -15,7 +15,7 @@ en:
warning_txt: "Optional"
statuses:
nok: "Error"
- na: "Unavailable"
+ uncheck: "Unavailable"
ok: "Success"
details:
#### level 1
@@ -359,7 +359,7 @@ fr:
warning_txt: "Optionnel"
statuses:
nok: "Erreur"
- na: "Absent"
+ uncheck: "Absent"
ok: "Succès"
details:
#### level 1
diff --git a/config/routes.rb b/config/routes.rb
index 9116fba64..88fe912c2 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -84,9 +84,8 @@ ChouetteIhm::Application.routes.draw do
get "imported_file"
get "rule_parameter_set"
get "compliance_check"
- end
-
- resources :compliance_check_results
+ get 'export', defaults: { format: 'zip' }
+ end
end
resources :export_tasks, :only => [:new, :create] do
@@ -110,15 +109,11 @@ ChouetteIhm::Application.routes.draw do
resources :compliance_checks, :only => [:index, :show, :destroy] do
member do
get 'export', defaults: { format: 'zip' }
- end
- member do
get 'rule_parameter_set'
end
collection do
get 'references'
end
-
- resources :compliance_check_results
end
resources :companies