aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/assets/javascripts/modal_confirmation.js31
-rw-r--r--app/assets/stylesheets/modules/_vj_collection.sass10
-rw-r--r--app/controllers/referential_vehicle_journeys_controller.rb2
-rw-r--r--app/controllers/stop_areas_controller.rb21
-rw-r--r--app/decorators/compliance_control_decorator.rb4
-rw-r--r--app/decorators/compliance_control_set_decorator.rb2
-rw-r--r--app/decorators/line_decorator.rb6
-rw-r--r--app/decorators/network_decorator.rb4
-rw-r--r--app/decorators/purchase_window_decorator.rb2
-rw-r--r--app/decorators/referential_line_decorator.rb6
-rw-r--r--app/decorators/referential_network_decorator.rb4
-rw-r--r--app/decorators/route_decorator.rb12
-rw-r--r--app/decorators/routing_constraint_zone_decorator.rb2
-rw-r--r--app/decorators/stop_area_decorator.rb14
-rw-r--r--app/decorators/stop_area_referential_decorator.rb4
-rw-r--r--app/helpers/stop_areas_helper.rb21
-rw-r--r--app/javascript/vehicle_journeys/actions/index.js10
-rw-r--r--app/models/chouette/route.rb6
-rw-r--r--app/models/chouette/stop_area.rb30
-rw-r--r--app/models/chouette/stop_point.rb3
-rw-r--r--app/models/chouette/vehicle_journey.rb1
-rw-r--r--app/models/chouette/vehicle_journey_at_stop.rb4
-rw-r--r--app/models/simple_importer.rb16
-rw-r--r--app/models/simple_interface.rb7
-rw-r--r--app/models/simple_interfaces_group.rb4
-rw-r--r--app/services/referential_consolidated.rb45
-rw-r--r--app/views/lines/_form.html.slim2
-rw-r--r--app/views/referential_stop_areas/show.html.slim2
-rw-r--r--app/views/referential_vehicle_journeys/_consolidated_line.html.slim4
-rw-r--r--app/views/routes/show.html.slim2
-rw-r--r--app/views/routing_constraint_zones/show.html.slim6
-rw-r--r--app/views/stop_areas/_filters.html.slim34
-rw-r--r--app/views/stop_areas/index.html.slim2
-rw-r--r--app/views/stop_areas/show.html.slim2
-rw-r--r--app/views/workbenches/show.html.slim4
-rw-r--r--app/workers/route_way_cost_worker.rb6
-rw-r--r--config/breadcrumbs.rb1
-rw-r--r--config/locales/actions.en.yml1
-rw-r--r--config/locales/actions.fr.yml1
-rw-r--r--config/locales/companies.en.yml2
-rw-r--r--config/locales/layouts.en.yml1
-rw-r--r--config/locales/layouts.fr.yml1
-rw-r--r--config/locales/lines.en.yml4
-rw-r--r--config/locales/networks.en.yml2
-rw-r--r--config/locales/routing_constraint_zones.en.yml2
-rw-r--r--config/locales/routing_constraint_zones.fr.yml2
-rw-r--r--config/locales/stop_areas.en.yml2
-rw-r--r--config/locales/time_tables.en.yml2
-rw-r--r--config/schedule.rb16
-rw-r--r--lib/cron.rb78
-rw-r--r--lib/tasks/codifligne.rake8
-rw-r--r--lib/tasks/compliance_check_sets.rb11
-rw-r--r--lib/tasks/exports.rake14
-rw-r--r--lib/tasks/imports.rake10
-rw-r--r--lib/tasks/organisations.rake6
-rw-r--r--lib/tasks/reflex.rake8
-rw-r--r--lib/tasks/users.rake6
-rw-r--r--spec/features/stop_areas_spec.rb12
-rw-r--r--spec/models/merge_spec.rb11
59 files changed, 321 insertions, 215 deletions
diff --git a/app/assets/javascripts/modal_confirmation.js b/app/assets/javascripts/modal_confirmation.js
new file mode 100644
index 000000000..e82a8a81b
--- /dev/null
+++ b/app/assets/javascripts/modal_confirmation.js
@@ -0,0 +1,31 @@
+$(document).ready(() => {
+ $.rails.allowAction = (link) => {
+ let message = link.data('confirm')
+ if (!message) return true
+ showConfirmModal(link)
+ return false
+ }
+
+ let showConfirmModal = (link) => {
+ let message = link.data('confirm')
+ let html = `<div class="modal fade" id="confirmationDialog" tabindex="1" role="dialog">
+ <div class="modal-container">
+ <div class="modal-dialog">
+ <div class="modal-content">
+ <div class="modal-header">
+ <h4 class="modal-title"> ${I18n.t('warning')} </h4>
+ </div>
+ <div class="modal-body">
+ <p>${message}</p>
+ </div>
+ <div class="modal-footer">
+ <a data-dismiss="modal" class="btn">${I18n.t('cancel')}</a>
+ <a data-dismiss="modal" class="btn btn-primary" data-method=${link.data('method')} href=${link.attr('href')}>${I18n.t('ok')}</a>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div> `
+ $(html).modal()
+ }
+}) \ No newline at end of file
diff --git a/app/assets/stylesheets/modules/_vj_collection.sass b/app/assets/stylesheets/modules/_vj_collection.sass
index 9bb19f75f..b230991fb 100644
--- a/app/assets/stylesheets/modules/_vj_collection.sass
+++ b/app/assets/stylesheets/modules/_vj_collection.sass
@@ -22,7 +22,7 @@
display: block
height: 100%
- > span
+ > span:not(.small)
position: absolute
display: block
line-height: 1em
@@ -268,9 +268,12 @@
margin-bottom: 0px
& > *
display: inline-block
+ .t2e-item-list
+ overflow: scroll
& > *
overflow: hidden
min-width: 0
+ max-width: none
&.open
margin-bottom: 40px
@@ -305,6 +308,11 @@
.table-2entries > .t2e-head > .td > div > span::after
bottom: -6px !important
+ .table-2entries > .t2e-head > .td > div > span
+ text-overflow: ellipsis
+ overflow: hidden
+ white-space: nowrap
+
.table.table-2entries .t2e-item-list .t2e-item
background-color: #F9F9F9
diff --git a/app/controllers/referential_vehicle_journeys_controller.rb b/app/controllers/referential_vehicle_journeys_controller.rb
index 111d39c2b..917326a6d 100644
--- a/app/controllers/referential_vehicle_journeys_controller.rb
+++ b/app/controllers/referential_vehicle_journeys_controller.rb
@@ -23,7 +23,7 @@ class ReferentialVehicleJourneysController < ChouetteController
private
def collection
- @q ||= end_of_association_chain
+ @q ||= end_of_association_chain.select("vehicle_journeys.id", "vehicle_journeys.journey_pattern_id", "vehicle_journeys.route_id", "vehicle_journeys.objectid", "vehicle_journeys.published_journey_name")
@q = @q.with_stop_area_ids(params[:q][:stop_area_ids]) if params[:q] && params[:q][:stop_area_ids]
@q = ransack_period_range(scope: @q, error_message: t('vehicle_journeys.errors.purchase_window'), query: :in_purchase_window, prefix: :purchase_window)
@q = ransack_period_range(scope: @q, error_message: t('vehicle_journeys.errors.time_table'), query: :with_matching_timetable, prefix: :time_table)
diff --git a/app/controllers/stop_areas_controller.rb b/app/controllers/stop_areas_controller.rb
index 734152c64..38363e8ef 100644
--- a/app/controllers/stop_areas_controller.rb
+++ b/app/controllers/stop_areas_controller.rb
@@ -120,7 +120,6 @@ class StopAreasController < ChouetteController
def collection
scope = parent.present? ? parent.stop_areas : referential.stop_areas
- scope = ransack_status(scope)
@q = scope.search(params[:q])
if sort_column && sort_direction
@@ -206,24 +205,4 @@ class StopAreasController < ChouetteController
] + permitted_custom_fields_params(Chouette::StopArea.custom_fields(stop_area_referential.workgroup))
params.require(:stop_area).permit(fields)
end
-
- # Fake ransack filter
- def ransack_status scope
- return scope unless params[:q].try(:[], :status)
- return scope if params[:q][:status].values.uniq.length == 1
-
- @status = {
- in_creation: params[:q][:status]['in_creation'] == 'true',
- confirmed: params[:q][:status]['confirmed'] == 'true',
- deactivated: params[:q][:status]['deactivated'] == 'true',
- }
-
- scope = Chouette::StopArea.where(
- "confirmed_at #{(@status[:confirmed] || @status[:deactivated]) ? "IS NOT NULL" : "IS NULL"}
- AND deleted_at #{@status[:deactivated] ? "IS NOT NULL" : "IS NULL"}"
- )
-
- params[:q].delete :status
- scope
- end
end
diff --git a/app/decorators/compliance_control_decorator.rb b/app/decorators/compliance_control_decorator.rb
index fd2dbd9ce..7cdb4a890 100644
--- a/app/decorators/compliance_control_decorator.rb
+++ b/app/decorators/compliance_control_decorator.rb
@@ -5,7 +5,7 @@ class ComplianceControlDecorator < AF83::Decorator
with_instance_decorator do |instance_decorator|
instance_decorator.show_action_link do |l|
- l.content h.t('compliance_control_sets.actions.show')
+ l.content t('compliance_control_sets.actions.show')
l.href do
h.compliance_control_set_compliance_control_path(
object.compliance_control_set.id,
@@ -17,7 +17,7 @@ class ComplianceControlDecorator < AF83::Decorator
instance_decorator.edit_action_link
instance_decorator.destroy_action_link do |l|
- l.data confirm: h.t('compliance_controls.actions.destroy_confirm')
+ l.data confirm: t('compliance_controls.actions.destroy_confirm')
end
end
diff --git a/app/decorators/compliance_control_set_decorator.rb b/app/decorators/compliance_control_set_decorator.rb
index b16a06886..ad38c492c 100644
--- a/app/decorators/compliance_control_set_decorator.rb
+++ b/app/decorators/compliance_control_set_decorator.rb
@@ -20,7 +20,7 @@ class ComplianceControlSetDecorator < AF83::Decorator
instance_decorator.destroy_action_link do |l|
l.content h.destroy_link_content
l.href { h.compliance_control_set_path(object.id) }
- l.data confirm: h.t('compliance_control_sets.actions.destroy_confirm')
+ l.data confirm: t('compliance_control_sets.actions.destroy_confirm')
end
end
end
diff --git a/app/decorators/line_decorator.rb b/app/decorators/line_decorator.rb
index 077978c36..0fdb7cc0b 100644
--- a/app/decorators/line_decorator.rb
+++ b/app/decorators/line_decorator.rb
@@ -44,7 +44,7 @@ class LineDecorator < AF83::Decorator
l.content { h.deactivate_link_content('lines.actions.deactivate') }
l.href { h.deactivate_line_referential_line_path(context[:line_referential], object) }
l.method :put
- l.data confirm: h.t('lines.actions.deactivate_confirm')
+ l.data {{ confirm: h.t('lines.actions.deactivate_confirm') }}
l.add_class "delete-action"
end
@@ -52,13 +52,13 @@ class LineDecorator < AF83::Decorator
l.content { h.activate_link_content('lines.actions.activate') }
l.href { h.activate_line_referential_line_path(context[:line_referential], object) }
l.method :put
- l.data confirm: h.t('lines.actions.activate_confirm')
+ l.data {{ confirm: h.t('lines.actions.activate_confirm') }}
l.add_class "delete-action"
end
instance_decorator.destroy_action_link do |l|
l.content { h.destroy_link_content('lines.actions.destroy') }
- l.data confirm: h.t('lines.actions.destroy_confirm')
+ l.data {{ confirm: h.t('lines.actions.destroy_confirm') }}
l.add_class "delete-action"
end
end
diff --git a/app/decorators/network_decorator.rb b/app/decorators/network_decorator.rb
index ea0f73dc2..55cd37082 100644
--- a/app/decorators/network_decorator.rb
+++ b/app/decorators/network_decorator.rb
@@ -25,8 +25,8 @@ class NetworkDecorator < AF83::Decorator
end
instance_decorator.destroy_action_link do |l|
- l.content h.destroy_link_content('networks.actions.destroy')
- l.data confirm: h.t('networks.actions.destroy_confirm')
+ l.content { h.destroy_link_content('networks.actions.destroy') }
+ l.data {{ confirm: h.t('networks.actions.destroy_confirm') }}
end
end
end
diff --git a/app/decorators/purchase_window_decorator.rb b/app/decorators/purchase_window_decorator.rb
index 9b58577b2..8e6ca9d36 100644
--- a/app/decorators/purchase_window_decorator.rb
+++ b/app/decorators/purchase_window_decorator.rb
@@ -15,7 +15,7 @@ class PurchaseWindowDecorator < AF83::Decorator
instance_decorator.edit_action_link
instance_decorator.destroy_action_link do |l|
- l.data confirm: h.t('purchase_windows.actions.destroy_confirm')
+ l.data confirm: t('purchase_windows.actions.destroy_confirm')
end
end
diff --git a/app/decorators/referential_line_decorator.rb b/app/decorators/referential_line_decorator.rb
index 3ac846d76..4416e133e 100644
--- a/app/decorators/referential_line_decorator.rb
+++ b/app/decorators/referential_line_decorator.rb
@@ -13,12 +13,12 @@ class ReferentialLineDecorator < AF83::Decorator
instance_decorator.show_action_link
instance_decorator.action_link secondary: true do |l|
- l.content Chouette::Line.human_attribute_name(:footnotes)
+ l.content Chouette::Line.tmf(:footnotes)
l.href { h.referential_line_footnotes_path(context[:referential], object) }
end
instance_decorator.action_link secondary: true do |l|
- l.content h.t('routing_constraint_zones.index.title')
+ l.content t('routing_constraint_zones.index.title')
l.href do
h.referential_line_routing_constraint_zones_path(
scope,
@@ -36,7 +36,7 @@ class ReferentialLineDecorator < AF83::Decorator
},
secondary: true
) do |l|
- l.content h.t('routes.actions.new')
+ l.content t('routes.actions.new')
l.href { h.new_referential_line_route_path(scope, object) }
end
end
diff --git a/app/decorators/referential_network_decorator.rb b/app/decorators/referential_network_decorator.rb
index c508452c0..f8c656e7c 100644
--- a/app/decorators/referential_network_decorator.rb
+++ b/app/decorators/referential_network_decorator.rb
@@ -20,8 +20,8 @@ class ReferentialNetworkDecorator < AF83::Decorator
end
instance_decorator.destroy_action_link do |l|
- l.content h.destroy_link_content('networks.actions.destroy')
- l.data confirm: h.t('networks.actions.destroy_confirm')
+ l.content { h.destroy_link_content('networks.actions.destroy') }
+ l.data confirm: t('networks.actions.destroy_confirm')
end
end
end
diff --git a/app/decorators/route_decorator.rb b/app/decorators/route_decorator.rb
index 646bc1620..801e139b0 100644
--- a/app/decorators/route_decorator.rb
+++ b/app/decorators/route_decorator.rb
@@ -18,7 +18,7 @@ class RouteDecorator < AF83::Decorator
if: ->() { object.stop_points.any? },
secondary: :show
) do |l|
- l.content h.t('journey_patterns.actions.index')
+ l.content t('journey_patterns.actions.index')
l.href do
[
context[:referential],
@@ -33,7 +33,7 @@ class RouteDecorator < AF83::Decorator
if: ->() { object.journey_patterns.present? },
secondary: :show
) do |l|
- l.content h.t('vehicle_journeys.actions.index')
+ l.content t('vehicle_journeys.actions.index')
l.href do
[
context[:referential],
@@ -45,7 +45,7 @@ class RouteDecorator < AF83::Decorator
end
instance_decorator.action_link secondary: :show do |l|
- l.content h.t('vehicle_journey_exports.new.title')
+ l.content t('vehicle_journey_exports.new.title')
l.href do
h.referential_line_route_vehicle_journey_exports_path(
context[:referential],
@@ -60,7 +60,7 @@ class RouteDecorator < AF83::Decorator
secondary: :show,
policy: :duplicate
) do |l|
- l.content h.t('routes.duplicate.title')
+ l.content t('routes.duplicate.title')
l.method :post
l.href do
h.duplicate_referential_line_route_path(
@@ -76,7 +76,7 @@ class RouteDecorator < AF83::Decorator
policy: :create_opposite,
if: ->{h.has_feature?(:create_opposite_routes)}
) do |l|
- l.content h.t('routes.create_opposite.title')
+ l.content t('routes.create_opposite.title')
l.method :post
l.disabled { object.opposite_route.present? }
l.href do
@@ -90,7 +90,7 @@ class RouteDecorator < AF83::Decorator
end
instance_decorator.destroy_action_link do |l|
- l.data confirm: h.t('routes.actions.destroy_confirm')
+ l.data confirm: t('routes.actions.destroy_confirm')
end
end
end
diff --git a/app/decorators/routing_constraint_zone_decorator.rb b/app/decorators/routing_constraint_zone_decorator.rb
index de73068be..3ff286cc1 100644
--- a/app/decorators/routing_constraint_zone_decorator.rb
+++ b/app/decorators/routing_constraint_zone_decorator.rb
@@ -21,7 +21,7 @@ class RoutingConstraintZoneDecorator < AF83::Decorator
instance_decorator.edit_action_link
instance_decorator.destroy_action_link do |l|
- l.data confirm: h.t('routing_constraint_zones.actions.destroy_confirm')
+ l.data confirm: t('routing_constraint_zones.actions.destroy_confirm')
end
end
end
diff --git a/app/decorators/stop_area_decorator.rb b/app/decorators/stop_area_decorator.rb
index 525681971..c7f10b13b 100644
--- a/app/decorators/stop_area_decorator.rb
+++ b/app/decorators/stop_area_decorator.rb
@@ -11,11 +11,11 @@ class StopAreaDecorator < AF83::Decorator
instance_decorator.show_action_link
instance_decorator.edit_action_link do |l|
- l.content h.t('stop_areas.actions.edit')
+ l.content t('stop_areas.actions.edit')
end
instance_decorator.action_link policy: :deactivate, secondary: true do |l|
- l.content h.deactivate_link_content('stop_areas.actions.deactivate')
+ l.content { h.deactivate_link_content('stop_areas.actions.deactivate') }
l.href do
h.deactivate_stop_area_referential_stop_area_path(
object.stop_area_referential,
@@ -23,12 +23,12 @@ class StopAreaDecorator < AF83::Decorator
)
end
l.method :put
- l.data confirm: h.t('stop_areas.actions.deactivate_confirm')
+ l.data confirm: t('stop_areas.actions.deactivate_confirm')
l.add_class 'delete-action'
end
instance_decorator.action_link policy: :activate, secondary: true do |l|
- l.content h.activate_link_content('stop_areas.actions.activate')
+ l.content { h.activate_link_content('stop_areas.actions.activate') }
l.href do
h.activate_stop_area_referential_stop_area_path(
object.stop_area_referential,
@@ -36,13 +36,13 @@ class StopAreaDecorator < AF83::Decorator
)
end
l.method :put
- l.data confirm: h.t('stop_areas.actions.activate_confirm')
+ l.data confirm: t('stop_areas.actions.activate_confirm')
l.add_class 'delete-action'
end
instance_decorator.destroy_action_link do |l|
- l.content h.destroy_link_content('stop_areas.actions.destroy')
- l.data confirm: h.t('stop_areas.actions.destroy_confirm')
+ l.content { h.destroy_link_content('stop_areas.actions.destroy') }
+ l.data confirm: t('stop_areas.actions.destroy_confirm')
end
end
diff --git a/app/decorators/stop_area_referential_decorator.rb b/app/decorators/stop_area_referential_decorator.rb
index d30501ec9..36e45abca 100644
--- a/app/decorators/stop_area_referential_decorator.rb
+++ b/app/decorators/stop_area_referential_decorator.rb
@@ -5,9 +5,9 @@ class StopAreaReferentialDecorator < AF83::Decorator
instance_decorator.action_link policy: :synchronize, primary: :show do |l|
l.content t('actions.sync')
- l.href { h. sync_stop_area_referential_path(object.id) }
+ l.href { h.sync_stop_area_referential_path(object.id) }
l.method :post
end
-
+
end
end
diff --git a/app/helpers/stop_areas_helper.rb b/app/helpers/stop_areas_helper.rb
index 314154fb7..d3e7dd2a4 100644
--- a/app/helpers/stop_areas_helper.rb
+++ b/app/helpers/stop_areas_helper.rb
@@ -75,16 +75,17 @@ module StopAreasHelper
t "formtastic.hints.stop_area.registration_number"
end
- def stop_area_status(stop_area)
- if stop_area.activated?
- content_tag(:span, nil, class: 'fa fa-check-circle fa-lg text-success') +
- t('activerecord.attributes.stop_area.confirmed')
- elsif stop_area.deactivated?
- content_tag(:span, nil, class: 'fa fa-exclamation-circle fa-lg text-danger') +
- t('activerecord.attributes.stop_area.deactivated')
- else
- content_tag(:span, nil, class: 'fa fa-pencil fa-lg text-info') +
- t('activerecord.attributes.stop_area.in_creation')
+ def stop_area_status(status)
+ case status
+ when :confirmed
+ content_tag(:span, nil, class: 'fa fa-check-circle fa-lg text-success') +
+ t('activerecord.attributes.stop_area.confirmed')
+ when :deactivated
+ content_tag(:span, nil, class: 'fa fa-exclamation-circle fa-lg text-danger') +
+ t('activerecord.attributes.stop_area.deactivated')
+ else
+ content_tag(:span, nil, class: 'fa fa-pencil fa-lg text-info') +
+ t('activerecord.attributes.stop_area.in_creation')
end
end
diff --git a/app/javascript/vehicle_journeys/actions/index.js b/app/javascript/vehicle_journeys/actions/index.js
index 98594083d..8ac8b5ec5 100644
--- a/app/javascript/vehicle_journeys/actions/index.js
+++ b/app/javascript/vehicle_journeys/actions/index.js
@@ -379,11 +379,11 @@ const actions = {
vehicle_journey_at_stops: vjasWithDelta,
deletable: false,
selected: false,
- published_journey_name: val.published_journey_name || 'non renseigné',
- published_journey_identifier: val.published_journey_identifier || 'non renseigné',
- company: val.company || {name: 'non renseigné'},
- transport_mode: val.route.line.transport_mode || 'undefined',
- transport_submode: val.route.line.transport_submode || 'undefined'
+ published_journey_name: val.published_journey_name || '',
+ published_journey_identifier: val.published_journey_identifier || '',
+ company: val.company || {name: ''},
+ transport_mode: val.route.line.transport_mode || '',
+ transport_submode: val.route.line.transport_submode || ''
})
)
}
diff --git a/app/models/chouette/route.rb b/app/models/chouette/route.rb
index 949b18d6f..6a02203ad 100644
--- a/app/models/chouette/route.rb
+++ b/app/models/chouette/route.rb
@@ -63,6 +63,9 @@ module Chouette
where(" position between ? and ? ", between_positions.first, between_positions.last)
end
end
+
+ has_many :vehicle_journey_at_stops, through: :vehicle_journeys
+
has_many :stop_areas, -> { order('stop_points.position ASC') }, :through => :stop_points do
def between(departure, arrival)
departure, arrival = [departure, arrival].map do |endpoint|
@@ -166,7 +169,8 @@ module Chouette
end
def time_tables
- vehicle_journeys.joins(:time_tables).map(&:"time_tables").flatten.uniq
+ ids = vehicle_journeys.joins(:time_tables).pluck('time_tables.id').uniq
+ Chouette::TimeTable.where(id: ids)
end
def sorted_vehicle_journeys(journey_category_model)
diff --git a/app/models/chouette/stop_area.rb b/app/models/chouette/stop_area.rb
index b933e1944..25a0010d8 100644
--- a/app/models/chouette/stop_area.rb
+++ b/app/models/chouette/stop_area.rb
@@ -383,6 +383,28 @@ module Chouette
end
end
+ def self.ransackable_scopes(auth_object = nil)
+ [:by_status]
+ end
+
+
+ def self.by_status(*statuses)
+ return Chouette::StopArea.all if statuses.reject(&:blank?).length == 3 || statuses.reject(&:blank?).empty?
+
+ status = {
+ in_creation: statuses.include?('in_creation'),
+ confirmed: statuses.include?('confirmed'),
+ deactivated: statuses.include?('deactivated'),
+ }
+
+ query = []
+ query << "deleted_at IS NOT NULL" if statuses.include?('deactivated')
+ query << "(confirmed_at IS NULL AND deleted_at IS NULL)" if statuses.include?('in_creation')
+ query << "(confirmed_at IS NOT NULL AND deleted_at IS NULL)" if statuses.include?('confirmed')
+
+ Chouette::StopArea.where(query.join(' OR '))
+ end
+
def activated?
!!(deleted_at.nil? && confirmed_at)
end
@@ -410,7 +432,7 @@ module Chouette
end
def status
- return :deleted if deleted_at
+ return :deactivated if deleted_at
return :confirmed if confirmed_at
:in_creation
@@ -418,7 +440,7 @@ module Chouette
def status=(status)
case status&.to_sym
- when :deleted
+ when :deactivated
deactivate
when :confirmed
activate
@@ -428,7 +450,7 @@ module Chouette
end
def self.statuses
- %i{in_creation confirmed deleted}
+ %i{in_creation confirmed deactivated}
end
def time_zone_offset
@@ -441,7 +463,7 @@ module Chouette
return unless ActiveSupport::TimeZone[time_zone].present?
ActiveSupport::TimeZone[time_zone].tzinfo.name
end
-
+
def country
return unless country_code
country = ISO3166::Country[country_code]
diff --git a/app/models/chouette/stop_point.rb b/app/models/chouette/stop_point.rb
index edb0e81fd..82bedc6ab 100644
--- a/app/models/chouette/stop_point.rb
+++ b/app/models/chouette/stop_point.rb
@@ -10,6 +10,7 @@ module Chouette
include ObjectidSupport
belongs_to :stop_area
+ belongs_to :stop_area_light, -> {select(:name, :city_name, :zip_code, :time_zone)}, class_name: "Chouette::StopArea", foreign_key: :stop_area_id
belongs_to :route, inverse_of: :stop_points
has_many :journey_patterns, through: :route
has_many :vehicle_journey_at_stops, :dependent => :destroy
@@ -27,7 +28,7 @@ module Chouette
scope :default_order, -> { order("position") }
- delegate :name, :registration_number, :kind, :area_type, to: :stop_area
+ delegate :name, :registration_number, :kind, :area_type, to: :stop_area_light
before_destroy :remove_dependent_journey_pattern_stop_points
def remove_dependent_journey_pattern_stop_points
diff --git a/app/models/chouette/vehicle_journey.rb b/app/models/chouette/vehicle_journey.rb
index 818287b04..3bbd89f7b 100644
--- a/app/models/chouette/vehicle_journey.rb
+++ b/app/models/chouette/vehicle_journey.rb
@@ -21,6 +21,7 @@ module Chouette
belongs_to :company
belongs_to :route
belongs_to :journey_pattern
+ belongs_to :journey_pattern_only_objectid, -> {select("journey_patterns.objectid")}, class_name: "Chouette::JourneyPattern", foreign_key: :journey_pattern_id
has_many :stop_areas, through: :journey_pattern
has_and_belongs_to_many :footnotes, :class_name => 'Chouette::Footnote'
diff --git a/app/models/chouette/vehicle_journey_at_stop.rb b/app/models/chouette/vehicle_journey_at_stop.rb
index 3f5bd5abf..797571070 100644
--- a/app/models/chouette/vehicle_journey_at_stop.rb
+++ b/app/models/chouette/vehicle_journey_at_stop.rb
@@ -101,8 +101,8 @@ module Chouette
end
def time_zone_offset
- return 0 unless stop_point&.stop_area&.time_zone.present?
- ActiveSupport::TimeZone[stop_point.stop_area.time_zone]&.utc_offset || 0
+ return 0 unless stop_point&.stop_area_light&.time_zone.present?
+ ActiveSupport::TimeZone[stop_point.stop_area_light.time_zone]&.utc_offset || 0
end
private
diff --git a/app/models/simple_importer.rb b/app/models/simple_importer.rb
index 4cfe90cff..d47ff6a92 100644
--- a/app/models/simple_importer.rb
+++ b/app/models/simple_importer.rb
@@ -42,8 +42,10 @@ class SimpleImporter < SimpleInterface
end
def dump_csv_from_context
- dir = context[:logs_output_dir] || "log/importers"
- filepath = File.join dir, "#{self.configuration_name}_#{Time.now.strftime "%y%m%d%H%M"}.csv"
+ dir = @output_dir
+ FileUtils.mkdir_p dir
+
+ filepath = File.join dir, "#{self.configuration_name}_#{Time.now.strftime "%y%m%d%H%M"}_dump.csv"
# for some reason, context[:csv].to_csv does not work
CSV.open(filepath, 'w') do |csv|
header = true
@@ -131,14 +133,16 @@ class SimpleImporter < SimpleInterface
@current_attribute = col[:attribute]
val = col[:value]
if val.nil? || val.is_a?(Proc)
- if row.has_key? col.name
- if val.is_a?(Proc)
+ if val.is_a?(Proc)
+ if row.has_key? col.name
val = instance_exec(row[col.name], &val)
else
- val = row[col.name]
+ val = instance_exec(&val)
end
+ elsif row.has_key? col.name
+ val = row[col.name]
else
- push_in_journal({event: :column_not_found, message: "Column not found: #{col.name}", kind: :warning})
+ push_in_journal({event: :column_not_found, message: "Column not found: #{col.name || col.attribute}", kind: :warning})
self.status ||= :success_with_warnings
end
end
diff --git a/app/models/simple_interface.rb b/app/models/simple_interface.rb
index 7b04a07df..d5feafb07 100644
--- a/app/models/simple_interface.rb
+++ b/app/models/simple_interface.rb
@@ -97,13 +97,14 @@ class SimpleInterface < ApplicationModel
def write_output_to_csv
cols = %i(line kind event message error)
- if self.journal.size > 0 && self.journal.first[:row].present?
+ journal = self.journal && self.journal.map(&:symbolize_keys)
+ if journal && journal.size > 0 && journal.first[:row].present?
log "Writing output log"
FileUtils.mkdir_p @output_dir
- keys = self.journal.first[:row].map(&:first)
+ keys = journal.first[:row].map(&:first)
CSV.open(output_filepath, "w") do |csv|
csv << cols + keys
- self.journal.each do |j|
+ journal.each do |j|
csv << cols.map{|c| j[c]} + j[:row].map(&:last)
end
end
diff --git a/app/models/simple_interfaces_group.rb b/app/models/simple_interfaces_group.rb
index 808be6570..1e13bd0b5 100644
--- a/app/models/simple_interfaces_group.rb
+++ b/app/models/simple_interfaces_group.rb
@@ -30,7 +30,9 @@ class SimpleInterfacesGroup
name = "### #{self.name} ###"
centered_name = " " * ([width - name.size, 0].max / 2) + name
- banner = [centered_name, ""]
+ banner = [centered_name]
+ banner << "Output to: #{shared_options[:output_dir]}" if shared_options && shared_options[:output_dir]
+ banner << ""
banner << @interfaces.each_with_index.map do |interface, i|
if interface[:interface].status.present?
SimpleInterface.colorize interface[:name], SimpleInterface.status_color(interface[:interface].status)
diff --git a/app/services/referential_consolidated.rb b/app/services/referential_consolidated.rb
index 465eab405..832210db3 100644
--- a/app/services/referential_consolidated.rb
+++ b/app/services/referential_consolidated.rb
@@ -48,11 +48,12 @@ class ReferentialConsolidated
attr_reader :parent
attr_reader :ar_model
- def initialize parent, ar_model, vehicle_journeys, params
+ def initialize parent, ar_model, vehicle_journeys, params, opts={}
@parent = parent
@ar_model = ar_model
@all_vehicle_journeys = vehicle_journeys
@params = params
+ @opts = opts
end
def should_highlight?
@@ -74,9 +75,19 @@ class ReferentialConsolidated
class Route < Base
def_delegators :ar_model, :name, :id, :time_tables, :purchase_windows, :stop_area_ids
+ def vehicle_journey_at_stops
+ @vehicle_journey_at_stops ||= begin
+ out = Hash.new{|h, k| h[k] = {}}
+ ar_model.vehicle_journey_at_stops.each do |vjas|
+ out[vjas.vehicle_journey_id][vjas.stop_point_id] = vjas
+ end
+ out
+ end
+ end
+
def vehicle_journeys
@vehicle_journeys ||= begin
- ar_model.vehicle_journeys.map {|vj| VehicleJourney.new(self, vj, @all_vehicle_journeys, params) }
+ ar_model.vehicle_journeys.select(:id, :published_journey_name, :route_id, :journey_pattern_id).map {|vj| VehicleJourney.new(self, vj, @all_vehicle_journeys, params, vehicle_journey_at_stops: vehicle_journey_at_stops[vj.id]) }
end
end
@@ -85,7 +96,7 @@ class ReferentialConsolidated
end
def highlighted_count
- highlighted_journeys.count
+ highlighted_journeys.except(:select).count
end
def highlighted?
@@ -93,18 +104,32 @@ class ReferentialConsolidated
(should_highlight? || matching_stop_areas) && highlighted_journeys.exists?
end
+ def stop_areas
+ @stop_areas ||= begin
+ out = {}
+ ar_model.stop_areas.select(:id, :name, :city_name, :zip_code, :time_zone).each do |sp|
+ out[sp.id] = sp
+ end
+ out
+ end
+ end
+
def stop_points
- @stop_points ||= ar_model.stop_points.map {|sp| StopPoint.new(self, sp, @all_vehicle_journeys, params) }
+ @stop_points ||= ar_model.stop_points.map {|sp| StopPoint.new(self, sp, @all_vehicle_journeys, params, stop_area: stop_areas[sp.stop_area_id]) }
end
end
class VehicleJourney < Base
- def_delegators :ar_model, :id, :published_journey_name, :journey_pattern, :time_tables, :purchase_windows, :vehicle_journey_at_stops, :time_table_ids, :purchase_window_ids, :route
+ def_delegators :ar_model, :id, :published_journey_name, :journey_pattern, :time_tables, :purchase_windows, :time_table_ids, :purchase_window_ids, :route, :journey_pattern_only_objectid
def highlighted?
should_highlight? && @all_vehicle_journeys.where(id: self.id).exists?
end
+ def vehicle_journey_at_stops
+ @opts[:vehicle_journey_at_stops] || {}
+ end
+
def has_purchase_window? purchase_window
purchase_window_ids.include?(purchase_window.id)
end
@@ -115,7 +140,15 @@ class ReferentialConsolidated
end
class StopPoint < Base
- def_delegators :ar_model, :id, :arrival_time, :departure_time, :name, :stop_area, :stop_area_id
+ def_delegators :ar_model, :id, :arrival_time, :departure_time, :stop_area_id
+
+ def stop_area
+ @opts[:stop_area]
+ end
+
+ def name
+ stop_area.name
+ end
def highlighted?
params[:q] && params[:q]["stop_areas"] && params[:q]["stop_areas"].values.any?{|v| v.to_s == stop_area_id.to_s}
diff --git a/app/views/lines/_form.html.slim b/app/views/lines/_form.html.slim
index 909d6512e..4623abf8a 100644
--- a/app/views/lines/_form.html.slim
+++ b/app/views/lines/_form.html.slim
@@ -4,7 +4,7 @@
= f.input :name
= f.input :network_id, as: :select, :collection => @line_referential.networks, include_blank: false
= f.input :company_id, as: :select, :collection => @line_referential.companies, include_blank: true
- = f.input :secondary_company_ids, :collection => @line_referential.companies, include_blank: false, input_html: { multiple: true, 'data-select2ed': true }, label: t('activerecord.attributes.line.secondary_company')
+ = f.input :secondary_company_ids, :collection => @line_referential.companies, include_blank: false, input_html: { multiple: true, 'data-select2ed': true }, label: Chouette::Line.tmf(:secondary_companies)
= f.input :published_name
= f.input :registration_number
= f.input :number
diff --git a/app/views/referential_stop_areas/show.html.slim b/app/views/referential_stop_areas/show.html.slim
index beee0383f..06096bbaa 100644
--- a/app/views/referential_stop_areas/show.html.slim
+++ b/app/views/referential_stop_areas/show.html.slim
@@ -7,7 +7,7 @@
.col-lg-6.col-md-6.col-sm-12.col-xs-12
= definition_list t('metadatas'),
{ t('id_reflex') => @stop_area.try(:user_objectid),
- Chouette::StopArea.tmf(:status) => stop_area_status(@stop_area),
+ Chouette::StopArea.tmf(:status) => stop_area_status(@stop_area.status),
Chouette::StopArea.tmf(:comment) => @stop_area.try(:comment),
Chouette::StopArea.tmf(:stop_area_type) => t("area_types.label.#{@stop_area.stop_area_type}"),
Chouette::StopArea.tmf(:registration_number) => @stop_area.registration_number,
diff --git a/app/views/referential_vehicle_journeys/_consolidated_line.html.slim b/app/views/referential_vehicle_journeys/_consolidated_line.html.slim
index c73c65961..9a27c0ecf 100644
--- a/app/views/referential_vehicle_journeys/_consolidated_line.html.slim
+++ b/app/views/referential_vehicle_journeys/_consolidated_line.html.slim
@@ -78,7 +78,7 @@
strong= link_to journey.id, [@referential, journey.route.line, journey.route, :vehicle_journeys]
div
= link_to journey.published_journey_name, [@referential, journey.route.line, journey.route, :vehicle_journeys], title: journey.published_journey_name
- div= journey.journey_pattern.get_objectid.short_id
+ div= journey.journey_pattern_only_objectid.get_objectid.short_id
div
- journey.purchase_windows[0..3].each do |tt|
span.vj_tt
@@ -105,7 +105,7 @@
ruby:
headline = vehicle_journey_stop_headline prev_sp, sp
prev_sp = sp
- vjas = journey.vehicle_journey_at_stops.where(stop_point_id: sp.id).last
+ vjas = journey.vehicle_journey_at_stops[sp.id]
.td class="#{vjas && sp.highlighted? ? 'highlighted' : ''} #{vjas.nil? ? 'disabled' : ''} #{headline.present? ? 'headlined' : ''}"
div title="#{sp.stop_area.city_name ? "#{sp.stop_area.city_name} (#{sp.stop_area.zip_code})" : ''}" data-headline=headline class=(headline.present? ? 'headlined' : '')
- if vjas.present?
diff --git a/app/views/routes/show.html.slim b/app/views/routes/show.html.slim
index 2218bd85f..615913faa 100644
--- a/app/views/routes/show.html.slim
+++ b/app/views/routes/show.html.slim
@@ -36,7 +36,7 @@
TableBuilderHelper::Column.new( \
key: :status, \
name: Chouette::StopArea.tmf('status'), \
- attribute: Proc.new { |s| stop_area_status(s.try(:stop_area)) } \
+ attribute: Proc.new { |s| stop_area_status(s.try(:stop_area).try(:status) ) } \
), \
TableBuilderHelper::Column.new( \
key: :zip_code, \
diff --git a/app/views/routing_constraint_zones/show.html.slim b/app/views/routing_constraint_zones/show.html.slim
index 8c8e9b17a..55c952ae6 100644
--- a/app/views/routing_constraint_zones/show.html.slim
+++ b/app/views/routing_constraint_zones/show.html.slim
@@ -16,15 +16,15 @@
= table_builder_2 @routing_constraint_zone.route.stop_points,
[ \
TableBuilderHelper::Column.new( \
- name: "Arrêts de l'itinéraire", \
+ name: t('.route_stop_points'), \
attribute: 'name', \
link_to: lambda do |stop_point| \
referential_stop_area_path(@referential, stop_point.stop_area) \
end \
),
TableBuilderHelper::Column.new( \
- name: "Arrêts inclus dans l'ITL", \
- attribute: Proc.new{ |rsp| (@routing_constraint_zone.stop_point_ids.include? rsp.id) ? 'Oui' : 'Non' } \
+ name: t('.stop_points'), \
+ attribute: Proc.new{ |rsp| (@routing_constraint_zone.stop_point_ids.include? rsp.id) ? t('yes') : t('no') } \
) \
],
sortable: false,
diff --git a/app/views/stop_areas/_filters.html.slim b/app/views/stop_areas/_filters.html.slim
index cca48bb17..88ed6a772 100644
--- a/app/views/stop_areas/_filters.html.slim
+++ b/app/views/stop_areas/_filters.html.slim
@@ -9,38 +9,16 @@
span.fa.fa-search
.ffg-row
- = f.input :zip_code_cont, placeholder: t('.zip_code'), label: Chouette::StopArea.human_attribute_name(:zip_code), required: false, wrapper_html: {class: filter_item_class(params[:q], :zip_code_cont)}
- = f.input :city_name_cont, placeholder: t('.city_name'), label: Chouette::StopArea.human_attribute_name(:city_name), required: false, wrapper_html: {class: filter_item_class(params[:q], :city_name_cont)}
+ = f.input :zip_code_cont, placeholder: t('.zip_code'), label: Chouette::StopArea.tmf('zip_code'), required: false, wrapper_html: {class: filter_item_class(params[:q], :zip_code_cont)}
+ = f.input :city_name_cont, placeholder: t('.city_name'), label: Chouette::StopArea.tmf('city_name'), required: false, wrapper_html: {class: filter_item_class(params[:q], :city_name_cont)}
.form-group.togglable class=filter_item_class(params[:q], :area_type_eq_any)
- = f.label Chouette::StopArea.human_attribute_name(:area_type), required: false, class: 'control-label'
+ = f.label Chouette::StopArea.tmf('area_type'), required: false, class: 'control-label'
= f.input :area_type_eq_any, checked: params[:q] && params[:q][:area_type_eq_any], collection: Chouette::AreaType.options, as: :check_boxes, label: false, label_method: lambda{|w| ("<span>" + w[0] + "</span>").html_safe}, required: false, wrapper_html: { class: 'checkbox_list' }
-
- .form-group.togglable class=filter_item_class(params[:q], :status)
+
+ .form-group.togglable class=filter_item_class(params[:q], :by_status)
= f.label Chouette::StopArea.tmf('status'), required: false, class: 'control-label'
- .form-group.checkbox_list
- = f.simple_fields_for :status do |p|
- = p.input :in_creation,
- label: ("<span>#{t('activerecord.attributes.stop_area.in_creation')}<span class='fa fa-pencil text-info'></span></span>").html_safe,
- as: :boolean,
- wrapper_html: { class: 'checkbox-wrapper' },
- checked_value: true,
- unchecked_value: false,
- input_html: { checked: @status.try(:[], :in_creation) }
- = p.input :confirmed,
- label: ("<span>#{t('activerecord.attributes.stop_area.confirmed')}<span class='fa fa-check-circle text-success'></span></span>").html_safe,
- as: :boolean,
- wrapper_html: { class: 'checkbox-wrapper' },
- checked_value: true,
- unchecked_value: false,
- input_html: { checked: @status.try(:[], :confirmed) }
- = p.input :deactivated,
- label: ("<span>#{t('activerecord.attributes.stop_area.deleted')}<span class='fa fa-exclamation-circle text-danger'></span></span>").html_safe,
- as: :boolean,
- wrapper_html: { class: 'checkbox-wrapper' },
- checked_value: true,
- unchecked_value: false,
- input_html: { checked: @status.try(:[], :deactivated) }
+ = f.input :by_status, checked: params[:q] && params[:q][:by_status], collection: [:in_creation, :confirmed, :deactivated], as: :check_boxes, label: false, label_method: lambda{|w| ("<span>" + stop_area_status(w) + "</span>").html_safe}, required: false, wrapper_html: { class: 'checkbox_list' }
.actions
= link_to t('actions.erase'), @workbench, class: 'btn btn-link'
diff --git a/app/views/stop_areas/index.html.slim b/app/views/stop_areas/index.html.slim
index 62b873c36..e5ca82ee2 100644
--- a/app/views/stop_areas/index.html.slim
+++ b/app/views/stop_areas/index.html.slim
@@ -33,7 +33,7 @@
), \
TableBuilderHelper::Column.new( \
key: :status, \
- attribute: Proc.new { |s| stop_area_status(s) } \
+ attribute: Proc.new { |s| stop_area_status(s.status) } \
), \
TableBuilderHelper::Column.new( \
key: :zip_code, \
diff --git a/app/views/stop_areas/show.html.slim b/app/views/stop_areas/show.html.slim
index c10d22bfb..c1965c161 100644
--- a/app/views/stop_areas/show.html.slim
+++ b/app/views/stop_areas/show.html.slim
@@ -21,7 +21,7 @@
Chouette::StopArea.tmf('city_name') => @stop_area.city_name,
Chouette::StopArea.tmf('country_code') => @stop_area.country_code.presence || '-',
Chouette::StopArea.tmf('time_zone') => @stop_area.time_zone.presence || '-',
- Chouette::StopArea.tmf('status') => stop_area_status(@stop_area),
+ Chouette::StopArea.tmf('status') => stop_area_status(@stop_area.status),
Chouette::StopArea.tmf('comment') => @stop_area.try(:comment),
})
- @stop_area.custom_fields.each do |code, field|
diff --git a/app/views/workbenches/show.html.slim b/app/views/workbenches/show.html.slim
index 213c9e5f2..979e7ff04 100644
--- a/app/views/workbenches/show.html.slim
+++ b/app/views/workbenches/show.html.slim
@@ -6,8 +6,8 @@
- if policy(Workbench).update?
= link_to t('workbenches.actions.configure'), edit_workbench_path(@workbench), class: 'btn btn-primary'
- if policy(Referential).create?
- = link_to t('actions.import'), workbench_imports_path(@workbench), class: 'btn btn-primary'
- = link_to t('actions.export'), workbench_exports_path(@workbench), class: 'btn btn-primary'
+ = link_to t('actions.import'), workbench_imports_path(@workbench), class: 'btn btn-primary' unless @workbench.workgroup.import_types.empty?
+ = link_to t('actions.export'), workbench_exports_path(@workbench), class: 'btn btn-primary' unless @workbench.workgroup.export_types.empty?
= link_to t('actions.add'), new_workbench_referential_path(@workbench), class: 'btn btn-primary'
= link_to t('workbenches.actions.show_output'), workbench_output_path(@workbench), class: 'btn btn-primary'
diff --git a/app/workers/route_way_cost_worker.rb b/app/workers/route_way_cost_worker.rb
index b62416c3d..5d8ed52f9 100644
--- a/app/workers/route_way_cost_worker.rb
+++ b/app/workers/route_way_cost_worker.rb
@@ -3,7 +3,11 @@ class RouteWayCostWorker
def perform(referential_id, route_id)
Referential.find(referential_id).switch
- route = Chouette::Route.find(route_id)
+ route = Chouette::Route.where(id: route_id).last
+ unless route.present?
+ Rails.logger.warn "RouteWayCost called on missing route ##{route_id}".red
+ return
+ end
# Prevent recursive worker spawning since this call updates the
# `costs` field of the route.
diff --git a/config/breadcrumbs.rb b/config/breadcrumbs.rb
index af1dec3ae..28a117d52 100644
--- a/config/breadcrumbs.rb
+++ b/config/breadcrumbs.rb
@@ -175,7 +175,6 @@ end
crumb :stop_areas do |stop_area_referential|
link I18n.t('stop_areas.index.title'), stop_area_referential_stop_areas_path(stop_area_referential)
- parent :stop_area_referential, stop_area_referential
end
crumb :stop_area do |stop_area_referential, stop_area|
diff --git a/config/locales/actions.en.yml b/config/locales/actions.en.yml
index faf0dcec2..2c48f11a9 100644
--- a/config/locales/actions.en.yml
+++ b/config/locales/actions.en.yml
@@ -35,3 +35,4 @@ en:
no_result_text: "No Results"
searching_term: "Searching..."
are_you_sure: Are you sure?
+ ok: Ok
diff --git a/config/locales/actions.fr.yml b/config/locales/actions.fr.yml
index 9e1a132a7..f02ab2198 100644
--- a/config/locales/actions.fr.yml
+++ b/config/locales/actions.fr.yml
@@ -35,3 +35,4 @@ fr:
no_result_text: "Aucun résultat"
searching_term: "Recherche en cours..."
are_you_sure: Etes vous sûr ?
+ ok: Ok
diff --git a/config/locales/companies.en.yml b/config/locales/companies.en.yml
index f2b19bc19..8a746f6b7 100644
--- a/config/locales/companies.en.yml
+++ b/config/locales/companies.en.yml
@@ -6,7 +6,7 @@ en:
new: "Add a new company"
edit: "Edit this company"
destroy: "Remove this company"
- destroy_confirm: "Are you sure you want destroy this company?"
+ destroy_confirm: "Are you sure you want to destroy this company?"
new:
title: "Add a new company"
edit:
diff --git a/config/locales/layouts.en.yml b/config/locales/layouts.en.yml
index 2f75bffbf..3f67c5c20 100644
--- a/config/locales/layouts.en.yml
+++ b/config/locales/layouts.en.yml
@@ -71,6 +71,7 @@ en:
yesterday: "Yestersday"
edit_periods: "Edit periods"
delete_periods: "Delete periods"
+ warning: Warning
attributes:
author: "Edited by"
created_at: "Created at"
diff --git a/config/locales/layouts.fr.yml b/config/locales/layouts.fr.yml
index 4526a9e56..48c1211d4 100644
--- a/config/locales/layouts.fr.yml
+++ b/config/locales/layouts.fr.yml
@@ -71,6 +71,7 @@ fr:
yesterday: "Hier"
edit_periods: "Editer Périodes"
delete_periods: "Supprimer Périodes"
+ warning: Avertissement
attributes:
author: "Edité par"
created_at: "Créé le"
diff --git a/config/locales/lines.en.yml b/config/locales/lines.en.yml
index 6501faa57..0f3eaadd9 100644
--- a/config/locales/lines.en.yml
+++ b/config/locales/lines.en.yml
@@ -8,7 +8,7 @@ en:
activate: "Activate this line"
deactivate: "Deactivate this line"
activate_confirm: "Are you sure you want to activate this line ?"
- deactivate_confirm: "Are you sure you want tode activate this line ?"
+ deactivate_confirm: "Are you sure you want to deactivate this line ?"
destroy_confirm: "Are you sure you want to destroy this line ?"
destroy_selection_confirm: "Are you sure you want to destroy those lines ?"
import: "Import lines"
@@ -117,7 +117,7 @@ en:
updated_at: Updated at
creator_id: "Created by"
footnotes: "Footnotes"
- stable_id: External permanent idenifier"
+ stable_id: External permanent identifier
status: Status
activated: Activated
deactivated: Deactivated
diff --git a/config/locales/networks.en.yml b/config/locales/networks.en.yml
index 2046a30ae..d4164f9a6 100644
--- a/config/locales/networks.en.yml
+++ b/config/locales/networks.en.yml
@@ -5,7 +5,7 @@ en:
new: "Add a new network"
edit: "Edit this network"
destroy: "Remove this network"
- destroy_confirm: "Are you sure you want destroy this network?"
+ destroy_confirm: "Are you sure you want to destroy this network ?"
new:
title: "Add a new network"
edit:
diff --git a/config/locales/routing_constraint_zones.en.yml b/config/locales/routing_constraint_zones.en.yml
index 2143ce1e1..a4bb9b36c 100644
--- a/config/locales/routing_constraint_zones.en.yml
+++ b/config/locales/routing_constraint_zones.en.yml
@@ -39,6 +39,8 @@ en:
title: "Update routing constraint zone %{name}"
show:
title: "Routing constraint zone %{name}"
+ route_stop_points: Route stop points
+ stop_points: Stop points included in the RCZ
index:
title: "Routing constraint zones"
search_no_results: "No ITL matches your query"
diff --git a/config/locales/routing_constraint_zones.fr.yml b/config/locales/routing_constraint_zones.fr.yml
index b5e0fa7fb..8de1bc225 100644
--- a/config/locales/routing_constraint_zones.fr.yml
+++ b/config/locales/routing_constraint_zones.fr.yml
@@ -39,6 +39,8 @@ fr:
title: "Editer l'ITL : %{name}"
show:
title: "Zone de contrainte %{name}"
+ route_stop_points: Arrêts de l'itinéraire
+ stop_points: Arrêts inclus dans l'ITL
index:
title: "Interdictions de trafic local"
search_no_results: "Aucune ITL ne correspond à votre recherche"
diff --git a/config/locales/stop_areas.en.yml b/config/locales/stop_areas.en.yml
index 7f460381c..3a26f93b2 100644
--- a/config/locales/stop_areas.en.yml
+++ b/config/locales/stop_areas.en.yml
@@ -28,7 +28,7 @@ en:
activate: "Activate this stop"
deactivate: "Deactivate this stop"
activate_confirm: "Are you sure you want to activate this stop ?"
- deactivate_confirm: "Are you sure you want tode activate this stop ?"
+ deactivate_confirm: "Are you sure you want to deactivate this stop ?"
deleted_at: "Activated"
destroy_confirm: "Are you sure you want destroy this stop and all of his children ?"
select_parent: "Create or modify the relation child -> parent"
diff --git a/config/locales/time_tables.en.yml b/config/locales/time_tables.en.yml
index ce890942d..234f36e81 100644
--- a/config/locales/time_tables.en.yml
+++ b/config/locales/time_tables.en.yml
@@ -90,7 +90,7 @@ en:
to: " to: "
start_date: "mm/jj/aaaa"
end_date: "mm/jj/aaaa"
- title: "timetables"
+ title: "Timetables"
selection: "Selection"
selection_all: "All"
advanced_search: "Advanced Search"
diff --git a/config/schedule.rb b/config/schedule.rb
index 0d2a24f31..9642fa3a4 100644
--- a/config/schedule.rb
+++ b/config/schedule.rb
@@ -28,25 +28,19 @@ set :NEW_RELIC_LOG, 'stdout'
set :job_template, "/bin/bash -c ':job'"
every :hour do
- rake "organisations:sync"
- rake "users:sync"
+ runner "Cron.every_hour"
end
every :day, :at => '3:00am' do
- rake "reflex:sync"
-end
-every :day, :at => '4:00 am' do
- rake "codifligne:sync"
+ runner "Cron.every_day_at_3AM"
end
-every 5.minutes do
- rake "import:netex_abort_old"
- rake "import:notify_parent"
+every :day, :at => '4:00 am' do
+ runner "Cron.every_day_at_4AM"
end
every 5.minutes do
- rake "compliance_check_sets:abort_old"
- rake "compliance_check_sets:notify_parent"
+ runner "Cron.every_5_minutes"
end
every 1.minute do
diff --git a/lib/cron.rb b/lib/cron.rb
new file mode 100644
index 000000000..fe010ffd9
--- /dev/null
+++ b/lib/cron.rb
@@ -0,0 +1,78 @@
+module Cron
+ class << self
+
+ def every_day_at_3AM
+ sync_reflex
+ end
+
+ def every_day_at_4AM
+ sync_codifligne
+ end
+
+ def every_hour
+ sync_organizations
+ sync_users
+ end
+
+ def every_5_minutes
+ check_import_operations
+ check_ccset_operations
+ end
+
+ private
+
+ def sync_organizations
+ begin
+ Organisation.portail_sync
+ rescue => e
+ Rails.logger.error(e.inspect)
+ end
+ end
+
+ def sync_users
+ begin
+ User.portail_sync
+ rescue => e
+ Rails.logger.error(e.inspect)
+ end
+ end
+
+ def sync_reflex
+ begin
+ sync = StopAreaReferential.find_by(name: 'Reflex').stop_area_referential_syncs.build
+ raise "reflex:sync aborted - There is already an synchronisation in progress" unless sync.valid?
+ sync.save
+ rescue => e
+ Rails.logger.warn(e.message)
+ end
+ end
+
+ def sync_codifligne
+ begin
+ sync = LineReferential.find_by(name: 'CodifLigne').line_referential_syncs.build
+ raise "Codifligne:sync aborted - There is already an synchronisation in progress" unless sync.valid?
+ sync.save
+ rescue => e
+ Rails.logger.warn(e.message)
+ end
+ end
+
+ def check_ccset_operations
+ begin
+ ParentNotifier.new(ComplianceCheckSet).notify_when_finished
+ ComplianceCheckSet.abort_old
+ rescue => e
+ Rails.logger.error(e.inspect)
+ end
+ end
+
+ def check_import_operations
+ begin
+ ParentNotifier.new(Import::Base).notify_when_finished
+ Import::Netex.abort_old
+ rescue => e
+ Rails.logger.error(e.inspect)
+ end
+ end
+ end
+end \ No newline at end of file
diff --git a/lib/tasks/codifligne.rake b/lib/tasks/codifligne.rake
deleted file mode 100644
index dd5e99370..000000000
--- a/lib/tasks/codifligne.rake
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace :codifligne do
- desc "Sync lines, companies, networks, and group of lines from codifligne"
- task sync: :environment do
- sync = LineReferential.find_by(name: 'CodifLigne').line_referential_syncs.build
- raise "Codifligne:sync aborted - There is already an synchronisation in progress" unless sync.valid?
- sync.save if sync.valid?
- end
-end
diff --git a/lib/tasks/compliance_check_sets.rb b/lib/tasks/compliance_check_sets.rb
deleted file mode 100644
index c53c7f9ed..000000000
--- a/lib/tasks/compliance_check_sets.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-namespace :compliance_check_sets do
- desc "Notify parent check sets when children finish"
- task notify_parent: :environment do
- ParentNotifier.new(ComplianceCheckSet).notify_when_finished
- end
-
- desc "Mark old unfinished check sets as 'aborted'"
- task abort_old: :environment do
- ComplianceCheckSet.abort_old
- end
-end
diff --git a/lib/tasks/exports.rake b/lib/tasks/exports.rake
index 845d581d3..33fbf81ed 100644
--- a/lib/tasks/exports.rake
+++ b/lib/tasks/exports.rake
@@ -52,9 +52,9 @@ namespace :export do
puts "No maching journeys were found".red
else
exports_group = SimpleInterfacesGroup.new "Export Complet \"#{referential.name}\" du #{Time.now.to_date} au #{args[:timelapse].to_i.days.from_now.to_date}"
- exports_group.shared_options = {verbose: true}
+ exports_group.shared_options = {verbose: true, output_dir: args[:output_dir]}
- exporter = SimpleJsonExporter.create configuration_name: "#{args[:configuration_name]}_companies", filepath: "#{args[:output_dir]}/#{args[:configuration_name]}_companies.json"
+ exporter = SimpleJsonExporter.create configuration_name: "#{args[:configuration_name]}_companies", filepath: "#{args[:output_dir]}/service_type.json"
ids = journeys.pluck :company_id
ids += journeys.joins(route: :line).pluck :"lines.company_id"
@@ -64,28 +64,28 @@ namespace :export do
exports_group.add_interface exporter, "Services Types", :export
- exporter = SimpleJsonExporter.create configuration_name: "#{args[:configuration_name]}_schedules", filepath: "#{args[:output_dir]}/#{args[:configuration_name]}_schedules.json"
+ exporter = SimpleJsonExporter.create configuration_name: "#{args[:configuration_name]}_schedules", filepath: "#{args[:output_dir]}/schedule.json"
exporter.configure do |config|
- config.collection = journeys
+ config.collection = journeys.where("custom_field_values->>'capacity' IS NOT NULL")
end
exports_group.add_interface exporter, "Schedules", :export
- exporter = SimpleJsonExporter.create configuration_name: "#{args[:configuration_name]}_routes", filepath: "#{args[:output_dir]}/#{args[:configuration_name]}_routes.json"
+ exporter = SimpleJsonExporter.create configuration_name: "#{args[:configuration_name]}_routes", filepath: "#{args[:output_dir]}/route.json"
exporter.configure do |config|
config.collection = Chouette::JourneyPattern.where(id: journeys.pluck(:journey_pattern_id).uniq)
end
exports_group.add_interface exporter, "Routes", :export
- exporter = SimpleJsonExporter.create configuration_name: "#{args[:configuration_name]}_stops", filepath: "#{args[:output_dir]}/#{args[:configuration_name]}_stops.json"
+ exporter = SimpleJsonExporter.create configuration_name: "#{args[:configuration_name]}_stops", filepath: "#{args[:output_dir]}/station.json"
exporter.configure do |config|
config.collection = Chouette::StopArea.where(id: journeys.joins(:stop_points).pluck(:"stop_points.stop_area_id").uniq).order('parent_id ASC NULLS FIRST')
end
exports_group.add_interface exporter, "Stops", :export
- exporter = SimpleJsonExporter.create configuration_name: "#{args[:configuration_name]}_journeys", filepath: "#{args[:output_dir]}/#{args[:configuration_name]}_journeys.json"
+ exporter = SimpleJsonExporter.create configuration_name: "#{args[:configuration_name]}_journeys", filepath: "#{args[:output_dir]}/service.json"
exporter.configure do |config|
config.collection = journeys
end
diff --git a/lib/tasks/imports.rake b/lib/tasks/imports.rake
index d393ab156..258c37bbd 100644
--- a/lib/tasks/imports.rake
+++ b/lib/tasks/imports.rake
@@ -2,16 +2,6 @@ require 'csv'
require 'tasks/helpers/simple_interfaces'
namespace :import do
- desc "Notify parent imports when children finish"
- task notify_parent: :environment do
- ParentNotifier.new(Import::Base).notify_when_finished
- end
-
- desc "Mark old unfinished Netex imports as 'aborted'"
- task netex_abort_old: :environment do
- Import::Netex.abort_old
- end
-
desc "import the given file with the corresponding importer"
task :import, [:configuration_name, :filepath, :referential_id, :logs_output_dir] => :environment do |t, args|
args.with_defaults(logs_output_dir: "./log/importers/")
diff --git a/lib/tasks/organisations.rake b/lib/tasks/organisations.rake
deleted file mode 100644
index 1b21d7119..000000000
--- a/lib/tasks/organisations.rake
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace :organisations do
- desc "Sync organisations from stif portail"
- task sync: :environment do
- Organisation.portail_sync
- end
-end
diff --git a/lib/tasks/reflex.rake b/lib/tasks/reflex.rake
deleted file mode 100644
index 67496cee0..000000000
--- a/lib/tasks/reflex.rake
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace :reflex do
- desc "Sync data from Reflex api"
- task sync: :environment do
- sync = StopAreaReferential.find_by(name: 'Reflex').stop_area_referential_syncs.build
- raise "reflex:sync aborted - There is already an synchronisation in progress" unless sync.valid?
- sync.save if sync.valid?
- end
-end
diff --git a/lib/tasks/users.rake b/lib/tasks/users.rake
deleted file mode 100644
index c045639c1..000000000
--- a/lib/tasks/users.rake
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace :users do
- desc "Sync users from stif portail"
- task sync: :environment do
- User.portail_sync
- end
-end
diff --git a/spec/features/stop_areas_spec.rb b/spec/features/stop_areas_spec.rb
index 52040f070..3a47f826f 100644
--- a/spec/features/stop_areas_spec.rb
+++ b/spec/features/stop_areas_spec.rb
@@ -43,30 +43,30 @@ describe "StopAreas", :type => :feature do
describe 'updated stop areas in before block' do
it 'supports displaying only stop areas in creation' do
- find("#q_status_in_creation").set(true)
+ find("#q_by_status_in_creation").set(true)
click_button 'search-btn'
expect(page).not_to have_content(stop_areas.first.name)
expect(page).not_to have_content(stop_areas.last.name)
end
it 'supports displaying only confirmed stop areas' do
- find("#q_status_confirmed").set(true)
+ find("#q_by_status_confirmed").set(true)
click_button 'search-btn'
expect(page).to have_content(stop_areas.first.name)
expect(page).not_to have_content(stop_areas.last.name)
end
it 'supports displaying only deactivated stop areas' do
- find("#q_status_deactivated").set(true)
+ find("#q_by_status_deactivated").set(true)
click_button 'search-btn'
expect(page).not_to have_content(stop_areas.first.name)
expect(page).to have_content(stop_areas.last.name)
end
it 'should display all stop areas if all filters are checked' do
- find("#q_status_in_creation").set(true)
- find("#q_status_confirmed").set(true)
- find("#q_status_deactivated").set(true)
+ find("#q_by_status_in_creation").set(true)
+ find("#q_by_status_confirmed").set(true)
+ find("#q_by_status_deactivated").set(true)
click_button 'search-btn'
expect(page).to have_content(stop_areas.first.name)
expect(page).to have_content(stop_areas.last.name)
diff --git a/spec/models/merge_spec.rb b/spec/models/merge_spec.rb
index 8c3f48272..f1df40b83 100644
--- a/spec/models/merge_spec.rb
+++ b/spec/models/merge_spec.rb
@@ -30,6 +30,13 @@ RSpec.describe Merge do
stop_areas = stop_area_referential.stop_areas.order("random()").limit(5)
FactoryGirl.create :route, line: line, stop_areas: stop_areas, stop_points_count: 0
end
+ # Loop
+ stop_areas = stop_area_referential.stop_areas.order("random()").limit(5)
+ route = FactoryGirl.create :route, line: line, stop_areas: stop_areas, stop_points_count: 0
+ route.stop_points.create stop_area: stop_areas.first, position: route.stop_points.size
+ jp = route.full_journey_pattern
+ expect(route.stop_points.uniq.count).to eq route.stop_areas.uniq.count + 1
+ expect(jp.stop_points.uniq.count).to eq jp.stop_areas.uniq.count + 1
end
referential.routes.each_with_index do |route, index|
@@ -65,7 +72,7 @@ RSpec.describe Merge do
end
referential.journey_patterns.each do |journey_pattern|
- stop_points_positions[journey_pattern.name] = Hash[*journey_pattern.stop_points.map{|sp| [sp.stop_area_id, sp.position]}.flatten]
+ stop_points_positions[journey_pattern.name] = Hash[*journey_pattern.stop_points.map{|sp| [sp.position, sp.stop_area_id]}.flatten]
factor.times do
FactoryGirl.create :vehicle_journey, journey_pattern: journey_pattern, company: company
end
@@ -118,7 +125,7 @@ RSpec.describe Merge do
# This should be enforced by the checksum preservation though
output.journey_patterns.each do |journey_pattern|
journey_pattern.stop_points.each do |sp|
- expect(sp.position).to eq stop_points_positions[journey_pattern.name][sp.stop_area_id]
+ expect(sp.stop_area_id).to eq stop_points_positions[journey_pattern.name][sp.position]
end
end