diff options
Diffstat (limited to 'app')
34 files changed, 128 insertions, 52 deletions
diff --git a/app/controllers/compliance_check_results_controller.rb b/app/controllers/compliance_check_results_controller.rb index a4ef40509..45136938a 100644 --- a/app/controllers/compliance_check_results_controller.rb +++ b/app/controllers/compliance_check_results_controller.rb @@ -1,22 +1,25 @@ class ComplianceCheckResultsController < ChouetteController + respond_to :json respond_to :js, :only => :index + #respond_to :csv, :only => :index belongs_to :compliance_check_task - def index + def index index! do |format| format.html { render :layout => false } + #format.csv { send_file collection[0].compliance_check_task.file, :type => "text/html; charset=utf-8" } end end - + def collection wheres = [:status, :severity].map{|key| params.has_key?(key) ? {key => params[key]} : {} }\ .inject({}){|hash, injected| hash.merge!(injected)} @compliance_check_results ||= end_of_association_chain.where(wheres).order(:rule_code) 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_check_tasks_controller.rb b/app/controllers/compliance_check_tasks_controller.rb index d28ca34ae..9964407ce 100644 --- a/app/controllers/compliance_check_tasks_controller.rb +++ b/app/controllers/compliance_check_tasks_controller.rb @@ -2,6 +2,7 @@ class ComplianceCheckTasksController < ChouetteController defaults :resource_class => ComplianceCheckTask respond_to :html, :js + respond_to :zip, :only => :export belongs_to :referential @@ -25,6 +26,12 @@ class ComplianceCheckTasksController < ChouetteController success.html { flash[:notice] = I18n.t('compliance_check_tasks.new.flash'); redirect_to referential_compliance_check_tasks_path(@referential) } end end + + def export + respond_to do |format| + format.zip { send_file ComplianceCheckTaskExport.new(compliance_check_task).export, :type => :zip } + end + end protected diff --git a/app/exporters/chouette/hub/city_code_exporter.rb b/app/exporters/chouette/hub/city_code_exporter.rb index 1279313eb..ee1180064 100644 --- a/app/exporters/chouette/hub/city_code_exporter.rb +++ b/app/exporters/chouette/hub/city_code_exporter.rb @@ -27,7 +27,7 @@ class Chouette::Hub::CityCodeExporter end def save - File.open(directory + hub_name , "a:ISO_8859_1") do |f| + File.open(directory + hub_name , "a:Windows_1252") do |f| f.write("COMMUNES\u000D\u000A") if f.size == 0 f.write(render) end diff --git a/app/exporters/chouette/hub/commercial_stop_area_exporter.rb b/app/exporters/chouette/hub/commercial_stop_area_exporter.rb index be4b667e5..87a41b8ee 100644 --- a/app/exporters/chouette/hub/commercial_stop_area_exporter.rb +++ b/app/exporters/chouette/hub/commercial_stop_area_exporter.rb @@ -7,7 +7,9 @@ class Chouette::Hub::CommercialStopAreaExporter @directory = directory @template = File.open('app/views/api/hub/arrets_generiques.hub.erb' ){ |f| f.read } @type = "ONNNNNNNNNNNNNNNNN" - + if @stop_area.mobility_restricted_suitability + @type = "ONNNNNNNNNNNNONNNN" + end @stop_area.referential.projection_type = "27562" wgs84 = '+proj=lonlat +datum=WGS84 +ellps=WGS84' @@ -35,7 +37,7 @@ class Chouette::Hub::CommercialStopAreaExporter end def save - File.open(directory + hub_name , "a:ISO_8859_1") do |f| + File.open(directory + hub_name , "a:Windows_1252") do |f| f.write("ARRET\u000D\u000A") if f.size == 0 f.write(render) end if stop_area.present? diff --git a/app/exporters/chouette/hub/company_exporter.rb b/app/exporters/chouette/hub/company_exporter.rb index 142853b22..e5ba0549c 100644 --- a/app/exporters/chouette/hub/company_exporter.rb +++ b/app/exporters/chouette/hub/company_exporter.rb @@ -26,7 +26,7 @@ class Chouette::Hub::CompanyExporter end def save - File.open(directory + hub_name , "a:ISO_8859_1") do |f| + File.open(directory + hub_name , "a:Windows_1252") do |f| f.write("TRANSPORTEUR\u000D\u000A") if f.size == 0 f.write(render) end if company.present? diff --git a/app/exporters/chouette/hub/connection_link_exporter.rb b/app/exporters/chouette/hub/connection_link_exporter.rb index 0db286434..6f89fb6c1 100644 --- a/app/exporters/chouette/hub/connection_link_exporter.rb +++ b/app/exporters/chouette/hub/connection_link_exporter.rb @@ -31,7 +31,7 @@ class Chouette::Hub::ConnectionLinkExporter end def save - File.open(directory + hub_name , "a:ISO_8859_1") do |f| + File.open(directory + hub_name , "a:Windows_1252") do |f| f.write("CORRESPONDANCE\u000D\u000A") if f.size == 0 f.write(render) if (connection_link.present? && connection_link.link_distance.present?) end diff --git a/app/exporters/chouette/hub/direction_exporter.rb b/app/exporters/chouette/hub/direction_exporter.rb index 03c4c8c85..e81efbe32 100644 --- a/app/exporters/chouette/hub/direction_exporter.rb +++ b/app/exporters/chouette/hub/direction_exporter.rb @@ -30,7 +30,7 @@ class Chouette::Hub::DirectionExporter end def save - File.open(directory + hub_name , "a:ISO_8859_1") do |f| + File.open(directory + hub_name , "a:Windows_1252") do |f| f.write("DIRECTION\u000D\u000A") if f.size == 0 f.write(render) end if journey_pattern.present? diff --git a/app/exporters/chouette/hub/group_of_lines_exporter.rb b/app/exporters/chouette/hub/group_of_lines_exporter.rb index 2b07d7c4d..7b69eb6e3 100644 --- a/app/exporters/chouette/hub/group_of_lines_exporter.rb +++ b/app/exporters/chouette/hub/group_of_lines_exporter.rb @@ -26,7 +26,7 @@ class Chouette::Hub::GroupOfLinesExporter end def save - File.open(directory + hub_name , "a:ISO_8859_1") do |f| + File.open(directory + hub_name , "a:Windows_1252") do |f| f.write("GROUPELIGNE\u000D\u000A") if f.size == 0 f.write(render) end if group_of_lines.present? diff --git a/app/exporters/chouette/hub/journey_pattern_exporter.rb b/app/exporters/chouette/hub/journey_pattern_exporter.rb index 97cbab41d..0ec8d76c5 100644 --- a/app/exporters/chouette/hub/journey_pattern_exporter.rb +++ b/app/exporters/chouette/hub/journey_pattern_exporter.rb @@ -40,7 +40,7 @@ class Chouette::Hub::JourneyPatternExporter end def save - File.open(directory + hub_name , "a:ISO_8859_1") do |f| + File.open(directory + hub_name , "a:Windows_1252") do |f| f.write("CHEMIN\u000D\u000A") if f.size == 0 f.write(render) end if journey_pattern.present? diff --git a/app/exporters/chouette/hub/line_exporter.rb b/app/exporters/chouette/hub/line_exporter.rb index 622f7a924..464cad077 100644 --- a/app/exporters/chouette/hub/line_exporter.rb +++ b/app/exporters/chouette/hub/line_exporter.rb @@ -31,7 +31,7 @@ class Chouette::Hub::LineExporter end def save - File.open(directory + hub_name , "a:ISO_8859_1") do |f| + File.open(directory + hub_name , "a:Windows_1252") do |f| f.write("LIGNE\u000D\u000A") if f.size == 0 f.write(render) end if line.present? diff --git a/app/exporters/chouette/hub/network_exporter.rb b/app/exporters/chouette/hub/network_exporter.rb index fc77a84fc..a333beda2 100644 --- a/app/exporters/chouette/hub/network_exporter.rb +++ b/app/exporters/chouette/hub/network_exporter.rb @@ -26,7 +26,7 @@ class Chouette::Hub::NetworkExporter end def save - File.open(directory + hub_name , "a:ISO_8859_1") do |f| + File.open(directory + hub_name , "a:Windows_1252") do |f| f.write("RESEAU\u000D\u000A") if f.size == 0 f.write(render) end if network.present? diff --git a/app/exporters/chouette/hub/physical_stop_area_exporter.rb b/app/exporters/chouette/hub/physical_stop_area_exporter.rb index a8d992735..a0bf054a6 100644 --- a/app/exporters/chouette/hub/physical_stop_area_exporter.rb +++ b/app/exporters/chouette/hub/physical_stop_area_exporter.rb @@ -7,6 +7,9 @@ class Chouette::Hub::PhysicalStopAreaExporter @directory = directory @template = File.open('app/views/api/hub/arrets_physiques.hub.erb' ){ |f| f.read } @type = "NNNNNNNNNNNNNNNNNN" + if @stop_area.mobility_restricted_suitability + @type = "NNNNNNNNNNNNNONNNN" + end if @stop_area.parent_id @parent = Chouette::StopArea.find(@stop_area.parent_id) end @@ -38,7 +41,7 @@ class Chouette::Hub::PhysicalStopAreaExporter end def save - File.open(directory + hub_name , "a:ISO_8859_1") do |f| + File.open(directory + hub_name , "a:Windows_1252") do |f| f.write("ARRET\u000D\u000A") if f.size == 0 f.write(render) end if stop_area.present? diff --git a/app/exporters/chouette/hub/route_exporter.rb b/app/exporters/chouette/hub/route_exporter.rb index e94780329..670f977aa 100644 --- a/app/exporters/chouette/hub/route_exporter.rb +++ b/app/exporters/chouette/hub/route_exporter.rb @@ -35,7 +35,7 @@ class Chouette::Hub::RouteExporter end def save - File.open(directory + hub_name , "a:ISO_8859_1") do |f| + File.open(directory + hub_name , "a:Windows_1252") do |f| f.write("SCHEMA\u000D\u000A") if f.size == 0 f.write(render) end if route.present? diff --git a/app/exporters/chouette/hub/time_table_exporter.rb b/app/exporters/chouette/hub/time_table_exporter.rb index 2553128cd..98fac8fef 100644 --- a/app/exporters/chouette/hub/time_table_exporter.rb +++ b/app/exporters/chouette/hub/time_table_exporter.rb @@ -1,15 +1,19 @@ class Chouette::Hub::TimeTableExporter include ERB::Util - attr_accessor :time_table, :directory, :template, :start_date, :end_date, :identifier + attr_accessor :directory, :template, :time_table, :code, :comment, :start_date, :end_date, :calendar, :identifier - def initialize(time_table, directory, identifier) + def initialize(time_table, directory, index) @time_table = time_table @directory = directory - @identifier = identifier @template = File.open('app/views/api/hub/periodes.hub.erb' ){ |f| f.read } + + @code = time_table.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') + @comment = time_table.comment.encode(Encoding::Windows_1252) if time_table.comment + @start_date = time_table.start_date.strftime("%d/%m/%Y") + @end_date = time_table.end_date.strftime("%d/%m/%Y") @calendar = "" - s_date = @time_table.start_date - e_date = @time_table.end_date + s_date = time_table.start_date + e_date = time_table.end_date while s_date <= e_date if time_table.include_day?(s_date) @calendar += "1" @@ -18,6 +22,7 @@ class Chouette::Hub::TimeTableExporter end s_date = s_date.next_day end + @identifier = index end def render() @@ -29,18 +34,18 @@ class Chouette::Hub::TimeTableExporter end def self.save(time_tables, directory, hub_export) - identifier = 1 + index = 1 time_tables.each do |time_table| - self.new(time_table, directory, identifier).tap do |specific_exporter| + self.new(time_table, directory, index).tap do |specific_exporter| specific_exporter.save - identifier += 1 + index += 1 end end hub_export.log_messages.create( :severity => "ok", :key => "EXPORT|TIME_TABLE_COUNT", :arguments => {"0" => time_tables.size}) end - + def save - File.open(directory + hub_name , "a:ISO_8859_1") do |f| + File.open(directory + hub_name , "a:Windows_1252") do |f| f.write("PERIODE\u000D\u000A") if f.size == 0 f.write(render) end if time_table.present? diff --git a/app/exporters/chouette/hub/transport_mode_exporter.rb b/app/exporters/chouette/hub/transport_mode_exporter.rb index 46d116eec..7b959d3be 100644 --- a/app/exporters/chouette/hub/transport_mode_exporter.rb +++ b/app/exporters/chouette/hub/transport_mode_exporter.rb @@ -27,7 +27,7 @@ class Chouette::Hub::TransportModeExporter end def save - File.open(directory + hub_name , "a:ISO_8859_1") do |f| + File.open(directory + hub_name , "a:Windows_1252") do |f| f.write("MODETRANSPORT\u000D\u000A") if f.size == 0 f.write(render) end diff --git a/app/exporters/chouette/hub/vehicle_journey_at_stop_exporter.rb b/app/exporters/chouette/hub/vehicle_journey_at_stop_exporter.rb index 1c4b4c620..504ff18a3 100644 --- a/app/exporters/chouette/hub/vehicle_journey_at_stop_exporter.rb +++ b/app/exporters/chouette/hub/vehicle_journey_at_stop_exporter.rb @@ -6,7 +6,7 @@ class Chouette::Hub::VehicleJourneyAtStopExporter @vehicle_journey_at_stop = vehicle_journey_at_stop @directory = directory @vehicle_journey_num = index - @vehicle_journey_id = id + @id = id @template = File.open('app/views/api/hub/horaires.hub.erb' ) { |f| f.read } stop_point = @vehicle_journey_at_stop.stop_point stop_area = stop_point.stop_area @@ -49,7 +49,7 @@ class Chouette::Hub::VehicleJourneyAtStopExporter end def save - File.open(directory + hub_name , "a:ISO_8859_1") do |f| + File.open(directory + hub_name , "a:Windows_1252") do |f| f.write("HORAIRE\u000D\u000A") if f.size == 0 f.write(render) end if vehicle_journey_at_stop.present? diff --git a/app/exporters/chouette/hub/vehicle_journey_exporter.rb b/app/exporters/chouette/hub/vehicle_journey_exporter.rb index fb854566b..5ddb536c8 100644 --- a/app/exporters/chouette/hub/vehicle_journey_exporter.rb +++ b/app/exporters/chouette/hub/vehicle_journey_exporter.rb @@ -25,7 +25,7 @@ class Chouette::Hub::VehicleJourneyExporter @arrival_time_sec = arrival_time.sec + ( arrival_time.min + arrival_time.hour * 60 ) * 60 @validity = 0 #@vehicle_journey.time_tables.map(&:int_day_types).each { |v| @validity |= v } - @vehicle_journey.time_tables.each { |t| @validity |= t.int_day_types if t.int_day_types } + @vehicle_journey.time_tables.each { |t| @validity |= ((t.int_day_types / 4) & 127 ) if t.int_day_types } periods = Chouette::TimeTable.where( :id => @vehicle_journey.time_tables.map(&:id) ).map(&:objectid) @periods = "" @@ -38,13 +38,13 @@ class Chouette::Hub::VehicleJourneyExporter end # USE @renvoi for PMR and TAD and create RENVOI.TXT File @renvoi = "" - if @vehicle_journey.mobility_restricted_suitability + if @vehicle_journey.mobility_restricted_suitability || @line.mobility_restricted_suitability @renvoi = "1" - end - File.open(directory + "/RENVOI.TXT" , "a:ISO_8859_1") do |f| - if f.size == 0 - f.write("RENVOI\u000D\u000A") - f.write("a;PMR;1\u000D\u000A") + File.open(directory + "/RENVOI.TXT" , "a:Windows_1252") do |f| + if f.size == 0 + f.write("RENVOI\u000D\u000A") + f.write("a;PMR;1\u000D\u000A") + end end end end @@ -67,7 +67,7 @@ class Chouette::Hub::VehicleJourneyExporter end def save - File.open(directory + hub_name , "a:ISO_8859_1") do |f| + File.open(directory + hub_name , "a:Windows_1252") do |f| f.write("COURSE\u000D\u000A") if f.size == 0 f.write(render) end if vehicle_journey.present? diff --git a/app/exporters/chouette/hub/vehicle_journey_operation_exporter.rb b/app/exporters/chouette/hub/vehicle_journey_operation_exporter.rb index 533f0628e..b6dd6bc78 100644 --- a/app/exporters/chouette/hub/vehicle_journey_operation_exporter.rb +++ b/app/exporters/chouette/hub/vehicle_journey_operation_exporter.rb @@ -91,7 +91,7 @@ class Chouette::Hub::VehicleJourneyOperationExporter end def save - File.open(directory + hub_name , "a:ISO_8859_1") do |f| + File.open(directory + hub_name , "a:Windows_1252") do |f| f.write("COURSE_OPERATION\u000D\u000A") if f.size == 0 f.write(render) end if vehicle_journey.present? diff --git a/app/models/compliance_check_task.rb b/app/models/compliance_check_task.rb index 80fbad38f..1808a792c 100644 --- a/app/models/compliance_check_task.rb +++ b/app/models/compliance_check_task.rb @@ -1,4 +1,5 @@ class ComplianceCheckTask < ActiveRecord::Base + attr_accessor :rule_parameter_set_id belongs_to :referential @@ -9,7 +10,7 @@ class ComplianceCheckTask < ActiveRecord::Base validates_presence_of :user_name validates_inclusion_of :status, :in => %w{ pending processing completed failed } - has_many :compliance_check_results, :order => :status + has_many :compliance_check_results, :order => [ :severity , :status ] serialize :parameter_set, JSON @@ -100,6 +101,4 @@ class ComplianceCheckTask < ActiveRecord::Base update_attribute :status, "failed" end end - - end diff --git a/app/models/compliance_check_task_export.rb b/app/models/compliance_check_task_export.rb new file mode 100644 index 000000000..cce26c5e8 --- /dev/null +++ b/app/models/compliance_check_task_export.rb @@ -0,0 +1,51 @@ +require 'tempfile' + +class ComplianceCheckTaskExport + include ERB::Util + + require 'zip' + + attr_accessor :template, :detailed_errors_template + attr_reader :compliance_check_task + + def initialize(compliance_check_task) + @compliance_check_task = compliance_check_task + @template = File.open('app/views/compliance_check_tasks/summary_errors_index.csv.erb' ) { |f| f.read } + @detailed_errors_template = File.open('app/views/compliance_check_tasks/detailed_errors_index.csv.erb' ) { |f| f.read } + end + + def export + begin + Dir.mktmpdir("ComplianceCheckResults_#{@compliance_check_task.referential_id}_#{@compliance_check_task.id}_", Dir.tmpdir) { |temp_dir| + + File.open(temp_dir + "/summary_errors_index.csv" , "a") do |f| + f.write(render) + f.flush + end + + File.open(temp_dir + "/detailed_errors_report.csv" , "a") do |f| + f.write(detailed_errors_render) + f.flush + end + + zip_file = Tempfile.new(["ComplianceCheckResults_#{@compliance_check_task.referential_id}_#{@compliance_check_task.id}_", ".zip"]) + + ::Zip::File.open(zip_file.path, ::Zip::File::CREATE) do |zipfile| + Dir[File.join(temp_dir, '*.csv')].each do |f| + zipfile.add(File.basename(f), f) + end + end + return zip_file + } + end + end + + def render() + ERB.new(@template).result(binding) + end + + def detailed_errors_render() + ERB.new(@detailed_errors_template).result(binding) + end + +end diff --git a/app/views/api/hub/arrets_generiques.hub.erb b/app/views/api/hub/arrets_generiques.hub.erb index 00f041552..ba28d3fff 100644 --- a/app/views/api/hub/arrets_generiques.hub.erb +++ b/app/views/api/hub/arrets_generiques.hub.erb @@ -1 +1 @@ -<%= @stop_area.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @stop_area.objectid %>;<%= @stop_area.name.encode(Encoding::ISO_8859_1) if @stop_area.name %>;<%= @stop_area.nearest_topic_name.encode(Encoding::ISO_8859_1) if @stop_area.nearest_topic_name %>;<%= @type %>;;<%= (@stop_area.latitude && @stop_area.longitude) ? RGeo::CoordSys::Proj4::transform_coords(@from_projection, @to_projection, @stop_area.longitude, @stop_area.latitude)[0].to_i : '' %>;<%= (@stop_area.latitude && @stop_area.longitude) ? RGeo::CoordSys::Proj4::transform_coords(@from_projection, @to_projection, @stop_area.longitude, @stop_area.latitude)[1].to_i : '' %>;<%= @stop_area.city_name.encode(Encoding::ISO_8859_1) if @stop_area.city_name %>;<%= @stop_area.zip_code if @stop_area.zip_code %>;<%= @stop_area.comment.encode(Encoding::ISO_8859_1) if @stop_area.comment %>;<%= "\u000D\u000A" %>
\ No newline at end of file +<%= @stop_area.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @stop_area.objectid %>;<%= @stop_area.name.encode(Encoding::Windows_1252) if @stop_area.name %>;<%= @stop_area.nearest_topic_name.encode(Encoding::Windows_1252) if @stop_area.nearest_topic_name %>;<%= @type %>;;<%= (@stop_area.latitude && @stop_area.longitude) ? RGeo::CoordSys::Proj4::transform_coords(@from_projection, @to_projection, @stop_area.longitude, @stop_area.latitude)[0].to_i : '' %>;<%= (@stop_area.latitude && @stop_area.longitude) ? RGeo::CoordSys::Proj4::transform_coords(@from_projection, @to_projection, @stop_area.longitude, @stop_area.latitude)[1].to_i : '' %>;<%= @stop_area.city_name.encode(Encoding::Windows_1252) if @stop_area.city_name %>;<%= @stop_area.zip_code if @stop_area.zip_code %>;<%= @stop_area.comment.encode(Encoding::Windows_1252) if @stop_area.comment %>;<%= "\u000D\u000A" %>
\ No newline at end of file diff --git a/app/views/api/hub/arrets_physiques.hub.erb b/app/views/api/hub/arrets_physiques.hub.erb index 02cb11238..626ee6454 100644 --- a/app/views/api/hub/arrets_physiques.hub.erb +++ b/app/views/api/hub/arrets_physiques.hub.erb @@ -1 +1 @@ -<%= @stop_area.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @stop_area.objectid %>;<%= @stop_area.name.encode(Encoding::ISO_8859_1) if @stop_area.name %>;<%= @stop_area.nearest_topic_name.encode(Encoding::ISO_8859_1) if @stop_area.nearest_topic_name %>;<%= @type %>;<%= @parent.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @parent %>;<%= (@stop_area.latitude && @stop_area.longitude) ? RGeo::CoordSys::Proj4::transform_coords(@from_projection, @to_projection, @stop_area.longitude, @stop_area.latitude)[0].to_i : -1 %>;<%= (@stop_area.latitude && @stop_area.longitude) ? RGeo::CoordSys::Proj4::transform_coords(@from_projection, @to_projection, @stop_area.longitude, @stop_area.latitude)[1].to_i : -1 %>;<%= @stop_area.city_name.encode(Encoding::ISO_8859_1) if @stop_area.city_name %>;<%= @stop_area.zip_code if @stop_area.zip_code %>;<%= @stop_area.comment.encode(Encoding::ISO_8859_1) if @stop_area.comment %>;<%= @stop_area.registration_number %><%= "\u000D\u000A" %>
\ No newline at end of file +<%= @stop_area.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @stop_area.objectid %>;<%= @stop_area.name.encode(Encoding::Windows_1252) if @stop_area.name %>;<%= @stop_area.nearest_topic_name.encode(Encoding::Windows_1252) if @stop_area.nearest_topic_name %>;<%= @type %>;<%= @parent.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @parent %>;<%= (@stop_area.latitude && @stop_area.longitude) ? RGeo::CoordSys::Proj4::transform_coords(@from_projection, @to_projection, @stop_area.longitude, @stop_area.latitude)[0].to_i : -1 %>;<%= (@stop_area.latitude && @stop_area.longitude) ? RGeo::CoordSys::Proj4::transform_coords(@from_projection, @to_projection, @stop_area.longitude, @stop_area.latitude)[1].to_i : -1 %>;<%= @stop_area.city_name.encode(Encoding::Windows_1252) if @stop_area.city_name %>;<%= @stop_area.zip_code if @stop_area.zip_code %>;<%= @stop_area.comment.encode(Encoding::Windows_1252) if @stop_area.comment %>;<%= @stop_area.registration_number %><%= "\u000D\u000A" %>
\ No newline at end of file diff --git a/app/views/api/hub/chemins.hub.erb b/app/views/api/hub/chemins.hub.erb index f5408c51f..38ea4e562 100644 --- a/app/views/api/hub/chemins.hub.erb +++ b/app/views/api/hub/chemins.hub.erb @@ -1 +1 @@ -<%= @line.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @line %>;<%= @journey_pattern.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @journey_pattern.objectid %>;<%= @journey_pattern.registration_number if @journey_pattern.registration_number %>;<%= @journey_pattern.name.encode(Encoding::ISO_8859_1) if @journey_pattern.name %>;<%= (@journey_pattern.route.wayback == 'A' ? 1 : 2) if @journey_pattern.route %>;<%= @type %>;<% @stop_areas.each do |s| %>;<%= s.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if s.objectid %>;<%= s.registration_number %>;;<% end %><%= "\u000D\u000A" %>
\ No newline at end of file +<%= @line.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @line %>;<%= @journey_pattern.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @journey_pattern.objectid %>;<%= @journey_pattern.registration_number if @journey_pattern.registration_number %>;<%= @journey_pattern.name.encode(Encoding::Windows_1252) if @journey_pattern.name %>;<%= (@journey_pattern.route.wayback == 'A' ? 1 : 2) if @journey_pattern.route %>;<%= @type %>;<% @stop_areas.each do |s| %>;<%= s.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if s.objectid %>;<%= s.registration_number %>;;<% end %><%= "\u000D\u000A" %>
\ No newline at end of file diff --git a/app/views/api/hub/communes.hub.erb b/app/views/api/hub/communes.hub.erb index 265271c54..cb981b0d2 100644 --- a/app/views/api/hub/communes.hub.erb +++ b/app/views/api/hub/communes.hub.erb @@ -1 +1 @@ -<%= @city_code %>;<%= @city_name.encode(Encoding::ISO_8859_1) if @city_name %><%= "\u000D\u000A" %>
\ No newline at end of file +<%= @city_code %>;<%= @city_name.encode(Encoding::Windows_1252) if @city_name %><%= "\u000D\u000A" %>
\ No newline at end of file diff --git a/app/views/api/hub/directions.hub.erb b/app/views/api/hub/directions.hub.erb index dd069968d..031c38d7b 100644 --- a/app/views/api/hub/directions.hub.erb +++ b/app/views/api/hub/directions.hub.erb @@ -1 +1 @@ -<%= @journey_pattern.name.encode(Encoding::ISO_8859_1) if @journey_pattern.name %>;<%= @line.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @line %>;<%= (@journey_pattern.route.wayback == 'A' ? 1 : 2) if @journey_pattern.route %>;<%= @journey_pattern.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @journey_pattern.objectid %><%= "\u000D\u000A" %>
\ No newline at end of file +<%= @journey_pattern.name.encode(Encoding::Windows_1252) if @journey_pattern.name %>;<%= @line.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @line %>;<%= (@journey_pattern.route.wayback == 'A' ? 1 : 2) if @journey_pattern.route %>;<%= @journey_pattern.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @journey_pattern.objectid %><%= "\u000D\u000A" %>
\ No newline at end of file diff --git a/app/views/api/hub/groupe_de_lignes.hub.erb b/app/views/api/hub/groupe_de_lignes.hub.erb index 2547c1e11..fe4f6d849 100644 --- a/app/views/api/hub/groupe_de_lignes.hub.erb +++ b/app/views/api/hub/groupe_de_lignes.hub.erb @@ -1 +1 @@ -<%= @group_of_lines.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= @group_of_lines.name.encode(Encoding::ISO_8859_1) if @group_of_lines.name %>;<%= @group_of_lines.id %><%= "\u000D\u000A" %>
\ No newline at end of file +<%= @group_of_lines.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= @group_of_lines.name.encode(Encoding::Windows_1252) if @group_of_lines.name %>;<%= @group_of_lines.id %><%= "\u000D\u000A" %>
\ No newline at end of file diff --git a/app/views/api/hub/horaires.hub.erb b/app/views/api/hub/horaires.hub.erb index 1497588af..6c5b9d04b 100644 --- a/app/views/api/hub/horaires.hub.erb +++ b/app/views/api/hub/horaires.hub.erb @@ -1 +1 @@ -<%= @stop_area_code %>;<%= @arrival_time %>;<%= @arrival_type %>;<%= @vehicle_journey_num %>;<%= @vehicle_journey_at_stop.vehicle_journey.journey_pattern_id %>;<%= @stop_area_id %>;<%= 2 * @vehicle_journey_id - 1 %><%= "\u000D\u000A" %><%= @stop_area_code %>;<%= @departure_time %>;<%= @departure_type %>;<%= @vehicle_journey_num %>;<%= @vehicle_journey_at_stop.vehicle_journey.journey_pattern_id %>;<%= @stop_area_id %>;<%= 2 * @vehicle_journey_id %><%= "\u000D\u000A" %>
\ No newline at end of file +<%= @stop_area_code %>;<%= @arrival_time %>;<%= @arrival_type %>;<%= @vehicle_journey_num %>;<%= @vehicle_journey_at_stop.vehicle_journey.journey_pattern_id %>;<%= @stop_area_id %>;<%= 2 * @id - 1 %><%= "\u000D\u000A" %><%= @stop_area_code %>;<%= @departure_time %>;<%= @departure_type %>;<%= @vehicle_journey_num %>;<%= @vehicle_journey_at_stop.vehicle_journey.journey_pattern_id %>;<%= @stop_area_id %>;<%= 2 * @id %><%= "\u000D\u000A" %>
\ No newline at end of file diff --git a/app/views/api/hub/lignes.hub.erb b/app/views/api/hub/lignes.hub.erb index 921eb7056..604d52812 100644 --- a/app/views/api/hub/lignes.hub.erb +++ b/app/views/api/hub/lignes.hub.erb @@ -1 +1 @@ -<%= @line.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @line.objectid %>;<%= @line.number %>;<%= @line.name.encode(Encoding::ISO_8859_1) if @line.name %>;;;<%= @company.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @company %>;<%= @network.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @network %>;<%= @group_of_line %>;<%= @line.id %><%= "\u000D\u000A" %>
\ No newline at end of file +<%= @line.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @line.objectid %>;<%= @line.number %>;<%= @line.name.encode(Encoding::Windows_1252) if @line.name %>;;;<%= @company.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @company %>;<%= @network.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if @network %>;<%= @group_of_line %>;<%= @line.id %><%= "\u000D\u000A" %>
\ No newline at end of file diff --git a/app/views/api/hub/periodes.hub.erb b/app/views/api/hub/periodes.hub.erb index 2bb3e8368..64737c17d 100644 --- a/app/views/api/hub/periodes.hub.erb +++ b/app/views/api/hub/periodes.hub.erb @@ -1 +1 @@ -<%= Chouette::TimeTable.find(@time_table.id).objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= @time_table.comment.encode(Encoding::ISO_8859_1) if @time_table.comment %>;<%= @time_table.start_date.strftime("%d/%m/%Y") %>;<%= @time_table.end_date.strftime("%d/%m/%Y") %>;<%= @calendar %>;<%= @identifier %><%= "\u000D\u000A" %>
\ No newline at end of file +<%= @code %>;<%= @comment %>;<%= @start_date %>;<%= @end_date %>;<%= @calendar %>;<%= @identifier %><%= "\u000D\u000A" %>
\ No newline at end of file diff --git a/app/views/api/hub/reseaux.hub.erb b/app/views/api/hub/reseaux.hub.erb index 95ab8d547..f8894f9cd 100644 --- a/app/views/api/hub/reseaux.hub.erb +++ b/app/views/api/hub/reseaux.hub.erb @@ -1 +1 @@ -<%= @network.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= @network.name.encode(Encoding::ISO_8859_1) if @network.name %>;<%= @network.id %><%= "\u000D\u000A" %>
\ No newline at end of file +<%= @network.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= @network.name.encode(Encoding::Windows_1252) if @network.name %>;<%= @network.id %><%= "\u000D\u000A" %>
\ No newline at end of file diff --git a/app/views/api/hub/transporteurs.hub.erb b/app/views/api/hub/transporteurs.hub.erb index 595d3b5fb..8ee7aa5ce 100644 --- a/app/views/api/hub/transporteurs.hub.erb +++ b/app/views/api/hub/transporteurs.hub.erb @@ -1 +1 @@ -<%= @company.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= @company.name.encode(Encoding::ISO_8859_1) if @company.name %>;<%= @company.id %><%= "\u000D\u000A" %>
\ No newline at end of file +<%= @company.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') %>;<%= @company.name.encode(Encoding::Windows_1252) if @company.name %>;<%= @company.id %><%= "\u000D\u000A" %>
\ No newline at end of file diff --git a/app/views/compliance_check_tasks/detailed_errors_index.csv.erb b/app/views/compliance_check_tasks/detailed_errors_index.csv.erb new file mode 100644 index 000000000..527e35532 --- /dev/null +++ b/app/views/compliance_check_tasks/detailed_errors_index.csv.erb @@ -0,0 +1,2 @@ +<%= ComplianceCheckResult.human_attribute_name(:severity) %>;<%= ComplianceCheckResult.human_attribute_name(:status) %>;<%= ComplianceCheckResult.human_attribute_name(:rule_code) %>;<%= ComplianceCheckResult.human_attribute_name(:detail) %>;<%= ComplianceCheckResult.human_attribute_name(:url) %>;<%= ComplianceCheckResult.human_attribute_name(:violation_count) %>;<%= ComplianceCheckResult.human_attribute_name(:first_violations) %> +<% @compliance_check_task.compliance_check_results.each do |r| %><% if r.detail.present? %><% r.detail["detail"].first(10).each do |error| %><% case r.severity %><% when "warning" %><%= I18n.t "compliance_check_result.severities.warning" %><% when "error" %><%= I18n.t "compliance_check_result.severities.error" %><% end %>;<%= r.status %>;<%= r.rule_code %>;<%= ComplianceCheckResult.human_attribute_name(r.rule_code) %>;<%= Rails.application.config.validation_spec + I18n.locale.to_s + "/" + r.rule_code + ".html" %>;<%= r.violation_count %>;<% if error["messageArgs"] %><%= ComplianceCheckResult.human_attribute_name(r.rule_code) + I18n.t("compliance_check_result.details." + error["messageKey"], error["messageArgs"].symbolize_keys ) %><% else %><%= ComplianceCheckResult.human_attribute_name(r.rule_code) + I18n.t("compliance_check_result.details." + error["messageKey"] ) %><% end %><%= "\n" %><% end %><% end %><% end %>
\ No newline at end of file diff --git a/app/views/compliance_check_tasks/show.html.erb b/app/views/compliance_check_tasks/show.html.erb index c72d9350f..2fa39ff6f 100644 --- a/app/views/compliance_check_tasks/show.html.erb +++ b/app/views/compliance_check_tasks/show.html.erb @@ -31,6 +31,7 @@ </div> <% content_for :sidebar do %> <ul class="actions"> + <li><%= link_to t('compliance_check_tasks.actions.download'), export_referential_compliance_check_task_path(@referential, @compliance_check_task) %></il> <li><%= link_to t('compliance_check_tasks.actions.destroy'), referential_compliance_check_task_path(@referential, @compliance_check_task), :method => :delete, :data => {:confirm => t('compliance_check_tasks.actions.destroy_confirm')}, :class => "remove" %></li> </ul> diff --git a/app/views/compliance_check_tasks/summary_errors_index.csv.erb b/app/views/compliance_check_tasks/summary_errors_index.csv.erb new file mode 100644 index 000000000..516cb1b93 --- /dev/null +++ b/app/views/compliance_check_tasks/summary_errors_index.csv.erb @@ -0,0 +1,3 @@ +<%= ComplianceCheckResult.human_attribute_name(:severity) %>;<%= ComplianceCheckResult.human_attribute_name(:status) %>;<%= ComplianceCheckResult.human_attribute_name(:rule_code) %>;<%= ComplianceCheckResult.human_attribute_name(:detail) %>;<%= ComplianceCheckResult.human_attribute_name(:url) %>;<%= ComplianceCheckResult.human_attribute_name(:violation_count) %> +<% @compliance_check_task.compliance_check_results.each do |r| %><% case r.severity %><% when "warning" %><%= I18n.t "compliance_check_result.severities.warning" %><% when "error" %><%= I18n.t "compliance_check_result.severities.error" %><% end %>;<%= r.status %>;<%= r.rule_code %>;<%= ComplianceCheckResult.human_attribute_name(r.rule_code) %>;<%= Rails.application.config.validation_spec + I18n.locale.to_s + "/" + r.rule_code + ".html" %>;<%= r.violation_count %> +<% end %>
\ No newline at end of file |
