aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/assets/stylesheets/main/routes.css.scss8
-rw-r--r--app/assets/stylesheets/main/simple_form.css.scss7
-rw-r--r--app/controllers/autocomplete_time_tables_controller.rb33
-rw-r--r--app/controllers/compliance_check_results_controller.rb9
-rw-r--r--app/controllers/compliance_check_tasks_controller.rb7
-rw-r--r--app/controllers/exports_controller.rb4
-rw-r--r--app/controllers/routes_controller.rb17
-rw-r--r--app/exporters/chouette/hub/city_code_exporter.rb2
-rw-r--r--app/exporters/chouette/hub/commercial_stop_area_exporter.rb6
-rw-r--r--app/exporters/chouette/hub/company_exporter.rb2
-rw-r--r--app/exporters/chouette/hub/connection_link_exporter.rb2
-rw-r--r--app/exporters/chouette/hub/direction_exporter.rb2
-rw-r--r--app/exporters/chouette/hub/exporter.rb318
-rw-r--r--app/exporters/chouette/hub/group_of_lines_exporter.rb2
-rw-r--r--app/exporters/chouette/hub/itl_exporter.rb65
-rw-r--r--app/exporters/chouette/hub/journey_pattern_exporter.rb2
-rw-r--r--app/exporters/chouette/hub/line_exporter.rb2
-rw-r--r--app/exporters/chouette/hub/network_exporter.rb2
-rw-r--r--app/exporters/chouette/hub/physical_stop_area_exporter.rb5
-rw-r--r--app/exporters/chouette/hub/route_exporter.rb2
-rw-r--r--app/exporters/chouette/hub/time_table_exporter.rb25
-rw-r--r--app/exporters/chouette/hub/transport_mode_exporter.rb2
-rw-r--r--app/exporters/chouette/hub/vehicle_journey_at_stop_exporter.rb4
-rw-r--r--app/exporters/chouette/hub/vehicle_journey_exporter.rb16
-rw-r--r--app/exporters/chouette/hub/vehicle_journey_operation_exporter.rb2
-rw-r--r--app/helpers/routes_helper.rb1
-rw-r--r--app/helpers/rule_parameter_sets_helper.rb18
-rw-r--r--app/helpers/stop_areas_helper.rb12
-rw-r--r--app/helpers/time_tables_helper.rb54
-rw-r--r--app/helpers/users_helper.rb2
-rw-r--r--app/inputs/search_time_table_input.rb5
-rw-r--r--app/models/compliance_check_task.rb5
-rw-r--r--app/models/compliance_check_task_export.rb52
-rw-r--r--app/models/referential.rb136
-rw-r--r--app/models/rule_parameter_set.rb120
-rw-r--r--app/presenters/time_table_presenter.rb52
-rw-r--r--app/presenters/vehicle_journey_presenter.rb11
-rw-r--r--app/views/api/hub/arrets_generiques.hub.erb2
-rw-r--r--app/views/api/hub/arrets_physiques.hub.erb2
-rw-r--r--app/views/api/hub/chemins.hub.erb2
-rw-r--r--app/views/api/hub/communes.hub.erb2
-rw-r--r--app/views/api/hub/directions.hub.erb2
-rw-r--r--app/views/api/hub/groupe_de_lignes.hub.erb2
-rw-r--r--app/views/api/hub/horaires.hub.erb2
-rw-r--r--app/views/api/hub/itls.hub.erb1
-rw-r--r--app/views/api/hub/lignes.hub.erb2
-rw-r--r--app/views/api/hub/periodes.hub.erb2
-rw-r--r--app/views/api/hub/reseaux.hub.erb2
-rw-r--r--app/views/api/hub/transporteurs.hub.erb2
-rw-r--r--app/views/autocomplete_time_tables/index.rabl10
-rw-r--r--app/views/compliance_check_tasks/detailed_errors_index.csv.erb2
-rw-r--r--app/views/compliance_check_tasks/show.html.erb8
-rw-r--r--app/views/compliance_check_tasks/summary_errors_index.csv.erb3
-rw-r--r--app/views/connection_links/show.html.erb6
-rw-r--r--app/views/devise/invitations/edit.html.erb2
-rw-r--r--app/views/devise/invitations/new.html.erb2
-rw-r--r--app/views/exports/_fields_hub_export.erb2
-rw-r--r--app/views/group_of_lines/_form.erb1
-rw-r--r--app/views/group_of_lines/show.html.erb4
-rw-r--r--app/views/help/index.textile8
-rw-r--r--app/views/help/introduction.textile2
-rw-r--r--app/views/routes/edit_boarding_alighting.html.erb27
-rw-r--r--app/views/routes/show.html.erb12
-rw-r--r--app/views/rule_parameter_sets/_column_fields.html.erb11
-rw-r--r--app/views/rule_parameter_sets/_form.html.erb33
-rw-r--r--app/views/rule_parameter_sets/show.html.erb71
-rw-r--r--app/views/time_table_combinations/_combine_form.html.erb2
-rw-r--r--app/views/time_tables/_properties_show.html.erb127
-rw-r--r--app/views/time_tables/_show_time_table.html.erb14
-rw-r--r--app/views/time_tables/_time_table.html.erb14
-rw-r--r--app/views/time_tables/index.html.erb12
-rw-r--r--app/views/vehicle_journeys/_form.html.erb8
-rw-r--r--app/views/vehicle_journeys/_show_popover.html.erb12
-rw-r--r--app/views/vehicle_journeys/_time_filter.html.erb13
-rw-r--r--app/views/vehicle_journeys/_time_table.html.erb7
-rw-r--r--app/views/vehicle_journeys/_timeless_vehicle_journey.html.erb15
-rw-r--r--app/views/vehicle_journeys/index.html.erb27
77 files changed, 987 insertions, 505 deletions
diff --git a/app/assets/stylesheets/main/routes.css.scss b/app/assets/stylesheets/main/routes.css.scss
index 31891f39e..7714c13a3 100644
--- a/app/assets/stylesheets/main/routes.css.scss
+++ b/app/assets/stylesheets/main/routes.css.scss
@@ -34,6 +34,14 @@
}
}
+#workspace.routes.edit_boarding_alighting{
+
+ .stop_area{
+ padding-top: 7px;
+ }
+
+}
+
#workspace.routes.show
{
}
diff --git a/app/assets/stylesheets/main/simple_form.css.scss b/app/assets/stylesheets/main/simple_form.css.scss
new file mode 100644
index 000000000..9282d89e0
--- /dev/null
+++ b/app/assets/stylesheets/main/simple_form.css.scss
@@ -0,0 +1,7 @@
+#workspace{
+
+ .submit{
+ @extend .col-md-offset-3;
+ }
+
+} \ No newline at end of file
diff --git a/app/controllers/autocomplete_time_tables_controller.rb b/app/controllers/autocomplete_time_tables_controller.rb
new file mode 100644
index 000000000..c556bb71c
--- /dev/null
+++ b/app/controllers/autocomplete_time_tables_controller.rb
@@ -0,0 +1,33 @@
+class AutocompleteTimeTablesController < InheritedResources::Base
+ respond_to :json, :only => [:index]
+
+ before_filter :switch_referential
+
+ def switch_referential
+ Apartment::Database.switch(referential.slug)
+ end
+
+ def referential
+ @referential ||= current_organisation.referentials.find params[:referential_id]
+ end
+
+ protected
+
+ def select_time_tables
+ if params[:route_id]
+ referential.time_tables.joins( vehicle_journeys: :route).where( "routes.id IN (#{params[:route_id]})")
+ else
+ referential.time_tables
+ end
+ end
+
+ def referential_time_tables
+ @referential_time_tables ||= select_time_tables
+ end
+
+ def collection
+ comment_selection = referential_time_tables.select{ |p| p.comment =~ /#{params[:q]}/i }
+ tag_selection = referential_time_tables.tagged_with( params[:q], :wild => true)
+ @time_tables = (comment_selection + tag_selection).uniq
+ end
+end
diff --git a/app/controllers/compliance_check_results_controller.rb b/app/controllers/compliance_check_results_controller.rb
index a4ef40509..a39c79ea7 100644
--- a/app/controllers/compliance_check_results_controller.rb
+++ b/app/controllers/compliance_check_results_controller.rb
@@ -1,22 +1,23 @@
class ComplianceCheckResultsController < ChouetteController
+
respond_to :json
respond_to :js, :only => :index
belongs_to :compliance_check_task
- def index
+ def index
index! do |format|
format.html { render :layout => false }
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..773ea1ed7 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, request).export, :type => :zip }
+ end
+ end
protected
diff --git a/app/controllers/exports_controller.rb b/app/controllers/exports_controller.rb
index e8c140dd7..bb9cff197 100644
--- a/app/controllers/exports_controller.rb
+++ b/app/controllers/exports_controller.rb
@@ -14,8 +14,8 @@ class ExportsController < ChouetteController
end
def create
- if (params[:export][:type] == "HubExport") && Chouette::VehicleJourneyAtStop.all.count > 50000
- flash[:notice] = I18n.t("formtastic.titles.export.vjas.size", size: Chouette::VehicleJourneyAtStop.all.count)
+ if (params[:export][:type] == "HubExport") && Chouette::VehicleJourneyAtStop.count > 50000
+ flash[:notice] = I18n.t("formtastic.titles.export.vjas.size", size: Chouette::VehicleJourneyAtStop.count)
redirect_to new_referential_export_path(@referential)
elsif (params[:export][:type] == "HubExport") && (params[:export][:start_date].empty? || params[:export][:end_date].empty?)
flash[:notice] = I18n.t("formtastic.titles.export.dates.not_nul")
diff --git a/app/controllers/routes_controller.rb b/app/controllers/routes_controller.rb
index 391a14d88..6454ce068 100644
--- a/app/controllers/routes_controller.rb
+++ b/app/controllers/routes_controller.rb
@@ -15,6 +15,21 @@ class RoutesController < ChouetteController
end
end
+ def edit_boarding_alighting
+ @route = route
+ build_breadcrumb :edit
+ end
+
+ def save_boarding_alighting
+ @route = route
+
+ if @route.update_attributes(params[:route])
+ redirect_to referential_line_route_path(@referential, @line, @route)
+ else
+ render "edit_boarding_alighting"
+ end
+ end
+
def show
@map = RouteMap.new(route).with_helpers(self)
@stop_points = route.stop_points.paginate(:page => params[:page])
@@ -26,7 +41,7 @@ class RoutesController < ChouetteController
# overwrite inherited resources to use delete instead of destroy
# foreign keys will propagate deletion)
def destroy_resource(object)
- object.delete
+ object.delete
end
def destroy
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/exporter.rb b/app/exporters/chouette/hub/exporter.rb
index 27ac4e7ee..3a9313762 100644
--- a/app/exporters/chouette/hub/exporter.rb
+++ b/app/exporters/chouette/hub/exporter.rb
@@ -1,10 +1,10 @@
class Chouette::Hub::Exporter
require "zip"
-
+
attr_reader :referential
attr_reader :hub_export, :lines, :routes, :journey_patterns
attr_reader :time_tables, :vehicle_journeys
-
+
def initialize(referential, hub_export)
@referential = referential
@hub_export = hub_export
@@ -14,9 +14,8 @@ class Chouette::Hub::Exporter
@time_tables = nil
@vehicle_journeys = nil
end
-
+
def select_time_tables(start_date, end_date)
- #TODO considere options[:o], options[:id]
all_time_tables = Chouette::TimeTable.all
time_tables = []
s_date = Date.strptime(start_date, "%Y-%m-%d")
@@ -27,224 +26,188 @@ class Chouette::Hub::Exporter
end
return time_tables
end
-
+
def select_lines(object, ids)
if object == "network"
- ids.present? ? Chouette::Line.includes(:routes).where( :network_id => ids.split(",")).order(:objectid) :
+ ids.present? ? Chouette::Line.includes(:routes).where(:network_id => ids.split(",")).order(:objectid) :
Chouette::Line.joins(:network).includes(:routes).order(:objectid)
elsif object == "company"
- ids.present? ? Chouette::Line.includes(:routes).where( :company_id => ids.split(",")).order(:objectid) :
+ ids.present? ? Chouette::Line.includes(:routes).where(:company_id => ids.split(",")).order(:objectid) :
Chouette::Line.joins(:company).includes(:routes).order(:objectid)
elsif object == "line" && ids.present?
- Chouette::Line.includes(:routes).where( :id => ids.split(",")).order(:objectid)
+ Chouette::Line.includes(:routes).where(:id => ids.split(",")).order(:objectid)
else
Chouette::Line.includes(:routes).order(:objectid)
end
end
-
+
def referential_exportable?
- Chouette::VehicleJourneyAtStop.all.count < 50000
+ Chouette::VehicleJourneyAtStop.count < 50000
end
def time_tables_exportable?
time_tables
end
-
+
def routes_exportable?
routes # && routes.size < 150
end
-
+
def lines_exportable?
lines # && lines.size < 150
end
-
+
def journey_patterns_exportable?
journey_patterns # && journey_patterns.size < 150
end
-
+
def vehicle_journeys_exportable?
vehicle_journeys
end
-
+
def log_overflow_warning( target_class)
- hub_export.log_messages.create( :severity => "warning", :key => "EXPORT_ERROR|EXCEPTION",
- :arguments => {"0" => I18n.t( 'export_log_messages.messages.overflow',
- :count => 150, :data => target_class.model_name.human.pluralize)})
+ hub_export.log_messages.create(:severity => "warning",
+ :key => "EXPORT_ERROR|EXCEPTION",
+ :arguments => {"0" => I18n.t('export_log_messages.messages.overflow',
+ :count => 150,
+ :data => target_class.model_name.human.pluralize)})
end
-
+
def export(zip_file_path, options = {})
begin
referential.switch
-
if referential_exportable? && options[:start_date] && options[:end_date]
-
FileUtils.rm(zip_file_path) if File.exists? zip_file_path
-
hub_export.log_messages.create( :severity => "ok", :key => "EXPORT", :arguments => {"0" => "HUB"})
-
- Dir.mktmpdir(nil, "/tmp"){ |temp_dir|
-
- @time_tables = select_time_tables(options[:start_date], options[:end_date])
-
- @lines = select_lines( options[:o], options[:id] )
-
- @routes = []
- if @lines
- @lines.each { |line| @routes << Chouette::Route.where( "line_id = ?", line.id ).order(:wayback) }
- end
-
- @journey_patterns = []
- if @routes
- @routes.each { |subroutes| @journey_patterns << Chouette::JourneyPattern.where( :route_id => subroutes.map(&:id) ).order(:objectid) }
- end
- @journey_patterns = @journey_patterns.flatten
-
- @routes = @routes.flatten
- @vehicle_journeys = Chouette::VehicleJourney.where(:route_id => @routes.map(&:id)).order(:objectid) if routes_exportable?
-
- rts = []
- jps = []
- vjs = []
- tts = []
- @vehicle_journeys.each do |vj|
- unless (vj.time_tables & @time_tables).empty?
- vjs << vj
- tts << (vj.time_tables & @time_tables)
- rts << vj.route_id
- jps << vj.journey_pattern_id
+ Dir.mktmpdir(nil, "/tmp") { |temp_dir|
+ @time_tables = select_time_tables(options[:start_date], options[:end_date])
+ @lines = select_lines(options[:o], options[:id])
+
+ @routes = []
+ if @lines
+ @lines.each { |line| @routes << Chouette::Route.where("line_id = ?", line.id).order(:wayback) }
+ end
+
+ @journey_patterns = []
+ if @routes
+ @routes.each { |subroutes| @journey_patterns << Chouette::JourneyPattern.where(:route_id => subroutes.map(&:id)).order(:objectid) }
+ end
+ @journey_patterns = @journey_patterns.flatten
+
+ @routes = @routes.flatten
+ @vehicle_journeys = Chouette::VehicleJourney.where(:route_id => @routes.map(&:id)).order(:objectid) if routes_exportable?
+
+ rts = []
+ jps = []
+ vjs = []
+ tts = []
+ @vehicle_journeys.each do |vj|
+ unless (vj.time_tables & @time_tables).empty?
+ vjs << vj
+ tts << (vj.time_tables & @time_tables)
+ rts << vj.route_id
+ jps << vj.journey_pattern_id
+ end
+ end
+ @time_tables = tts.flatten.uniq
+ @vehicle_journeys = vjs.uniq
+ rts = rts.flatten.uniq
+ jps = jps.flatten.uniq
+
+ @routes.delete_if {|r| !(rts.include?(r.id)) }
+ @journey_patterns.delete_if {|jp| !(jps.include?(jp.id)) }
+
+ vehicle_journey_at_stops = Chouette::VehicleJourneyAtStop.where( :vehicle_journey_id => @vehicle_journeys.map(&:id) ) #.order(:id) if vehicle_journeys_exportable?
+
+ if time_tables_exportable?
+ Chouette::Hub::TimeTableExporter.save(@time_tables, temp_dir, hub_export)
+ else
+ log_overflow_warning(Chouette::TimeTable)
end
- end
- @time_tables = tts.flatten.uniq
- @vehicle_journeys = vjs.uniq
- rts = rts.flatten.uniq
- jps = jps.flatten.uniq
-
- @routes.delete_if {|r| !(rts.include?(r.id)) }
- @journey_patterns.delete_if {|jp| !(jps.include?(jp.id)) }
-
-
- vehicle_journey_at_stops = Chouette::VehicleJourneyAtStop.where( :vehicle_journey_id => @vehicle_journeys.map(&:id) ) #.order(:id) if vehicle_journeys_exportable?
-
- if time_tables_exportable?
- Chouette::Hub::TimeTableExporter.save(@time_tables, temp_dir, hub_export)
- else
- log_overflow_warning(Chouette::TimeTable)
- end
-
- if journey_patterns_exportable?
- Chouette::Hub::RouteExporter.save(@routes, temp_dir, hub_export)
- Chouette::Hub::JourneyPatternExporter.save(@journey_patterns, temp_dir, hub_export)
- Chouette::Hub::DirectionExporter.save(@journey_patterns, temp_dir, hub_export)
- else
- log_overflow_warning(Chouette::JourneyPattern) if routes_exportable?
- end
-
- if vehicle_journeys_exportable?
- Chouette::Hub::VehicleJourneyExporter.save(@vehicle_journeys, temp_dir, hub_export)
- Chouette::Hub::VehicleJourneyOperationExporter.save(@vehicle_journeys, temp_dir, hub_export)
- #Chouette::Hub::VehicleJourneyAtStopExporter.save(vehicle_journey_at_stops, temp_dir, hub_export)
- Chouette::Hub::VehicleJourneyAtStopExporter.save(@vehicle_journeys, temp_dir, hub_export, vehicle_journey_at_stops.count)
- else
- log_overflow_warning(Chouette::VehicleJourney)
- end
-
- stop_points = Chouette::StopPoint.where( :id => vehicle_journey_at_stops.map(&:stop_point_id)) #.order(:id)
- physical_stop_areas = Chouette::StopArea.where( :id => stop_points.map(&:stop_area_id)) #.order(:parent_id)
- commercial_stop_areas = Chouette::StopArea.where( :id => physical_stop_areas.map(&:parent_id)).order(:objectid)
-
- physical_stop_areas = []
- commercial_stop_areas.each { |commercial_stop_area| physical_stop_areas << Chouette::StopArea.where( :parent_id => [commercial_stop_area.id] ).order(:objectid) }
- physical_stop_areas = physical_stop_areas.flatten
-
- city_codes = Hash.new
- commercial_stop_areas.each { |commercial_stop_area| city_codes[commercial_stop_area.zip_code] = commercial_stop_area.city_name if commercial_stop_area.zip_code }
- physical_stop_areas.each { |physical_stop_area| city_codes[physical_stop_area.zip_code] = physical_stop_area.city_name if physical_stop_area.zip_code }
-
- Chouette::Hub::CityCodeExporter.save(city_codes, temp_dir, hub_export)
- Chouette::Hub::CommercialStopAreaExporter.save(commercial_stop_areas, temp_dir, hub_export)
- Chouette::Hub::PhysicalStopAreaExporter.save(physical_stop_areas, temp_dir, hub_export)
-
- connection_links = Chouette::ConnectionLink.where( "departure_id IN (?) AND arrival_id IN (?)", (physical_stop_areas.map(&:id) + commercial_stop_areas.map(&:id)), (physical_stop_areas.map(&:id) + commercial_stop_areas.map(&:id)) ).order(:id)
-
- Chouette::Hub::ConnectionLinkExporter.save(connection_links, temp_dir, hub_export)
+ if journey_patterns_exportable?
+ Chouette::Hub::RouteExporter.save(@routes, temp_dir, hub_export)
+ Chouette::Hub::ItlExporter.save(@routes, temp_dir, hub_export)
+ Chouette::Hub::JourneyPatternExporter.save(@journey_patterns, temp_dir, hub_export)
+ Chouette::Hub::DirectionExporter.save(@journey_patterns, temp_dir, hub_export)
+ else
+ log_overflow_warning(Chouette::JourneyPattern) if routes_exportable?
+ end
+
+ if vehicle_journeys_exportable?
+ Chouette::Hub::VehicleJourneyExporter.save(@vehicle_journeys, temp_dir, hub_export)
+ Chouette::Hub::VehicleJourneyOperationExporter.save(@vehicle_journeys, temp_dir, hub_export)
+ Chouette::Hub::VehicleJourneyAtStopExporter.save(@vehicle_journeys, temp_dir, hub_export, vehicle_journey_at_stops.count)
+ else
+ log_overflow_warning(Chouette::VehicleJourney)
+ end
- if lines_exportable?
- Chouette::Hub::LineExporter.save(@lines, temp_dir, hub_export)
+ stop_points = Chouette::StopPoint.where( :id => vehicle_journey_at_stops.map(&:stop_point_id)) #.order(:id)
+ physical_stop_areas = Chouette::StopArea.where( :id => stop_points.map(&:stop_area_id)) #.order(:parent_id)
+ commercial_stop_areas = Chouette::StopArea.where( :id => physical_stop_areas.map(&:parent_id)).order(:objectid)
- transport_modes = Hash.new
- @lines.each do |l|
- if l.transport_mode_name
- case l.transport_mode_name
- when "Coach"
- if transport_modes["CAR"]
- transport_modes["CAR"] += "|"+l.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2')
- else
- transport_modes["CAR"] = l.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2')
- end
- when "Bus"
- if transport_modes["BUS"]
- transport_modes["BUS"] += "|"+l.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2')
- else
- transport_modes["BUS"] = l.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2')
+ physical_stop_areas = []
+ commercial_stop_areas.each { |commercial_stop_area| physical_stop_areas << Chouette::StopArea.where( :parent_id => [commercial_stop_area.id] ).order(:objectid) }
+ physical_stop_areas = physical_stop_areas.flatten
+
+ city_codes = Hash.new
+ commercial_stop_areas.each { |commercial_stop_area| city_codes[commercial_stop_area.zip_code] = commercial_stop_area.city_name if commercial_stop_area.zip_code }
+ physical_stop_areas.each { |physical_stop_area| city_codes[physical_stop_area.zip_code] = physical_stop_area.city_name if physical_stop_area.zip_code }
+
+ Chouette::Hub::CityCodeExporter.save(city_codes, temp_dir, hub_export)
+ Chouette::Hub::CommercialStopAreaExporter.save(commercial_stop_areas, temp_dir, hub_export)
+ Chouette::Hub::PhysicalStopAreaExporter.save(physical_stop_areas, temp_dir, hub_export)
+
+ connection_links = Chouette::ConnectionLink.where( "departure_id IN (?) AND arrival_id IN (?)", (physical_stop_areas.map(&:id) + commercial_stop_areas.map(&:id)), (physical_stop_areas.map(&:id) + commercial_stop_areas.map(&:id)) ).order(:id)
+
+ Chouette::Hub::ConnectionLinkExporter.save(connection_links, temp_dir, hub_export)
+
+ if lines_exportable?
+ Chouette::Hub::LineExporter.save(@lines, temp_dir, hub_export)
+ transport_modes = Hash.new
+ @lines.each do |l|
+ if l.transport_mode_name
+ case l.transport_mode_name
+ when "Coach"
+ if transport_modes["CAR"]
+ transport_modes["CAR"] += "|"+l.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2')
+ else
+ transport_modes["CAR"] = l.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2')
+ end
+ when "Bus"
+ if transport_modes["BUS"]
+ transport_modes["BUS"] += "|"+l.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2')
+ else
+ transport_modes["BUS"] = l.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2')
+ end
end
end
end
+ Chouette::Hub::TransportModeExporter.save(transport_modes, temp_dir, hub_export)
+ networks = Chouette::Network.where( :id => @lines.map(&:network_id))
+ companies = Chouette::Company.where( :id => @lines.map(&:company_id))
+ groups_of_lines = []
+ @lines.each { |l| groups_of_lines << l.group_of_lines }
+ groups_of_lines = groups_of_lines.flatten.uniq
+ Chouette::Hub::GroupOfLinesExporter.save(groups_of_lines, temp_dir, hub_export)
+ Chouette::Hub::NetworkExporter.save(networks, temp_dir, hub_export)
+ Chouette::Hub::CompanyExporter.save(companies, temp_dir, hub_export)
+ else
+ log_overflow_warning(Chouette::Line)
end
- Chouette::Hub::TransportModeExporter.save(transport_modes, temp_dir, hub_export)
- networks = Chouette::Network.where( :id => @lines.map(&:network_id))
- companies = Chouette::Company.where( :id => @lines.map(&:company_id))
- groups_of_lines = []
- @lines.each { |l| groups_of_lines << l.group_of_lines }
- groups_of_lines = groups_of_lines.flatten.uniq
- Chouette::Hub::GroupOfLinesExporter.save(groups_of_lines, temp_dir, hub_export)
- Chouette::Hub::NetworkExporter.save(networks, temp_dir, hub_export)
- Chouette::Hub::CompanyExporter.save(companies, temp_dir, hub_export)
- else
- log_overflow_warning(Chouette::Line)
- end
-
- #if routes_exportable?
- # Chouette::Hub::RouteExporter.save( routes, temp_dir, hub_export)
- #else
- # log_overflow_warning(Chouette::Route) if lines_exportable?
- #end
-
- # if too many lines
- # there may be too many stop_areas
- if lines_exportable?
- stop_areas = Chouette::StopArea.joins( :stop_points => [:route => :line]).where(:lines => {:id => lines.map(&:id)}).uniq.order(:name)
- #Chouette::Hub::StopAreaExporter.save( stop_areas, temp_dir, hub_export, "Quay")
-
- commercial_stop_areas = Chouette::StopArea.where( :id => stop_areas.map(&:parent_id).compact.uniq).order(:name)
- #Chouette::Hub::StopAreaExporter.save( commercial_stop_areas, temp_dir, hub_export, "CommercialStopPoint")
- end
-
- if( options[:o] == "line" and not options[:id].present?) # Add all objects
- stop_places = referential.stop_areas.stop_place.order(:name)
- #Chouette::Hub::StopAreaExporter.save( stop_places, temp_dir, hub_export, "StopPlace")
-
- itls = referential.stop_areas.itl.order(:name)
- #Chouette::Hub::StopAreaExporter.save( itls, temp_dir, hub_export, "ITL")
-
- connection_links = referential.connection_links.order(:name)
- #Chouette::Hub::ConnectionLinkExporter.save( connection_links, temp_dir, hub_export)
-
- access_links = referential.access_links.order(:name)
- #Chouette::Hub::AccessLinkExporter.save(access_links, temp_dir, hub_export)
-
- access_points = referential.access_points.order(:name)
- #Chouette::Hub::AccessPointExporter.save(access_points, temp_dir, hub_export)
-
- end
-
- ::Zip::File.open(zip_file_path, ::Zip::File::CREATE) do |zipfile|
- Dir[File.join(temp_dir, '*.TXT')].each do |f|
- #Rails.logger.error("Adding File #{File.basename(f)}")
- zipfile.add(File.basename(f), f)
+
+ if lines_exportable?
+ stop_areas = Chouette::StopArea.joins( :stop_points => [:route => :line]).where(:lines => {:id => lines.map(&:id)}).uniq.order(:name)
+ commercial_stop_areas = Chouette::StopArea.where( :id => stop_areas.map(&:parent_id).compact.uniq).order(:name)
end
- end
- }
+
+ ::Zip::File.open(zip_file_path, ::Zip::File::CREATE) do |zipfile|
+ Dir[File.join(temp_dir, '*.TXT')].each do |f|
+ #Rails.logger.error("Adding File #{File.basename(f)}")
+ zipfile.add(File.basename(f), f)
+ end
+ end
+ }
end
ensure
# Always cleanup files
@@ -253,4 +216,3 @@ class Chouette::Hub::Exporter
end
end
-
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/itl_exporter.rb b/app/exporters/chouette/hub/itl_exporter.rb
new file mode 100644
index 000000000..8c281d965
--- /dev/null
+++ b/app/exporters/chouette/hub/itl_exporter.rb
@@ -0,0 +1,65 @@
+class Chouette::Hub::ItlExporter
+ include ERB::Util
+ attr_accessor :stop_point, :stop_area_id, :stop_area_code, :line_code, :sens, :order, :type, :identifier, :directory, :template
+
+ def initialize(stop_point, sens, line, directory, index)
+ @stop_point = stop_point
+ @directory = directory
+ @template = File.open('app/views/api/hub/itls.hub.erb' ){ |f| f.read }
+ @line_code = line.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2') if line
+ @sens = sens == 'A' ? 1 : 2
+ stop_area = stop_point.stop_area
+ if stop_area
+ @stop_area_code = stop_area.objectid.sub(/(\w*\:\w*\:)(\w*)/, '\2')
+ @stop_area_id = stop_area.registration_number
+ end
+ @order = stop_point.position
+ if stop_point.for_boarding == "forbidden"
+ @type = 1
+ elsif stop_point.for_alighting == "forbidden"
+ @type = 2
+ end
+ @identifier = index
+ end
+
+ def render()
+ ERB.new(@template).result(binding)
+ end
+
+ def hub_name
+ "/ITL.TXT"
+ end
+
+ def self.save( routes, directory, hub_export)
+ count = 0
+ routes.each do |route|
+ for_boarding_stops = route.stop_points.where( :for_boarding => [ "forbidden" , "normal"] ).order(:position)
+ if for_boarding_stops
+ for_boarding_stops.each do |stop_point|
+ count += 1
+ self.new( stop_point, route.wayback, route.line, directory, count ).tap do |specific_exporter|
+ specific_exporter.save
+ end
+ end
+ end
+ for_alighting_stops = route.stop_points.where( :for_alighting => [ "forbidden" , "normal"] ).order(:position)
+ if for_alighting_stops
+ for_alighting_stops.each do |stop_point|
+ count += 1
+ self.new( stop_point, route.wayback, route.line, directory, count ).tap do |specific_exporter|
+ specific_exporter.save
+ end
+ end
+ end
+ end
+ hub_export.log_messages.create( :severity => "ok", :key => "EXPORT|ITL_COUNT", :arguments => {"0" => count})
+ end
+
+ def save
+ File.open(directory + hub_name , "a:Windows_1252") do |f|
+ f.write("ITL\u000D\u000A") if f.size == 0
+ f.write(render)
+ end if stop_point.present?
+ end
+end
+
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/helpers/routes_helper.rb b/app/helpers/routes_helper.rb
index bbb611506..b3d79262e 100644
--- a/app/helpers/routes_helper.rb
+++ b/app/helpers/routes_helper.rb
@@ -14,4 +14,3 @@ module RoutesHelper
end
end
-
diff --git a/app/helpers/rule_parameter_sets_helper.rb b/app/helpers/rule_parameter_sets_helper.rb
new file mode 100644
index 000000000..8485b63ca
--- /dev/null
+++ b/app/helpers/rule_parameter_sets_helper.rb
@@ -0,0 +1,18 @@
+module RuleParameterSetsHelper
+
+ def unique( value)
+ return t("true") if value == "1"
+ t "false"
+ end
+
+ def pattern(value)
+ return t("rule_parameter_sets.labels.free_char") if value == "0"
+ return t("rule_parameter_sets.labels.num_char") if value == "1"
+ return t("rule_parameter_sets.labels.alpha_char") if value == "2"
+ return t("rule_parameter_sets.labels.upper_char") if value == "3"
+ return t("rule_parameter_sets.labels.lower_char") if value == "4"
+ end
+
+end
+
+
diff --git a/app/helpers/stop_areas_helper.rb b/app/helpers/stop_areas_helper.rb
index e287af7f3..ce0dab85a 100644
--- a/app/helpers/stop_areas_helper.rb
+++ b/app/helpers/stop_areas_helper.rb
@@ -1,4 +1,16 @@
module StopAreasHelper
+ def explicit_name(stop_area)
+ name = localization = ""
+
+ name += truncate(stop_area.name, :length => 30) || ""
+ name += (" <small>["+ ( truncate(stop_area.registration_number, :length => 10) || "") + "]</small>") if stop_area.registration_number
+
+ localization += stop_area.zip_code || ""
+ localization += ( truncate(stop_area.city_name, :length => 15) ) if stop_area.city_name
+
+ ( "#{image_tag( stop_area_picture_url(stop_area)) }" + " <span style='height:25px; line-height:25px; margin-left: 5px; '>" + name + " <small style='height:25px; line-height:25px; margin-left: 10px; color: #555;'>" + localization + "</small></span>").html_safe
+ end
+
def genealogical_title
return t(".stop_areas.genealogical.genealogical_routing") if @stop_area.stop_area_type == 'itl'
t("stop_areas.genealogical.genealogical")
diff --git a/app/helpers/time_tables_helper.rb b/app/helpers/time_tables_helper.rb
index e0c1fc2db..9fdb791b1 100644
--- a/app/helpers/time_tables_helper.rb
+++ b/app/helpers/time_tables_helper.rb
@@ -1,57 +1,3 @@
module TimeTablesHelper
- def time_table_state_code(time_table)
- if time_table.validity_out_from_on?(Date.today)
- "validity_out"
- elsif time_table.validity_out_between?(Date.today,Date.today+7.day)
- "validity_out_soon"
- else
- "validity_regular"
- end
- end
- def tag_list_shortened(time_table)
- time_table.tags.join(', ').truncate(30, separator: ',')
- end
- def bounding_info(time_table)
- return t('time_tables.time_table.empty') if time_table.bounding_dates.empty?
- t('time_tables.time_table.bounding',
- :start => l(time_table.bounding_dates.min),
- :end => l(time_table.bounding_dates.max))
- end
- def bounding_short_info(dates)
- return t('time_tables.time_table.empty') if dates.empty?
- "#{l(dates.min)} #{l(dates.max)}"
- end
- def time_table_bounding( time_table)
- bounding_short_info( time_table.bounding_dates)
- end
- def time_tables_shortest_info( vehicle)
- bounding_short_info( vehicle.bounding_dates)
- end
- def time_tables_info( vehicle)
- vehicle.time_tables.map do |time_table|
- "#{time_table_bounding( time_table)} - #{composition_info(time_table)}"
- end.join( "\n")
- end
-
- def composition_info(time_table)
- return if time_table.bounding_dates.empty?
- if time_table.dates.empty?
- t('time_tables.time_table.periods_count', :count => time_table.periods.count)
- elsif time_table.periods.empty?
- t('time_tables.time_table.dates_count', :count => time_table.dates.count)
- else
- t('time_tables.time_table.periods_dates_count',
- :dates_count => time_table.dates.count,
- :periods_count => time_table.periods.count)
- end
- end
-
- def time_table_description(time_table)
- if time_table.bounding_dates.empty?
- "#{time_table.comment} (vide)"
- else
- "#{time_table.comment} : #{time_table_bounding( time_table)} - #{composition_info(time_table)}"
- end
- end
end
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index a4347bd18..ea5f41fb7 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -1,7 +1,7 @@
module UsersHelper
def user_gravatar_image_tag(user, size = 64)
- gravatar_image_tag user.email, :alt => "", :class => "preview", :gravatar => { :default => user_default_avatar , :size => size }
+ image_tag user_image(user), :alt => "", :class => "preview", :width => size, :height => size
end
def user_default_avatar
diff --git a/app/inputs/search_time_table_input.rb b/app/inputs/search_time_table_input.rb
index 877333592..c64280e6d 100644
--- a/app/inputs/search_time_table_input.rb
+++ b/app/inputs/search_time_table_input.rb
@@ -25,12 +25,11 @@ class SearchTimeTableInput < Formtastic::Inputs::SearchInput
minChars: 2,
propertyToSearch: 'comment',
preventDuplicates: true,
- queryParam: 'q[comment_cont]',
hintText: '#{options[:hint_text]}',
noResultsText: '#{options[:no_result_text]}',
searchingText: '#{options[:searching_text]}',
resultsFormatter: time_table_formatter,
- tokenFormatter: time_table_formatter,
+ tokenFormatter: time_table_formatter,
});
});").html_safe)
end
@@ -49,7 +48,7 @@ class SearchTimeTableInput < Formtastic::Inputs::SearchInput
:required => nil,
:autofocus => nil,
:class => 'token-input',
- 'data-model-name' => object.class.model_name.human
+ 'data-model-name' => object.class.model_name.human
})
end
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..9828cffc4
--- /dev/null
+++ b/app/models/compliance_check_task_export.rb
@@ -0,0 +1,52 @@
+require 'tempfile'
+
+class ComplianceCheckTaskExport
+ include ERB::Util
+
+ require 'zip'
+
+ attr_accessor :template, :detailed_errors_template, :request
+ attr_reader :compliance_check_task
+
+ def initialize(compliance_check_task, request)
+ @request = request
+ @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("#{I18n.t('compliance_check_results.file.zip_name_prefix')}_#{@compliance_check_task.referential_id}_#{@compliance_check_task.id}_", Dir.tmpdir) { |temp_dir|
+
+ File.open(temp_dir + "/#{I18n.t('compliance_check_results.file.summary_errors_file_prefix')}" , "a") do |f|
+ f.write(render)
+ f.flush
+ end
+
+ File.open(temp_dir + "/#{I18n.t('compliance_check_results.file.detailed_errors_file_prefix')}" , "a") do |f|
+ f.write(detailed_errors_render)
+ f.flush
+ end
+
+ zip_file = Tempfile.new(["#{I18n.t('compliance_check_results.file.zip_name_prefix')}_#{@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/models/referential.rb b/app/models/referential.rb
index 41d239961..063e7436c 100644
--- a/app/models/referential.rb
+++ b/app/models/referential.rb
@@ -191,11 +191,13 @@ class Referential < ActiveRecord::Base
GeoRuby::SimpleFeatures::Geometry.from_ewkt(bounds.present? ? bounds : default_bounds ).envelope
end
-end
-
+ ##
+ # In Development environment where cache_classes = false
+ # each time a controller rb file is saved
+ # ninoxe models are reloaded without after_initialize from config/initializers
+ # so for development confort, it's better to keep here that after_initialize
Rails.application.config.after_initialize do
-
Chouette::TridentActiveRecord
class Chouette::TridentActiveRecord
@@ -212,11 +214,27 @@ Rails.application.config.after_initialize do
end
+ Chouette::TimeTable
+
+ class Chouette::TimeTable
+ def presenter
+ @presenter ||= ::TimeTablePresenter.new( self)
+ end
+ end
+
+ Chouette::VehicleJourney
+
+ class Chouette::VehicleJourney
+ def presenter
+ @presenter ||= ::VehicleJourneyPresenter.new( self)
+ end
+ end
+
Chouette::StopArea
class Chouette::StopArea
- attr_accessible :projection_x,:projection_y,:projection_xy
+ include NinoxeExtension::ProjectionFields
# override default_position method to add referential envelope when no stoparea is positioned
def default_position
@@ -224,118 +242,16 @@ Rails.application.config.after_initialize do
Chouette::StopArea.bounds ? Chouette::StopArea.bounds.center : self.referential.envelope.center
end
- # add projection_type set on pre-insert and pre_update action
- before_save :set_projections
- def set_projections
- if ! self.coordinates.blank?
- self.long_lat_type = 'WGS84'
- else
- self.long_lat_type = nil
- end
- end
-
- def projection
- if self.referential.projection_type.nil? || self.referential.projection_type.empty?
- nil
- else
- self.referential.projection_type
- end
- end
- @point = nil
-
- def projection_x
- if self.long_lat_type.nil? || self.projection.nil?
- nil
- else
- @point ||= GeoRuby::SimpleFeatures::Point::from_lat_lng(Geokit::LatLng.new(self.latitude,self.longitude)).project_to(self.projection.to_i)
- @point.x
- end
- end
- def projection_y
- if self.long_lat_type.nil? || self.projection.nil?
- nil
- else
- @point ||= GeoRuby::SimpleFeatures::Point::from_lat_lng(Geokit::LatLng.new(self.latitude,self.longitude)).project_to(self.projection.to_i)
- @point.y
- end
- end
- def projection_xy
- if self.long_lat_type.nil? || self.projection.nil?
- nil
- else
- @point ||= GeoRuby::SimpleFeatures::Point::from_lat_lng(Geokit::LatLng.new(self.latitude,self.longitude)).project_to(self.projection.to_i)
- @point.x.to_s+","+@point.y.to_s
- end
- end
- def projection_x=(dummy)
- # dummy method
- end
- def projection_y=(dummy)
- # dummy method
- end
- def projection_xy=(dummy)
- # dummy method
- end
end
Chouette::AccessPoint
class Chouette::AccessPoint
- attr_accessible :projection_x,:projection_y,:projection_xy
-
- # add projection_type set on pre-insert and pre_update action
- before_save :set_projections
- def set_projections
- if ! self.coordinates.blank?
- self.long_lat_type = 'WGS84'
- else
- self.long_lat_type = nil
- end
- end
-
- def projection
- if self.referential.projection_type.nil? || self.referential.projection_type.empty?
- nil
- else
- self.referential.projection_type
- end
- end
- @point = nil
-
- def projection_x
- if self.long_lat_type.nil? || self.projection.nil?
- nil
- else
- @point ||= GeoRuby::SimpleFeatures::Point::from_lat_lng(Geokit::LatLng.new(self.latitude,self.longitude)).project_to(self.projection.to_i)
- @point.x
- end
- end
- def projection_y
- if self.long_lat_type.nil? || self.projection.nil?
- nil
- else
- @point ||= GeoRuby::SimpleFeatures::Point::from_lat_lng(Geokit::LatLng.new(self.latitude,self.longitude)).project_to(self.projection.to_i)
- @point.y
- end
- end
- def projection_xy
- if self.long_lat_type.nil? || self.projection.nil?
- nil
- else
- @point ||= GeoRuby::SimpleFeatures::Point::from_lat_lng(Geokit::LatLng.new(self.latitude,self.longitude)).project_to(self.projection.to_i)
- @point.x.to_s+","+@point.y.to_s
- end
- end
- def projection_x=(dummy)
- # dummy method
- end
- def projection_y=(dummy)
- # dummy method
- end
- def projection_xy=(dummy)
- # dummy method
- end
+ include NinoxeExtension::ProjectionFields
end
end
+end
+
+
diff --git a/app/models/rule_parameter_set.rb b/app/models/rule_parameter_set.rb
index 0c7a98300..01c2e48a6 100644
--- a/app/models/rule_parameter_set.rb
+++ b/app/models/rule_parameter_set.rb
@@ -16,8 +16,43 @@ class RuleParameterSet < ActiveRecord::Base
inter_connection_link_distance_max walk_default_speed_max
walk_occasional_traveller_speed_max walk_frequent_traveller_speed_max walk_mobility_restricted_traveller_speed_max
inter_access_link_distance_max inter_stop_duration_max facility_stop_area_distance_max
- vehicle_journey_number_max vehicle_journey_number_min check_allowed_transport_modes)
+ check_allowed_transport_modes check_lines_in_groups check_line_routes
+ check_stop_parent check_connection_link_on_physical)
end
+
+ def self.validable_objects
+ [Chouette::Network,Chouette::Company,Chouette::GroupOfLine,
+ Chouette::StopArea,Chouette::AccessPoint,Chouette::AccessLink,Chouette::ConnectionLink,
+ Chouette::TimeTable,Chouette::Line,Chouette::Route,
+ Chouette::JourneyPattern,Chouette::VehicleJourney]
+ end
+
+ def self.validable_object_names
+ ["network","company","group_of_line",
+ "stop_area","access_point","access_link","connection_link",
+ "time_table","line","route",
+ "journey_pattern","vehicle_journey"]
+ end
+
+ def self.validable_columns
+ {"network" => ['objectid','name','registration_number'],
+ "company" => ['objectid','name','registration_number'],
+ "group_of_line" => ['objectid','name','registration_number'],
+ "stop_area" => ['objectid','name','registration_number','city_name','country_code','zip_code'],
+ "access_point" => ['objectid','name','city_name','country_code','zip_code'],
+ "access_link" => ['objectid','name','link_distance','default_duration'],
+ "connection_link" => ['objectid','name','link_distance','default_duration'],
+ "time_table" => ['objectid','comment','version'],
+ "line" => ['objectid','name','registration_number','number','published_name'],
+ "route" => ['objectid','name','number','published_name'],
+ "journey_pattern" => ['objectid','name','registration_number','published_name'],
+ "vehicle_journey" => ['objectid','published_journey_name','published_journey_identifier','number'] }
+ end
+
+ def self.column_attribute_prefixes
+ %w( unique pattern min_size max_size )
+ end
+
def self.all_modes
Chouette::TransportMode.all.map { |m| m.to_s}
end
@@ -28,6 +63,14 @@ class RuleParameterSet < ActiveRecord::Base
mode_attribute_prefixes.include?( $1) && self.class.all_modes.include?( $2)
end
+
+ def self.column_attribute?( method_name )
+ pattern = /(\w+)_column_(\w+)_object_(\w+)/
+ return false unless method_name.match( pattern)
+ return false unless validable_object_names.include?($3)
+ column_attribute_prefixes.include?( $1) && validable_columns[$3].include?( $2)
+ end
+
def self.mode_of_mode_attribute( method_name )
method_name.match( /(\w+)_mode_(\w+)/)
$2
@@ -37,6 +80,20 @@ class RuleParameterSet < ActiveRecord::Base
$1
end
+ def self.object_of_column_attribute( method_name )
+ method_name.match( /(\w+)_column_(\w+)_object_(\w+)/)
+ $3
+ end
+ def self.column_of_column_attribute( method_name )
+ method_name.match( /(\w+)_column_(\w+)_object_(\w+)/)
+ $2
+ end
+ def self.attribute_of_column_attribute( method_name )
+ method_name.match( /(\w+)_column_(\w+)_object_(\w+)/)
+ $1
+ end
+
+
def self.mode_parameter(name)
name = name.to_s
attr_accessible name
@@ -52,6 +109,37 @@ class RuleParameterSet < ActiveRecord::Base
((self.parameters ||= {})["mode_#{mode}"] ||= {})[attribute_name] = prefix
end
end
+
+ def self.column_parameter(obj,column,prefix)
+ name = "#{prefix}_column_#{column}_object_#{obj}"
+ attr_accessible name
+ define_method(name) do
+ attribute_name, column, obj = prefix, column, obj
+ self.parameters and self.parameters[obj] and
+ self.parameters[obj][column] and self.parameters[obj][column][attribute_name]
+ end
+
+ define_method("#{name}=") do |key|
+ attribute_name, column, obj = prefix, column, obj
+ (((self.parameters ||= {})[obj] ||= {})[column]||= {})[attribute_name] = key
+ end
+
+ end
+
+ def self.object_parameter(clazz)
+ name = clazz.table_name.singularize
+ attr_accessible name
+
+ parameter "check_#{clazz.table_name.singularize}"
+ validable_columns[name].each do |column|
+ column_attribute_prefixes.each do |prefix|
+ column_parameter name,column,prefix
+ end
+
+ end
+
+ end
+
def self.parameter(name)
name = name.to_s
attr_accessible name
@@ -77,7 +165,11 @@ class RuleParameterSet < ActiveRecord::Base
:inter_access_link_distance_max => 300,
:inter_stop_duration_max => 40,
:facility_stop_area_distance_max => 300,
- :check_allowed_transport_modes => false
+ :check_allowed_transport_modes => false,
+ :check_lines_in_groups => false,
+ :check_line_routes => false,
+ :check_stop_parent => false,
+ :check_connection_link_on_physical => false
}
if mode && self.mode_default_params[ mode.to_sym]
base.merge!( self.mode_default_params[ mode.to_sym])
@@ -231,21 +323,41 @@ class RuleParameterSet < ActiveRecord::Base
def allowed(mode)
return true unless self.check_allowed_transport_modes
- puts "#{mode} = "+self.send("allowed_transport_mode_#{mode}").to_s
+ # puts "#{mode} = "+self.send("allowed_transport_mode_#{mode}").to_s
return self.send("allowed_transport_mode_#{mode}") == "1"
end
+
+ def selected(object)
+ # puts "#{mode} = "+self.send("allowed_transport_mode_#{mode}").to_s
+ return self.send("check_#{object}") == "1"
+ end
+
+ def selected_column(object,column)
+ # puts "#{mode} = "+self.send("allowed_transport_mode_#{mode}").to_s
+ return self.send("unique_column_#{column}_object_#{object}") == "1" ||
+ self.send("pattern_column_#{column}_object_#{object}") != "0" ||
+ !self.send("min_size_column_#{column}_object_#{object}").empty? ||
+ !self.send("max_size_column_#{column}_object_#{object}").empty?
+ end
+
all_modes.each do |mode|
mode_attribute_prefixes.each do |prefix|
mode_parameter "#{prefix}_mode_#{mode}".to_sym
end
end
-
+
general_attributes.each do |attribute|
parameter attribute.to_sym
unless attribute == "stop_areas_area" || attribute == "check_allowed_transport_modes"
validates attribute.to_sym, :numericality => true, :allow_nil => true, :allow_blank => true
end
end
+
+
+ validable_objects.each do |obj|
+ object_parameter obj
+ end
+
end
diff --git a/app/presenters/time_table_presenter.rb b/app/presenters/time_table_presenter.rb
new file mode 100644
index 000000000..140087c4f
--- /dev/null
+++ b/app/presenters/time_table_presenter.rb
@@ -0,0 +1,52 @@
+class TimeTablePresenter
+
+ def initialize(time_table)
+ @time_table = time_table
+ end
+
+ def time_table_state_code
+ if @time_table.validity_out_from_on?(Date.today)
+ "validity_out"
+ elsif @time_table.validity_out_between?(Date.today,Date.today+7.day)
+ "validity_out_soon"
+ else
+ "validity_regular"
+ end
+ end
+
+ def tag_list_shortened
+ @time_table.tags.join(', ').truncate(30, separator: ',')
+ end
+
+ def time_table_bounding
+ return I18n.t('time_tables.time_table.empty') if @time_table.bounding_dates.empty?
+ "#{I18n.l(@time_table.bounding_dates.min)} #{I18n.l(@time_table.bounding_dates.max)}"
+ end
+
+ def time_tables_shortest_info
+ return I18n.t('time_tables.time_table.empty') if @time_table.bounding_dates.empty?
+ "#{I18n.l(@time_table.bounding_dates.min)} #{I18n.l(@time_table.bounding_dates.max)}"
+ end
+
+ def composition_info
+ return if @time_table.bounding_dates.empty?
+ if @time_table.dates.empty?
+ I18n.t('time_tables.time_table.periods_count', :count => @time_table.periods.count)
+ elsif @time_table.periods.empty?
+ I18n.t('time_tables.time_table.dates_count', :count => @time_table.dates.count)
+ else
+ I18n.t('time_tables.time_table.periods_dates_count',
+ :dates_count => @time_table.dates.count,
+ :periods_count => @time_table.periods.count)
+ end
+ end
+
+private
+ def bounding_info
+ return I18n.t('time_tables.time_table.empty') if @time_table.bounding_dates.empty?
+ I18n.t('time_tables.time_table.bounding',
+ :start => l(@time_table.bounding_dates.min),
+ :end => l(@time_table.bounding_dates.max))
+ end
+
+end
diff --git a/app/presenters/vehicle_journey_presenter.rb b/app/presenters/vehicle_journey_presenter.rb
new file mode 100644
index 000000000..b244946db
--- /dev/null
+++ b/app/presenters/vehicle_journey_presenter.rb
@@ -0,0 +1,11 @@
+class VehicleJourneyPresenter
+
+ def initialize(vehicle_journey)
+ @vehicle_journey = vehicle_journey
+ end
+
+ def time_tables_shortest_info
+ return I18n.t('time_tables.time_table.empty') if @vehicle_journey.bounding_dates.empty?
+ "#{I18n.l(@vehicle_journey.bounding_dates.min)} #{I18n.l(@vehicle_journey.bounding_dates.max)}"
+ 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/itls.hub.erb b/app/views/api/hub/itls.hub.erb
new file mode 100644
index 000000000..8bf596185
--- /dev/null
+++ b/app/views/api/hub/itls.hub.erb
@@ -0,0 +1 @@
+<%= @line_code %>;<%= @sens %>;<%= @stop_area_code %>;<%= @stop_area_id %>;<%= @order %>;<%= @type %>;<%= @identifier %><%= "\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/autocomplete_time_tables/index.rabl b/app/views/autocomplete_time_tables/index.rabl
new file mode 100644
index 000000000..0389c26b0
--- /dev/null
+++ b/app/views/autocomplete_time_tables/index.rabl
@@ -0,0 +1,10 @@
+collection @time_tables, :object_root => false
+
+node do |time_table|
+ { :id => time_table.id, :comment => time_table.comment,
+ :time_table_bounding => time_table.presenter.time_table_bounding,
+ :composition_info => time_table.presenter.composition_info,
+ :tags => time_table.tags.join(','),
+ :day_types => %w(monday tuesday wednesday thursday friday saturday sunday).select{ |d| time_table.send(d) }.map{ |d| time_table.human_attribute_name(d).first(2)}.join('')}
+end
+
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..339210f92
--- /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(:rule_code) %>;<%= ComplianceCheckResult.human_attribute_name(:object) %>;<%= ComplianceCheckResult.human_attribute_name(:resource) %>;<%= ComplianceCheckResult.human_attribute_name(:detail) %>;
+<% @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.rule_code %>;<% if error["messageArgs"] %><%= error["messageArgs"]["objectId"] %><% end %>;<% if error["location"]["url"].present? %><%= "http://#{request.host}:#{request.port}#{request.fullpath.sub(/(compliance_check_tasks.*)/, '')}" + error["location"]["url"] %><% elsif error["location"]["filename"].present? %><%= error["objectId"] + " - " %><%= File.basename(error["location"]["filename"]) +" - " %><%= I18n.t "compliance_check_results.index.column" %>: <%= error["location"]["columnNumber"] %>, <%= I18n.t "compliance_check_results.index.line" %>: <%= error["location"]["lineNumber"] %><% end %>;<% 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..d41e0da1d 100644
--- a/app/views/compliance_check_tasks/show.html.erb
+++ b/app/views/compliance_check_tasks/show.html.erb
@@ -9,6 +9,14 @@
<% if @compliance_check_task.rule_parameter_set_archived %>
<%= link_to image_tag('icons/link_page.png') + t("compliance_check_tasks.rule_parameter_set"), rule_parameter_set_referential_compliance_check_task_path(@compliance_check_task.referential, @compliance_check_task) %>
<% end %>
+ <div class="btn-group pull-right">
+ <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_task_path(@compliance_check_task.referential, @compliance_check_task) %></li>
+ </ul>
+ </div>
</div>
<% if @compliance_check_task.status == 'completed'%>
<div class="resume">
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..e51ad28c2
--- /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) %>;<%= ComplianceCheckResult.human_attribute_name(:objects) %>
+<% @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 %><% if r.violation_count > 0 %><% if r.detail.present? %>;<% r.detail["detail"].first(10).each do |error| %><% if error["messageArgs"] %><%= error["messageArgs"]["objectId"] + " " %><% else %><%= " " %><% end %><% end %><% end %><% end %>
+<% end %> \ No newline at end of file
diff --git a/app/views/connection_links/show.html.erb b/app/views/connection_links/show.html.erb
index 58649d245..0771caac4 100644
--- a/app/views/connection_links/show.html.erb
+++ b/app/views/connection_links/show.html.erb
@@ -22,7 +22,11 @@
</p>
<p>
<label><%= @connection_link.human_attribute_name("connection_link_type") %>: </label>
- <%= t("connection_link_types.label.#{@connection_link.connection_link_type}") %>
+ <% if @connection_link.connection_link_type.blank? %>
+ <%= t("connection_link_types.label.undefined") %>
+ <% else %>
+ <%= t("connection_link_types.label.#{@connection_link.connection_link_type}") %>
+ <% end %>
</p>
<p>
<label><%= @connection_link.human_attribute_name("comment") %>: </label>
diff --git a/app/views/devise/invitations/edit.html.erb b/app/views/devise/invitations/edit.html.erb
index a03b1ee7e..8835c5773 100644
--- a/app/views/devise/invitations/edit.html.erb
+++ b/app/views/devise/invitations/edit.html.erb
@@ -9,7 +9,7 @@
<%= form.input :password, :as => :password %>
<%= form.input :password_confirmation, :as => :password %>
- <div class="col-md-offset-2">
+ <div class="submit">
<%= form.button :submit, :value => t("devise.invitations.edit.submit_button"), :class => "btn-info" %>
</div>
<% end %>
diff --git a/app/views/devise/invitations/new.html.erb b/app/views/devise/invitations/new.html.erb
index 2232020c9..5567463c8 100644
--- a/app/views/devise/invitations/new.html.erb
+++ b/app/views/devise/invitations/new.html.erb
@@ -9,7 +9,7 @@
<%= form.input field %>
<% end -%>
- <div class="col-md-offset-2">
+ <div class="submit">
<%= form.button :submit, :value => t("devise.invitations.new.submit_button"), :class => "btn-info" %>
</div>
<% end %>
diff --git a/app/views/exports/_fields_hub_export.erb b/app/views/exports/_fields_hub_export.erb
index 8f51c104b..4d6f6f177 100644
--- a/app/views/exports/_fields_hub_export.erb
+++ b/app/views/exports/_fields_hub_export.erb
@@ -1,3 +1,3 @@
-<%= I18n.t("formtastic.titles.export.vjas.size", size: Chouette::VehicleJourneyAtStop.all.count) if Chouette::VehicleJourneyAtStop.all.count > 50000 %>
+<%= I18n.t("formtastic.titles.export.vjas.size", size: Chouette::VehicleJourneyAtStop.count) if Chouette::VehicleJourneyAtStop.count > 50000 %>
<%= form.input :start_date, :as => :date_picker, :input_html => { :title => t("formtastic.titles.export.start_date")} %>
<%= form.input :end_date, :as => :date_picker, :input_html => { :title => t("formtastic.titles.export.end_date")} %>
diff --git a/app/views/group_of_lines/_form.erb b/app/views/group_of_lines/_form.erb
index a0ef4a4c4..9482248b6 100644
--- a/app/views/group_of_lines/_form.erb
+++ b/app/views/group_of_lines/_form.erb
@@ -1,6 +1,7 @@
<%= semantic_form_for [@referential, @group_of_line] do |form| %>
<%= form.inputs do %>
<%= form.input :name %>
+ <%= form.input :registration_number %>
<%= form.input :comment %>
<%= form.input :objectid, :required => !@group_of_line.new_record?, :input_html => { :title => t("formtastic.titles.group_of_line.objectid")} %>
<% end %>
diff --git a/app/views/group_of_lines/show.html.erb b/app/views/group_of_lines/show.html.erb
index 07527f209..3369f284d 100644
--- a/app/views/group_of_lines/show.html.erb
+++ b/app/views/group_of_lines/show.html.erb
@@ -4,6 +4,10 @@
<%= @map.to_html %>
<div class="summary">
<p>
+ <label><%= @group_of_line.human_attribute_name("registration_number") %>: </label>
+ <%= @group_of_line.registration_number %>
+ </p>
+ <p>
<label><%= @group_of_line.human_attribute_name("comment") %>: </label>
<%= @group_of_line.comment %>
</p>
diff --git a/app/views/help/index.textile b/app/views/help/index.textile
index a94fa7f89..19eeb63e2 100644
--- a/app/views/help/index.textile
+++ b/app/views/help/index.textile
@@ -3,7 +3,7 @@ layout: default
title: Chouette v2
---
-Version 2.5.1
+Version 2.5.2
h3. Logiciel libre propriété de :
@@ -24,6 +24,12 @@ A cet égard l'attention de l'utilisateur est attirée sur les risques associé
h3. Notes de version
+h4. Version 2.5.2
+
+* Nouvelles foctionnalités :
+** Ajout des particularités de monté/descente aux arrêts d'une séquence
+** Ajout de tests sur les données pour l'export
+
h4. Version 2.5.1
* Nouvelles foctionnalités :
diff --git a/app/views/help/introduction.textile b/app/views/help/introduction.textile
index 78fdfa561..525ef133c 100644
--- a/app/views/help/introduction.textile
+++ b/app/views/help/introduction.textile
@@ -17,7 +17,7 @@ D'autres utilisateurs potentiels sont également identifiés : services de l'ét
h3. Ce que vous trouverez dans ce manuel
Vous trouverez dans ce document, toutes les informations nécessaires à la prise en main de l’application.
-Le manuel couvre la version 2.5.1.
+Le manuel couvre la version 2.5.2.
diff --git a/app/views/routes/edit_boarding_alighting.html.erb b/app/views/routes/edit_boarding_alighting.html.erb
new file mode 100644
index 000000000..fc3378425
--- /dev/null
+++ b/app/views/routes/edit_boarding_alighting.html.erb
@@ -0,0 +1,27 @@
+<%= title_tag t('routes.edit_boarding_alighting.title', :route => @route.name ) %>
+
+<%= simple_form_for ["save_boarding_alighting", @referential, @line, @route] do |form| %>
+<table class="table table-hover">
+ <thead>
+ <th><%= t(".stop_area_name") %></th>
+ <th><%= t(".for_boarding") %></th>
+ <th><%= t(".for_alighting") %></th>
+ </thead>
+ <tbody>
+ <%= form.simple_fields_for :stop_points do |stop_points_form| %>
+ <tr>
+ <td>
+ <%= explicit_name(stop_points_form.object.stop_area) %>
+ </td>
+ <td><%= stop_points_form.input :for_boarding, :label => false, include_blank: t("simple_form.include_blanks.defaults.for_boarding") %></td>
+ <td><%= stop_points_form.input :for_alighting, :label => false, include_blank: t("simple_form.include_blanks.defaults.for_alighting") %></td>
+ </tr>
+ <% end %>
+ </tbody>
+</table>
+
+ <div class="submit">
+ <%= form.button :submit, :class => "" %>
+ <%= link_to t("cancel"), referential_line_route_path(@referential, @line, @route) %>
+ </div>
+<% end %>
diff --git a/app/views/routes/show.html.erb b/app/views/routes/show.html.erb
index fe1a9c956..e1f59cde9 100644
--- a/app/views/routes/show.html.erb
+++ b/app/views/routes/show.html.erb
@@ -93,18 +93,26 @@
<li><%= link_to t('routes.actions.new'), new_referential_line_route_path(@referential, @line), :class => "add" %></li>
<li><%= link_to t('routes.actions.edit'), edit_referential_line_route_path(@referential, @line, @route), :class => "edit" %></li>
<li><%= link_to t('routes.actions.destroy'), referential_line_route_path(@referential, @line, @route), :method => :delete, :data => {:confirm => t('routes.actions.destroy_confirm')}, :class => "remove" %></li>
-<% if @route.stop_points.size >= 2 %>
+</ul>
+<ul class="actions">
+ <% if @route.stop_points.size >= 2 %>
<li><%= link_to t('journey_patterns.actions.new'), new_referential_line_route_journey_pattern_path(@referential, @line, @route), :class => "add" %></li>
<% end %>
+ <% if @route.stop_points.present? %>
+ <li><%= link_to t('routes.actions.edit_boarding_alighting'), edit_boarding_alighting_referential_line_route_path(@referential, @line, @route), :class => "edit" %></li>
+ <% end %>
<% if @route.journey_patterns.size > 0 %>
<li>
<%= link_to t('vehicle_journeys.actions.index'), [@referential, @line, @route, :vehicle_journeys], :class => "clock" %>
</li>
<% end %>
+</ul>
+
+<ul class="actions">
<li><%= link_to t('vehicle_journey_imports.new.title'), new_referential_line_route_vehicle_journey_import_path( @referential, @line, @route ), :class => "import" %></li>
<li><%= link_to t('vehicle_journey_exports.new.title'), referential_line_route_vehicle_journey_exports_path(@referential, @line, @route, :format => :zip), :class => "export" %></li>
</ul>
- <%= creation_tag(@route) %>
+<%= creation_tag(@route) %>
<% end %>
diff --git a/app/views/rule_parameter_sets/_column_fields.html.erb b/app/views/rule_parameter_sets/_column_fields.html.erb
new file mode 100644
index 000000000..abb2af4a8
--- /dev/null
+++ b/app/views/rule_parameter_sets/_column_fields.html.erb
@@ -0,0 +1,11 @@
+ <td></td>
+ <td><%= t("activerecord.attributes.#{obj.table_name.singularize}.#{column}") %></td>
+ <% suffix = "column_#{column}_object_#{obj.table_name.singularize}"%>
+ <td> <%= f.check_box "unique_#{suffix}".to_sym, :class => "special" %></td>
+ <% if obj.columns_hash[column].type == :string %>
+ <td><%= f.select "pattern_#{suffix}".to_sym, options_for_select([[t("rule_parameter_sets.labels.free_char"), "0"], [t("rule_parameter_sets.labels.num_char"), "1"], [t("rule_parameter_sets.labels.alpha_char"), "2"], [t("rule_parameter_sets.labels.upper_char"), "3"], [t("rule_parameter_sets.labels.lower_char"), "4"]]) %></td>
+ <% else %>
+ <td><%= t "rule_parameter_sets.labels.num_char" %></td>
+ <% end %>
+ <td><%= f.number_field "min_size_#{suffix}".to_sym, :class => "special" %></td>
+ <td><%= f.number_field "max_size_#{suffix}".to_sym, :class => "special" %></td>
diff --git a/app/views/rule_parameter_sets/_form.html.erb b/app/views/rule_parameter_sets/_form.html.erb
index 90d6850fb..905e7f691 100644
--- a/app/views/rule_parameter_sets/_form.html.erb
+++ b/app/views/rule_parameter_sets/_form.html.erb
@@ -17,9 +17,15 @@
<%= form.input :vehicle_journey_number_min, :as => :number %>
<%= form.input :vehicle_journey_number_max, :as => :number %>
+
+ <%= form.input :check_lines_in_groups, :as => :boolean %>
+ <%= form.input :check_line_routes, :as => :boolean %>
+ <%= form.input :check_stop_parent, :as => :boolean %>
+ <%= form.input :check_connection_link_on_physical, :as => :boolean %>
<%= form.input :check_allowed_transport_modes, :as => :boolean %>
<table class="table table-striped table-condensed">
+ <thead>
<tr>
<th><%= t("transport_modes.name") %></th>
<% RuleParameterSet.mode_attribute_prefixes.each do |prefix| %>
@@ -31,12 +37,39 @@
<% end %>
<% end %>
</tr>
+ </thead>
+ <tbody>
<% Chouette::Line.transport_modes.map(&:to_s).each do |mode| %>
<tr>
<%= render :partial => "mode_fields", :locals => { :f => form, :mode => mode} %>
</tr>
<% end %>
+ </tbody>
+ </table>
+
+ <%= t("rule_parameter_sets.labels.columns_restrictions") %>
+ <table class="table table-bordered table-condensed">
+ <% RuleParameterSet.validable_objects.each do |obj| %>
+ <thead>
+ <tr>
+ <th> <%= form.check_box "check_#{obj.table_name.singularize}".to_sym, :class => "special" %> <%= 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| %>
+ <tr class="<%= "columns_for_#{obj.table_name}" %>">
+ <%= render :partial => "column_fields", :locals => { :f => form, :obj => obj, :column => col} %>
+ </tr>
+ <% end %>
+ </tbody>
+ <% end %>
</table>
+
<% end %>
<%= form.actions do %>
diff --git a/app/views/rule_parameter_sets/show.html.erb b/app/views/rule_parameter_sets/show.html.erb
index 66e002b94..810730e50 100644
--- a/app/views/rule_parameter_sets/show.html.erb
+++ b/app/views/rule_parameter_sets/show.html.erb
@@ -68,26 +68,33 @@
<label><%= t(".inter_stop_duration_max") %>: </label>
<%= @rule_parameter_set.inter_stop_duration_max %>
</p>
- <% if @rule_parameter_set.vehicle_journey_number_min.present? && @rule_parameter_set.vehicle_journey_number_max.present? %>
- <div class="attributes_group" >
- <span class="title"><%= t(".vehicle_journey_number_bounds") %></span>
- <div class="columns">
- <div class="two_columns">
- <label><%= t(".min_value") %> : </label>
- <span class="value"><%= @rule_parameter_set.vehicle_journey_number_min %></span>
- </div>
- <div class="two_columns">
- <label><%= t(".max_value") %> : </label>
- <span class="value"><%= @rule_parameter_set.vehicle_journey_number_max %></span>
- </div>
- </div>
- </div>
- <% end %>
+
+ <p>
+ <label><%= RuleParameterSet.human_attribute_name("check_lines_in_groups") %>: </label>
+ <%= @rule_parameter_set.check_lines_in_groups ? t("true") : t("false") %>
+ </p>
+
+ <p>
+ <label><%= RuleParameterSet.human_attribute_name("check_line_routes") %>: </label>
+ <%= @rule_parameter_set.check_line_routes ? t("true") : t("false") %>
+ </p>
+
+ <p>
+ <label><%= RuleParameterSet.human_attribute_name("check_stop_parent") %>: </label>
+ <%= @rule_parameter_set.check_stop_parent ? t("true") : t("false") %>
+ </p>
+
<p>
+ <label><%= RuleParameterSet.human_attribute_name("check_connection_link_on_physical") %>: </label>
+ <%= @rule_parameter_set.check_allowed_transport_modes ? t("true") : t("false") %>
+ </p>
+
+ </p>
<label><%= RuleParameterSet.human_attribute_name("check_allowed_transport_modes") %>: </label>
<%= @rule_parameter_set.check_allowed_transport_modes ? t("true") : t("false") %>
</p>
+
<div class="rule_parameter_by_mode">
<label><%= t(".rule_parameter_by_mode") %>
<%= t(".modes_allowed") if @rule_parameter_set.check_allowed_transport_modes %>
@@ -116,6 +123,40 @@
<% 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/time_table_combinations/_combine_form.html.erb b/app/views/time_table_combinations/_combine_form.html.erb
index aad31a218..dd9cd9b92 100644
--- a/app/views/time_table_combinations/_combine_form.html.erb
+++ b/app/views/time_table_combinations/_combine_form.html.erb
@@ -3,7 +3,7 @@
<%= render "shared/flash_messages" %>
<%= form.inputs do %>
<%= form.input :operation, :as => :radio, :collection => Hash[TimeTableCombination.operations.map {|b| [t( b, :scope => "time_table_combinations.operations"),b]}] %>
- <%= form.input :combined_id, :label => t('.time_tables'), :as => :search_time_table, :json => referential_time_tables_path(@referential, :format => :json), :hint_text => t('search_hint'), :no_result_text => t('no_result_text'), :searching_text => t('searching_term'), :tokenLimit => 1 %>
+ <%= form.input :combined_id, :label => t('.time_tables'), :as => :search_time_table, :json => referential_autocomplete_time_tables_path(@referential, :format => :json), :hint_text => t('search_hint'), :no_result_text => t('no_result_text'), :searching_text => t('searching_term'), :tokenLimit => 1 %>
<% end %>
</div>
<div class="modal-footer">
diff --git a/app/views/time_tables/_properties_show.html.erb b/app/views/time_tables/_properties_show.html.erb
new file mode 100644
index 000000000..bc2f88ddf
--- /dev/null
+++ b/app/views/time_tables/_properties_show.html.erb
@@ -0,0 +1,127 @@
+<div class="time_table_show">
+
+ <div class="resume">
+ <div class="validity <%= time_table_state_code(@time_table) %>"></div>
+ <label>
+ <% if @time_table.bounding_dates.empty? %>
+ <%= t(".resume_empty") %>
+ <% else %>
+ <%= t(".resume", :start_date => l(@time_table.bounding_dates.min),
+ :end_date => l(@time_table.bounding_dates.max)) %>
+ <% end %>
+ </label>
+ </div>
+ <div class="summary">
+ <p>
+ <label><%= @time_table.human_attribute_name("version") %>: </label>
+ <%= @time_table.version %>
+ </p>
+ <p>
+ <label><%= @time_table.human_attribute_name("tag_list") %>: </label>
+ <%= @time_table.tag_list %>
+ </p>
+ <p>
+ <label><%= @time_table.human_attribute_name("day_types") %>:&nbsp;&nbsp;</label>
+ <% if @time_table.int_day_types & 508 == 0 %>
+ <label><%= @time_table.human_attribute_name("none") %></label>
+ <% else %>
+ <% if @time_table.monday %>
+ <span class='day_type'>&nbsp;<%= @time_table.human_attribute_name("monday") %>&nbsp;</span>
+ <% end %>
+
+ <% if @time_table.tuesday %>
+ <span class='day_type'>&nbsp;<%= @time_table.human_attribute_name("tuesday") %>&nbsp;</span>
+ <% end %>
+
+ <% if @time_table.wednesday %>
+ <span class='day_type'>&nbsp;<%= @time_table.human_attribute_name("wednesday") %>&nbsp;</span>
+ <% end %>
+
+ <% if @time_table.thursday %>
+ <span class='day_type'>&nbsp;<%= @time_table.human_attribute_name("thursday") %>&nbsp;</span>
+ <% end %>
+
+ <% if @time_table.friday %>
+ <span class='day_type'>&nbsp;<%= @time_table.human_attribute_name("friday") %>&nbsp;</span>
+ <% end %>
+
+ <% if @time_table.saturday %>
+ <span class='day_type'>&nbsp;<%= @time_table.human_attribute_name("saturday") %>&nbsp;</span>
+ <% end %>
+
+ <% if @time_table.sunday %>
+ <span class='day_type'>&nbsp;<%= @time_table.human_attribute_name("sunday") %>&nbsp;</span>
+ <% end %>
+ <% end %>
+ </p>
+
+ <h3 class="time_table_calendars">
+ <a class="calendars"><%= @time_table.human_attribute_name("calendars") %>
+ <%= image_tag("icons/plus.png" , :class => "switcher", :style => "display: none;") %>
+ <%= image_tag("icons/minus.png" , :class => "switcher" ) %>
+ </a>
+
+ </h3>
+ <div class="calendars content">
+ <div class="year_choice">
+ <span class="previous"> <%= link_to("<", referential_time_table_path(@referential, @time_table, :year => (@year - 1)) ) %> </span>
+ <span class="year"> <%= "#{@year}" %> </span>
+ <span class="next"> <%= link_to(">", referential_time_table_path(@referential, @time_table, :year => (@year + 1)) ) %> </span>
+ </div>
+ <div class="calendar_helper">
+ <%= cal = ""
+ (1..12).each do |month|
+ cal << calendar(:year => @year, :month => month, :first_day_of_week => 1) do |d|
+ if @time_table.excluded_date?(d)
+ [link_to(d.mday, edit_referential_time_table_path(@referential, @time_table) ), {:class => "excluded_date"}]
+ elsif @time_table.include_in_overlap_dates?(d)
+ [link_to(d.mday, edit_referential_time_table_path(@referential, @time_table) ), {:class => "overlap_date"}]
+ elsif @time_table.include_in_dates?(d)
+ [link_to(d.mday, edit_referential_time_table_path(@referential, @time_table) ), {:class => "selected_date"}]
+ elsif @time_table.include_in_periods?(d)
+ [link_to(d.mday, edit_referential_time_table_path(@referential, @time_table) ), {:class => "selected_period"}]
+ end
+ end
+ end
+ cal.html_safe
+ %>
+ </div>
+ </div>
+
+
+ </div>
+ <h3 class="time_table_periods">
+ <a class="periods"><%= @time_table.human_attribute_name("periods") %>
+ <%= image_tag("icons/plus.png" , :class => "switcher", :style => "display: none;") %>
+ <%= image_tag("icons/minus.png" , :class => "switcher" ) %>
+ </a>
+
+ </h3>
+ <div class="periods content">
+ <%= render "time_tables/periods" %>
+ </div>
+
+ <h3 class="time_table_dates">
+ <a class="dates"><%= @time_table.human_attribute_name("dates") %>
+ <%= image_tag("icons/plus.png" , :class => "switcher", :style => "display: none;") %>
+ <%= image_tag("icons/minus.png" , :class => "switcher" ) %>
+ </a>
+ </h3>
+
+ <div class="dates content">
+ <%= render "time_tables/dates" %>
+ </div>
+
+ <h3 class="time_table_dates">
+ <a class="excluded_dates"><%= @time_table.human_attribute_name("excluded_dates") %>
+ <%= image_tag("icons/plus.png" , :class => "switcher", :style => "display: none;") %>
+ <%= image_tag("icons/minus.png" , :class => "switcher" ) %>
+ </a>
+ </h3>
+
+ <div class="excluded_dates content">
+ <%= render "time_tables/excluded_dates" %>
+ </div>
+
+</div>
+
diff --git a/app/views/time_tables/_show_time_table.html.erb b/app/views/time_tables/_show_time_table.html.erb
index a439aed1b..c48b93470 100644
--- a/app/views/time_tables/_show_time_table.html.erb
+++ b/app/views/time_tables/_show_time_table.html.erb
@@ -1,6 +1,6 @@
<div class="time_table_show" id="time_table_show">
<p>
- <span class="state-code <%= time_table_state_code(@time_table) %>"><i class="fa fa-certificate"></i></span>
+ <span class="state-code <%= @time_table.presenter.time_table_state_code %>"><i class="fa fa-certificate"></i></span>
<label>
<% if @time_table.bounding_dates.empty? %>
<%= t(".resume_empty") %>
@@ -53,7 +53,7 @@
</div>
</div>
<div class="tab-pane" id="time_tables_datas">
- <div class="summary">
+ <div class="summary">
<p>
<label><%= @time_table.human_attribute_name("version") %>: </label>
<%= @time_table.version %>
@@ -62,15 +62,15 @@
<label><%= @time_table.human_attribute_name("day_types") %>:&nbsp;&nbsp;</label>
<% if @time_table.int_day_types & 508 == 0 %>
<label><%= @time_table.human_attribute_name("none") %></label>
- <% else %>
+ <% else %>
<% %w(monday tuesday wednesday thursday friday saturday sunday).each do |day_type| %>
<span class="<%= @time_table.send( day_type) ? "included_day_type" : "excluded_day_type" %>">
<%= @time_table.human_attribute_name(day_type) %>
</span>
<% end %>
- <% end %>
- </p>
-
+ <% end %>
+ </p>
+
</div>
<% if @time_table.periods.present? %>
@@ -93,7 +93,7 @@
<%= render "time_tables/excluded_dates" %>
</div>
<% end %>
-
+
</div>
</div>
diff --git a/app/views/time_tables/_time_table.html.erb b/app/views/time_tables/_time_table.html.erb
index 0642f5a6c..7f48a9365 100644
--- a/app/views/time_tables/_time_table.html.erb
+++ b/app/views/time_tables/_time_table.html.erb
@@ -1,24 +1,24 @@
<div id="index_item" class="panel panel-default time_table">
<div class="panel-heading">
<div class="panel-title clearfix">
- <span class="pull-right">
+ <span class="pull-right">
<%= link_to edit_referential_time_table_path(@referential, time_table), :class => "btn btn-default btn-sm" do %>
<span class="fa fa-pencil"></span>
<% end %>
- <%= link_to('<span class="fa fa-trash-o"></span>'.html_safe, referential_time_table_path(@referential, time_table), :method => :delete, :data => {:confirm => t('time_tables.actions.destroy_confirm')}, :class => "btn btn-danger btn-sm") if delete %>
+ <%= link_to('<span class="fa fa-trash-o"></span>'.html_safe, referential_time_table_path(@referential, time_table), :method => :delete, :data => {:confirm => t('time_tables.actions.destroy_confirm')}, :class => "btn btn-danger btn-sm") if delete %>
</span>
<h5>
<%= link_to([@referential, time_table], :class => "preview", :title => "#{Chouette::TimeTable.model_name.human.capitalize} #{time_table.comment}") do %>
- <span class="state-code <%= time_table_state_code(time_table) %>"><i class="fa fa-certificate"></i></span>
+ <span class="state-code <%= time_table.presenter.time_table_state_code %>"><i class="fa fa-certificate"></i></span>
<span class="name">
- <%= truncate(time_table.comment, :length => 20) %>
+ <%= truncate(time_table.comment, :length => 20) %>
</span>
<% end %>
</h5>
- </div>
+ </div>
</div>
<div class="panel-body">
- <%= time_tables_shortest_info(time_table) %>
+ <%= time_table.presenter.time_tables_shortest_info %>
<% unless time_table.periods.empty? %>
<div>
<% %w(monday tuesday wednesday thursday friday saturday sunday).each do |day_type| %>
@@ -29,7 +29,7 @@
</div>
<% end %>
<% unless time_table.tags.empty? %>
- <div><%= tag_list_shortened(time_table) %></div>
+ <div><%= time_table.presenter.tag_list_shortened %></div>
<% end %>
</div>
</div>
diff --git a/app/views/time_tables/index.html.erb b/app/views/time_tables/index.html.erb
index e9802b4bc..2163dfa94 100644
--- a/app/views/time_tables/index.html.erb
+++ b/app/views/time_tables/index.html.erb
@@ -1,11 +1,11 @@
-<%= title_tag t('time_tables.index.title') %>
+<%= title_tag t('time_tables.index.title') %>
<%= search_form_for @q, :url => referential_time_tables_path(@referential), remote: true, :html => {:method => :get, class: "form-inline", :id => "search", role: "form"} do |f| %>
<div class="panel panel-default">
- <div class="panel-heading">
- <div class="input-group col-md-9">
+ <div class="panel-heading">
+ <div class="input-group col-md-9">
<%= f.text_field :comment_cont, :placeholder => "#{t('.comment')}", :class => 'form-control' %>
-
+
<div class="input-group-btn">
<button class="btn btn-default" type="submit"><i class="fa fa-search"></i></button>
</div>
@@ -14,8 +14,8 @@
<i class="fa fa-plus"></i> <%= "#{t('.advanced_search')}" %>
</a>
</div>
-
- <div id="advanced_search" class="panel-collapse collapse">
+
+ <div id="advanced_search" class="panel-collapse collapse">
<div class="panel-body">
<div>
<label><%= "#{t('.from')}" %></label>
diff --git a/app/views/vehicle_journeys/_form.html.erb b/app/views/vehicle_journeys/_form.html.erb
index 1c3945164..5322f3eb4 100644
--- a/app/views/vehicle_journeys/_form.html.erb
+++ b/app/views/vehicle_journeys/_form.html.erb
@@ -12,7 +12,7 @@
<%= form.input :facility %>
<%= form.input :vehicle_type_identifier%>
<%= form.input :objectid, :required => !@vehicle_journey.new_record?, :input_html => { :title => t("formtastic.titles.vehicle_journey.objectid")} %>
- <%= form.input :time_table_tokens, :label => t('.time_tables'), :as => :search_time_table, :json => referential_time_tables_path(@referential, :format => :json), :hint_text => t('search_hint'), :no_result_text => t('no_result_text'),:searching_text => t('searching_term'), :input_html => { :"data-pre" => ( @vehicle_journey.time_tables.map{ |time_table| { :id => time_table.id, :tags => time_table.tags.join(','), :day_types => %w(monday tuesday wednesday thursday friday saturday sunday).select{ |d| time_table.send(d) }.map{ |d| time_table.human_attribute_name(d).first(2)}.join(''), :comment => time_table.comment, :time_table_bounding => time_table_bounding( time_table), :composition_info => composition_info(time_table) } } ).to_json } %>
+ <%= form.input :time_table_tokens, :label => t('.time_tables'), :as => :search_time_table, :json => referential_autocomplete_time_tables_path(@referential, :format => :json), :hint_text => t('search_hint'), :no_result_text => t('no_result_text'),:searching_text => t('searching_term'), :input_html => { :"data-pre" => Rabl::Renderer.new( 'autocomplete_time_tables/index', @vehicle_journey.time_tables, :view_path => 'app/views', :format => :json, :scope => :self ).render } %>
<li class="input">
<%= form.label @vehicle_journey.human_attribute_name(:vehicle_journey_at_stop_ids), :class => "label" %>
</li>
@@ -48,12 +48,12 @@
<tbody class="journey_pattern_dependent_list">
<%= render :partial => "vehicle_journeys/vehicle_journey_at_stop_fields",
:collection => @vehicle_journey.vehicle_journey_at_stops, :as => :vehicle_journey_at_stop, :locals => { :vehicle_journey_at_stops_size => @vehicle_journey.vehicle_journey_at_stops.size } %>
-
+
</tbody>
</table>
-
+
<% end %>
-
+
<%= form.actions do %>
<%= form.action :submit, :as => :button %>
<%= form.action :cancel, :as => :link %>
diff --git a/app/views/vehicle_journeys/_show_popover.html.erb b/app/views/vehicle_journeys/_show_popover.html.erb
index 5f6fe51ea..40a44e805 100644
--- a/app/views/vehicle_journeys/_show_popover.html.erb
+++ b/app/views/vehicle_journeys/_show_popover.html.erb
@@ -2,25 +2,25 @@
<%= Chouette::JourneyPattern.model_name.human %> : <%= link_to journey_name( vehicle_journey.journey_pattern ), [@referential, @line, @route, vehicle_journey.journey_pattern] %>
</p>
<p>
- <%= vehicle_journey.time_tables.size %> <%= Chouette::TimeTable.model_name.human.pluralize %> <small><%= time_tables_shortest_info( vehicle_journey ) %></small> :
+ <%= vehicle_journey.time_tables.size %> <%= Chouette::TimeTable.model_name.human.pluralize %> <small><%= vehicle_journey.presenter.time_tables_shortest_info %></small> :
<ul>
<% vehicle_journey.time_tables.limit(4).each do |time_table| %>
<li>
<%= link_to [@referential, time_table] do %>
- <span class="state-code <%= time_table_state_code(time_table) %>"><i class="fa fa-certificate"></i></span> <%= time_table.comment %>
- <% end %>
+ <span class="state-code <%= time_table.presenter.time_table_state_code %>"><i class="fa fa-certificate"></i></span> <%= time_table.comment %>
+ <% end %>
<% if time_table.tag_list.present? %>
<br>
<span class="time_table_info"><%= truncate(time_table.tag_list.to_s, :length => 35) %></span>
<% end %>
<br>
- <% %w(monday tuesday wednesday thursday friday saturday sunday).each do |day_type| %>
+ <% %w(monday tuesday wednesday thursday friday saturday sunday).each do |day_type| %>
<span class="<%= time_table.send( day_type) ? "included_day_type" : "excluded_day_type"%> time_table_info">
<%= time_table.human_attribute_name(day_type).first(2) %>
</span>
<% end %>
- <span class="bounding"><%= time_table_bounding( time_table) %></span>
+ <span class="bounding"><%= time_table.presenter.time_table_bounding %></span>
</li>
<% end %>
- </ul>
+ </ul>
</p>
diff --git a/app/views/vehicle_journeys/_time_filter.html.erb b/app/views/vehicle_journeys/_time_filter.html.erb
deleted file mode 100644
index 6767468ec..000000000
--- a/app/views/vehicle_journeys/_time_filter.html.erb
+++ /dev/null
@@ -1,13 +0,0 @@
- <%= search_form_for @q, :url => referential_line_route_vehicle_journeys_path(@referential, @line, @route) do |f| %>
- <input name=<%= "q[vehicle_journey_at_stops_departure_time_gt(3i)]" %> type="hidden" value="1">
- <input name=<%= "q[vehicle_journey_at_stops_departure_time_gt(2i)]" %> type="hidden" value="1">
- <input name=<%= "q[vehicle_journey_at_stops_departure_time_gt(1i)]" %> type="hidden" value="2000">
- <%= select_hour(@q.send( "vehicle_journey_at_stops_departure_time_gt") ? @q.send( "vehicle_journey_at_stops_departure_time_gt").hour : 0,
- :prefix => "q", :field_name => "vehicle_journey_at_stops_departure_time_gt(4i)") %>
- <%= select_minute(@q.send( "vehicle_journey_at_stops_departure_time_gt") ? @q.send( "vehicle_journey_at_stops_departure_time_gt").min : 0,
- :prefix => "q", :field_name => "vehicle_journey_at_stops_departure_time_gt(5i)") %>
- <%= f.hidden_field :journey_pattern_id_eq %>
- <%= f.hidden_field :time_tables_comment_eq %>
- <%= f.submit t('.time_range_filter') %>
- <% end %>
-
diff --git a/app/views/vehicle_journeys/_time_table.html.erb b/app/views/vehicle_journeys/_time_table.html.erb
deleted file mode 100644
index f9e51ac37..000000000
--- a/app/views/vehicle_journeys/_time_table.html.erb
+++ /dev/null
@@ -1,7 +0,0 @@
-<%= div_for(time_table, :class => "time_table") do %>
- <%= render "time_tables/cell_title", time_table: time_table %>
- <div class="info">
- <%= render "time_tables/cell_info", time_table: time_table %>
- </div>
-<% end %>
-
diff --git a/app/views/vehicle_journeys/_timeless_vehicle_journey.html.erb b/app/views/vehicle_journeys/_timeless_vehicle_journey.html.erb
deleted file mode 100644
index ad691a2fe..000000000
--- a/app/views/vehicle_journeys/_timeless_vehicle_journey.html.erb
+++ /dev/null
@@ -1,15 +0,0 @@
-<%= div_for(vehicle_journey) do %>
- <%= link_to vehicle_name(vehicle_journey), [@referential, @line, @route, vehicle_journey] %>
- <div class="info">
- <% unless vehicle_journey.time_tables.empty? %>
- <%= vehicle_journey.human_attribute_name('time_tables') %> <%= time_tables_info( vehicle_journey) %> -
- <% end %>
- <% if vehicle_journey.journey_pattern %>
- <%= vehicle_journey.human_attribute_name('journey_pattern') %> <%= link_to journey_name(vehicle_journey.journey_pattern), [@referential, @line, @route, vehicle_journey.journey_pattern] %>
- <% end %>
- <div class="actions">
- <%= link_to t("actions.edit"), edit_referential_line_route_vehicle_journey_path(@referential, @line, @route, vehicle_journey), :class => "edit" %> |
- <%= link_to t("actions.destroy"), [@referential, @line, @route, vehicle_journey], :method => :delete, :confirm => t('vehicle_journeys.actions.destroy_confirm'), :class => "remove" %>
- </div>
- </div>
-<% end %>
diff --git a/app/views/vehicle_journeys/index.html.erb b/app/views/vehicle_journeys/index.html.erb
index 990f028e9..13126b2e1 100644
--- a/app/views/vehicle_journeys/index.html.erb
+++ b/app/views/vehicle_journeys/index.html.erb
@@ -4,13 +4,13 @@
<div class="panel panel-default">
<div class="panel-heading">
<%= f.label :journey_pattern_id_eq, "Missions" %>
- <%= f.text_field(:journey_pattern_id_eq, :class => "form-control") %>
+ <%= f.text_field(:journey_pattern_id_eq, :class => "form-control") %>
<button class="btn btn-default" type="submit"><i class="fa fa-search"></i></button>
<a data-toggle="collapse" data-parent="#search" href="#advanced_search" class="advanced_search">
<i class="fa fa-plus"></i> <%= "#{t('.advanced_search')}" %>
</a>
</div>
-
+
<div id="advanced_search" class="panel-collapse collapse">
<div class="panel-body">
<div>
@@ -50,24 +50,31 @@
<script>
$(function() {
var time_tables_url = function(){
- return '<%= referential_time_tables_path(@referential, :format => :json) %>?route_id=<%= @route.id %>';
+ return '<%= referential_autocomplete_time_tables_path(@referential, :format => :json) %>?route_id=<%= @route.id %>';
};
- var time_table_to_html = function( item ){
+ var time_table_formatter = function(item){
+ var day_types = '';
+ if ( item.day_types.length >0 ){
+ day_types = '<span class=\"day_types\">' + item.day_types + '</span>' ;
+ }
+ var tags = '';
+ if ( item.tags.length >0 ){
+ tags = '<div class=\"info\">' + item.tags + '</div>' ;
+ }
return '<li><div class=\"comment\">' + item.comment +
- '</div><div class=\"info\">' + item.time_table_bounding +
- '</div><div class=\"info\">' + item.composition_info + '</div></li>';
+ '</div><div class=\"info\">' + item.time_table_bounding + ' ' + day_types + '</div>' +
+ tags + '</li>';
};
$( "#q_time_tables_id_eq" ).tokenInput( time_tables_url, {
crossDomain: false,
prePopulate: $('#q_time_tables_id_eq').data('pre'),
- minChars: 3,
- queryParam: 'q[comment_cont]',
+ minChars: 2,
propertyToSearch: 'comment',
hintText: '<%= t('search_hint') %>',
noResultsText: '<%= t('no_result_text') %>',
searchingText: '<%= t('searching_term') %>',
- resultsFormatter: time_table_to_html,
- tokenFormatter: time_table_to_html,
+ resultsFormatter: time_table_formatter,
+ tokenFormatter: time_table_formatter
});
$( "#q_journey_pattern_id_eq" ).tokenInput( '<%= referential_line_route_journey_patterns_path(@referential, @line, @route, :format => :json) %>', {
crossDomain: false,