aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume2017-11-27 16:52:38 +0100
committerGuillaume2017-11-27 16:52:38 +0100
commit2b11404b58dad37cc9e5dae3e24bcf7b466f5c32 (patch)
tree3091ac1c0be5f7584de79c9fd8a0a0b217753312
parentc83002d8f281384244dc9c11432e2eb648b99b3b (diff)
parent6bd0791839353750511ce4a49e6b75a462dfec51 (diff)
downloadchouette-core-2b11404b58dad37cc9e5dae3e24bcf7b466f5c32.tar.bz2
Merge branch 'master' into 4824-create_line_referentials
-rw-r--r--app/controllers/application_controller.rb1
-rw-r--r--app/decorators/company_decorator.rb86
-rw-r--r--app/decorators/line_decorator.rb5
-rw-r--r--app/decorators/network_decorator.rb72
-rw-r--r--app/decorators/route_decorator.rb122
-rw-r--r--app/decorators/routing_constraint_zone_decorator.rb70
-rw-r--r--app/decorators/stop_area_decorator.rb68
-rw-r--r--app/decorators/stop_point_decorator.rb12
-rw-r--r--app/decorators/time_table_decorator.rb90
-rw-r--r--app/helpers/custom_view_helper.rb9
-rw-r--r--app/helpers/import_resources_helper.rb4
-rw-r--r--app/javascript/journey_patterns/actions/index.js5
-rw-r--r--app/javascript/journey_patterns/components/JourneyPattern.js2
-rw-r--r--app/javascript/vehicle_journeys/actions/index.js5
-rw-r--r--app/javascript/vehicle_journeys/components/VehicleJourney.js4
-rw-r--r--app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js2
-rw-r--r--app/javascript/vehicle_journeys/components/tools/ShiftVehicleJourney.js2
-rw-r--r--app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js2
-rw-r--r--app/javascript/vehicle_journeys/components/tools/select2s/TimetableSelect2.js2
-rw-r--r--app/javascript/vehicle_journeys/components/tools/select2s/VJSelect2.js2
-rw-r--r--app/models/chouette.rb5
-rw-r--r--app/models/chouette/company.rb1
-rw-r--r--app/models/chouette/connection_link_type.rb2
-rw-r--r--app/models/chouette/direction.rb2
-rw-r--r--app/models/chouette/journey_pattern_section.rb22
-rw-r--r--app/models/chouette/network.rb1
-rw-r--r--app/models/chouette/objectid/netex.rb6
-rw-r--r--app/models/chouette/objectid/stif_netex.rb6
-rw-r--r--app/models/chouette/objectid/stif_reflex.rb2
-rw-r--r--app/models/chouette/objectid_formatter/netex.rb5
-rw-r--r--app/models/chouette/objectid_formatter/stif_codifligne.rb4
-rw-r--r--app/models/chouette/objectid_formatter/stif_netex.rb9
-rw-r--r--app/models/chouette/objectid_formatter/stif_reflex.rb4
-rw-r--r--app/models/chouette/route.rb6
-rw-r--r--app/models/chouette/route_section.rb83
-rw-r--r--app/models/chouette/routing_constraint_zone.rb4
-rw-r--r--app/models/chouette/stop_area.rb7
-rw-r--r--app/models/chouette/time_table.rb1
-rw-r--r--app/models/chouette/timeband.rb3
-rw-r--r--app/models/chouette/vehicle_journey.rb3
-rw-r--r--app/models/compliance_control.rb2
-rw-r--r--app/models/concerns/line_referential_support.rb1
-rw-r--r--app/models/concerns/netex_attributes_support.rb72
-rw-r--r--app/models/concerns/objectid_formatter_support.rb10
-rw-r--r--app/models/concerns/objectid_support.rb18
-rw-r--r--app/models/concerns/stif_codifligne_attributes_support.rb21
-rw-r--r--app/models/concerns/stif_netex_attributes_support.rb58
-rw-r--r--app/models/concerns/stif_reflex_attributes_support.rb21
-rw-r--r--app/models/concerns/stop_area_referential_support.rb1
-rw-r--r--app/models/line_referential.rb3
-rw-r--r--app/models/referential.rb3
-rw-r--r--app/models/route_control/unactivated_stop_point.rb (renamed from app/models/route_control/unactivated_stop_points.rb)2
-rw-r--r--app/models/stop_area_referential.rb3
-rw-r--r--app/models/workbench.rb3
-rw-r--r--app/policies/access_link_policy.rb28
-rw-r--r--app/policies/access_point_policy.rb28
-rw-r--r--app/policies/company_policy.rb10
-rw-r--r--app/policies/connection_link_policy.rb28
-rw-r--r--app/policies/group_of_line_policy.rb10
-rw-r--r--app/policies/journey_pattern_policy.rb28
-rw-r--r--app/policies/line_policy.rb34
-rw-r--r--app/policies/network_policy.rb10
-rw-r--r--app/policies/route_policy.rb34
-rw-r--r--app/policies/routing_constraint_zone_policy.rb28
-rw-r--r--app/policies/stop_area_policy.rb10
-rw-r--r--app/policies/time_table_policy.rb46
-rw-r--r--app/policies/vehicle_journey_policy.rb28
-rw-r--r--app/views/api/v1/journey_patterns/show.rabl7
-rw-r--r--app/views/api/v1/trident_objects/show.rabl1
-rw-r--r--app/views/autocomplete_time_tables/index.rabl4
-rw-r--r--app/views/compliance_controls/_form.html.slim2
-rw-r--r--app/views/dashboards/_dashboard.html.slim37
-rw-r--r--app/views/import_resources/index.html.slim2
-rw-r--r--app/views/imports/show.html.slim2
-rw-r--r--app/views/layouts/navigation/_main_nav_left.html.slim108
-rw-r--r--app/views/layouts/navigation/_main_nav_left_content.html.slim0
-rw-r--r--app/views/layouts/navigation/_main_nav_left_content_stif.html.slim107
-rw-r--r--app/views/lines/index.html.slim4
-rw-r--r--app/views/lines/show.html.slim2
-rw-r--r--app/views/referential_companies/index.html.slim2
-rw-r--r--app/views/referential_lines/show.html.slim4
-rw-r--r--app/views/referential_networks/index.html.slim4
-rw-r--r--app/views/referential_networks/show.html.slim2
-rw-r--r--app/views/referential_stop_areas/show.html.slim2
-rw-r--r--app/views/referentials/show.html.slim2
-rw-r--r--app/views/routes/show.html.slim2
-rw-r--r--app/views/stop_areas/index.html.slim4
-rw-r--r--app/views/stop_areas/show.html.slim4
-rw-r--r--app/views/time_tables/show.rabl2
-rw-r--r--app/views/vehicle_journeys/show.rabl3
-rw-r--r--config/deploy.rb6
-rw-r--r--config/initializers/apartment.rb2
-rw-r--r--config/initializers/stif.rb6
-rw-r--r--config/locales/compliance_controls.en.yml2
-rw-r--r--config/locales/compliance_controls.fr.yml4
-rw-r--r--config/locales/import_messages.en.yml2
-rw-r--r--config/locales/import_messages.fr.yml2
-rw-r--r--config/locales/import_resources.en.yml2
-rw-r--r--config/locales/import_resources.fr.yml2
-rw-r--r--db/migrate/20171001100320_add_custom_view_to_organisations.rb5
-rw-r--r--db/migrate/20171001100642_stif_define_custom_view_for_organisations.rb5
-rw-r--r--db/migrate/20171123110204_update_objectid_format_value_to_referentials.rb14
-rw-r--r--db/schema.rb3
-rw-r--r--db/seeds/chouette.seeds.rb40
-rw-r--r--db/seeds/stif.rb38
-rw-r--r--spec/controllers/devise/cas_sessions_controller_spec.rb2
-rw-r--r--spec/factories/chouette_lines.rb5
-rw-r--r--spec/factories/chouette_routes.rb7
-rw-r--r--spec/factories/compliance_controls/route_control_factories.rb2
-rw-r--r--spec/features/api_keys/edit_api_key_feature_spec.rb2
-rw-r--r--spec/features/api_keys/new_api_key_feature_spec.rb2
-rw-r--r--spec/models/chouette/company_spec.rb6
-rw-r--r--spec/models/chouette/journey_pattern_spec.rb6
-rw-r--r--spec/models/chouette/line_spec.rb11
-rw-r--r--spec/models/chouette/network_spec.rb6
-rw-r--r--spec/models/chouette/object_id_spec.rb149
-rw-r--r--spec/models/chouette/objectid/netex_spec.rb10
-rw-r--r--spec/models/chouette/objectid/stif_codifligne_spec.rb10
-rw-r--r--spec/models/chouette/objectid/stif_netex_spec.rb10
-rw-r--r--spec/models/chouette/objectid/stif_reflex_spec.rb11
-rw-r--r--spec/models/chouette/route/route_base_spec.rb11
-rw-r--r--spec/models/chouette/routing_constraint_zone_spec.rb6
-rw-r--r--spec/models/chouette/stop_area_spec.rb11
-rw-r--r--spec/models/chouette/stop_point_spec.rb13
-rw-r--r--spec/models/chouette/time_table_spec.rb6
-rw-r--r--spec/models/chouette/trident_active_record_spec.rb53
-rw-r--r--spec/models/chouette/vehicle_journey_spec.rb11
-rw-r--r--spec/models/compliance_control_class_level_defaults/route_control/unactivated_stop_point_cccld_spec.rb7
-rw-r--r--spec/models/compliance_control_class_level_defaults/route_control/unactivated_stop_points_cccld_spec.rb7
-rw-r--r--spec/models/concerns/objectid_support_spec.rb138
-rw-r--r--spec/models/referential_spec.rb6
131 files changed, 957 insertions, 1272 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 853c2f715..6a9f6942f 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -48,7 +48,6 @@ class ApplicationController < ActionController::Base
current_organisation
end
-
# Overwriting the sign_out redirect path method
def after_sign_out_path_for(resource_or_scope)
new_user_session_path
diff --git a/app/decorators/company_decorator.rb b/app/decorators/company_decorator.rb
index a95f90128..9416c73ae 100644
--- a/app/decorators/company_decorator.rb
+++ b/app/decorators/company_decorator.rb
@@ -1,52 +1,52 @@
- class CompanyDecorator < Draper::Decorator
- decorates Chouette::Company
+class CompanyDecorator < Draper::Decorator
+ decorates Chouette::Company
- delegate_all
+ delegate_all
- def self.collection_decorator_class
- PaginatingDecorator
- end
+ def self.collection_decorator_class
+ PaginatingDecorator
+ end
+
+ def linecount
+ object.lines.count
+ end
- def linecount
- object.lines.count
+ # Requires:
+ # context: {
+ # referential:
+ # }
+ def action_links
+ links = []
+
+ if h.policy(Chouette::Company).create?
+ links << Link.new(
+ content: h.t('companies.actions.new'),
+ href: h.new_line_referential_company_path(context[:referential])
+ )
end
- # Requires:
- # context: {
- # referential:
- # }
- def action_links
- links = []
-
- if h.policy(Chouette::Company).create?
- links << Link.new(
- content: h.t('companies.actions.new'),
- href: h.new_line_referential_company_path(context[:referential])
+ if h.policy(object).update?
+ links << Link.new(
+ content: h.t('companies.actions.edit'),
+ href: h.edit_line_referential_company_path(
+ context[:referential],
+ object
)
- end
-
- if h.policy(object).update?
- links << Link.new(
- content: h.t('companies.actions.edit'),
- href: h.edit_line_referential_company_path(
- context[:referential],
- object
- )
- )
- end
-
- if h.policy(object).destroy?
- links << Link.new(
- content: t('companies.actions.destroy'),
- href: h.line_referential_company_path(
- context[:referential],
- object
- ),
- method: :delete,
- data: { confirm: h.t('companies.actions.destroy_confirm') }
- )
- end
+ )
+ end
- links
+ if h.policy(object).destroy?
+ links << Link.new(
+ content: t('companies.actions.destroy'),
+ href: h.line_referential_company_path(
+ context[:referential],
+ object
+ ),
+ method: :delete,
+ data: { confirm: h.t('companies.actions.destroy_confirm') }
+ )
end
+
+ links
end
+end
diff --git a/app/decorators/line_decorator.rb b/app/decorators/line_decorator.rb
index d86916873..ee35cd85e 100644
--- a/app/decorators/line_decorator.rb
+++ b/app/decorators/line_decorator.rb
@@ -20,7 +20,8 @@ class LineDecorator < Draper::Decorator
content: h.t('lines.actions.show_company'),
href: [context[:line_referential], object.company]
)
- if h.policy(Chouette::Line).create? &&
+
+ if h.policy(Chouette::Line).update? &&
context[:line_referential].organisations.include?(
context[:current_organisation]
)
@@ -47,8 +48,6 @@ class LineDecorator < Draper::Decorator
method: :delete,
data: {confirm: h.t('lines.actions.destroy_confirm')}
)
- end
-
links
end
end
diff --git a/app/decorators/network_decorator.rb b/app/decorators/network_decorator.rb
index 4f22141e0..1f62fe512 100644
--- a/app/decorators/network_decorator.rb
+++ b/app/decorators/network_decorator.rb
@@ -1,44 +1,44 @@
- class NetworkDecorator < Draper::Decorator
- decorates Chouette::Network
+class NetworkDecorator < Draper::Decorator
+ decorates Chouette::Network
- delegate_all
+ delegate_all
- # Requires:
- # context: {
- # line_referential: ,
- # }
- def action_links
- links = []
+ # Requires:
+ # context: {
+ # line_referential: ,
+ # }
+ def action_links
+ links = []
- if h.policy(Chouette::Network).create?
- links << Link.new(
- content: h.t('networks.actions.new'),
- href: h.new_line_referential_network_path(context[:line_referential])
- )
- end
-
- if h.policy(object).update?
- links << Link.new(
- content: h.t('networks.actions.edit'),
- href: h.edit_line_referential_network_path(
- context[:line_referential],
- object
- )
- )
- end
+ if h.policy(Chouette::Network).create?
+ links << Link.new(
+ content: h.t('networks.actions.new'),
+ href: h.new_line_referential_network_path(context[:line_referential])
+ )
+ end
- if h.policy(object).destroy?
- links << Link.new(
- content: h.destroy_link_content('networks.actions.destroy'),
- href: h.line_referential_network_path(
- context[:line_referential],
- object
- ),
- method: :delete,
- data: { confirm: t('networks.actions.destroy_confirm') }
+ if h.policy(object).update?
+ links << Link.new(
+ content: h.t('networks.actions.edit'),
+ href: h.edit_line_referential_network_path(
+ context[:line_referential],
+ object
)
- end
+ )
+ end
- links
+ if h.policy(object).destroy?
+ links << Link.new(
+ content: h.destroy_link_content('networks.actions.destroy'),
+ href: h.line_referential_network_path(
+ context[:line_referential],
+ object
+ ),
+ method: :delete,
+ data: { confirm: t('networks.actions.destroy_confirm') }
+ )
end
+
+ links
end
+end
diff --git a/app/decorators/route_decorator.rb b/app/decorators/route_decorator.rb
index ca35c2dde..510c941a3 100644
--- a/app/decorators/route_decorator.rb
+++ b/app/decorators/route_decorator.rb
@@ -1,75 +1,75 @@
- class RouteDecorator < Draper::Decorator
- decorates Chouette::Route
+class RouteDecorator < Draper::Decorator
+ decorates Chouette::Route
- delegate_all
+ delegate_all
- # Requires:
- # context: {
- # referential: ,
- # line:
- # }
- def action_links
- links = []
+ # Requires:
+ # context: {
+ # referential: ,
+ # line:
+ # }
+ def action_links
+ links = []
- if object.stop_points.any?
- links << Link.new(
- content: h.t('journey_patterns.index.title'),
- href: [
- context[:referential],
- context[:line],
- object,
- :journey_patterns_collection
- ]
- )
- end
-
- if object.journey_patterns.present?
- links << Link.new(
- content: h.t('vehicle_journeys.actions.index'),
- href: [
- context[:referential],
- context[:line],
- object,
- :vehicle_journeys
- ]
- )
- end
+ if object.stop_points.any?
+ links << Link.new(
+ content: h.t('journey_patterns.index.title'),
+ href: [
+ context[:referential],
+ context[:line],
+ object,
+ :journey_patterns_collection
+ ]
+ )
+ end
+ if object.journey_patterns.present?
links << Link.new(
- content: h.t('vehicle_journey_exports.new.title'),
- href: h.referential_line_route_vehicle_journey_exports_path(
+ content: h.t('vehicle_journeys.actions.index'),
+ href: [
context[:referential],
context[:line],
object,
- format: :zip
- )
+ :vehicle_journeys
+ ]
)
+ end
- if h.policy(object).duplicate?
- links << Link.new(
- content: h.t('routes.duplicate.title'),
- href: h.duplicate_referential_line_route_path(
- context[:referential],
- context[:line],
- object
- ),
- method: :post
- )
- end
+ links << Link.new(
+ content: h.t('vehicle_journey_exports.new.title'),
+ href: h.referential_line_route_vehicle_journey_exports_path(
+ context[:referential],
+ context[:line],
+ object,
+ format: :zip
+ )
+ )
- if h.policy(object).destroy?
- links << Link.new(
- content: h.destroy_link_content,
- href: h.referential_line_route_path(
- context[:referential],
- context[:line],
- object
- ),
- method: :delete,
- data: { confirm: h.t('routes.actions.destroy_confirm') }
- )
- end
+ if h.policy(object).duplicate?
+ links << Link.new(
+ content: h.t('routes.duplicate.title'),
+ href: h.duplicate_referential_line_route_path(
+ context[:referential],
+ context[:line],
+ object
+ ),
+ method: :post
+ )
+ end
- links
+ if h.policy(object).destroy?
+ links << Link.new(
+ content: h.destroy_link_content,
+ href: h.referential_line_route_path(
+ context[:referential],
+ context[:line],
+ object
+ ),
+ method: :delete,
+ data: { confirm: h.t('routes.actions.destroy_confirm') }
+ )
end
+
+ links
end
+end
diff --git a/app/decorators/routing_constraint_zone_decorator.rb b/app/decorators/routing_constraint_zone_decorator.rb
index 1d12cfc25..0b438a554 100644
--- a/app/decorators/routing_constraint_zone_decorator.rb
+++ b/app/decorators/routing_constraint_zone_decorator.rb
@@ -1,42 +1,42 @@
- class RoutingConstraintZoneDecorator < Draper::Decorator
- decorates Chouette::RoutingConstraintZone
+class RoutingConstraintZoneDecorator < Draper::Decorator
+ decorates Chouette::RoutingConstraintZone
- delegate_all
+ delegate_all
- # Requires:
- # context: {
- # referential: ,
- # line:
- # }
- def action_links
- links = []
+ # Requires:
+ # context: {
+ # referential: ,
+ # line:
+ # }
+ def action_links
+ links = []
- if h.policy(object).update?
- links << Link.new(
- content: h.t('actions.edit'),
- href: h.edit_referential_line_routing_constraint_zone_path(
- context[:referential],
- context[:line],
- object
- )
+ if h.policy(object).update?
+ links << Link.new(
+ content: h.t('actions.edit'),
+ href: h.edit_referential_line_routing_constraint_zone_path(
+ context[:referential],
+ context[:line],
+ object
)
- end
-
- if h.policy(object).destroy?
- links << Link.new(
- content: h.destroy_link_content,
- href: h.referential_line_routing_constraint_zone_path(
- context[:referential],
- context[:line],
- object
- ),
- method: :delete,
- data: {
- confirm: h.t('routing_constraint_zones.actions.destroy_confirm')
- }
- )
- end
+ )
+ end
- links
+ if h.policy(object).destroy?
+ links << Link.new(
+ content: h.destroy_link_content,
+ href: h.referential_line_routing_constraint_zone_path(
+ context[:referential],
+ context[:line],
+ object
+ ),
+ method: :delete,
+ data: {
+ confirm: h.t('routing_constraint_zones.actions.destroy_confirm')
+ }
+ )
end
+
+ links
end
+end
diff --git a/app/decorators/stop_area_decorator.rb b/app/decorators/stop_area_decorator.rb
index c64ecc9e3..4e777292d 100644
--- a/app/decorators/stop_area_decorator.rb
+++ b/app/decorators/stop_area_decorator.rb
@@ -1,43 +1,43 @@
- class StopAreaDecorator < Draper::Decorator
- decorates Chouette::StopArea
+class StopAreaDecorator < Draper::Decorator
+ decorates Chouette::StopArea
- delegate_all
+ delegate_all
- def action_links(stop_area = nil)
- links = []
- stop_area ||= object
+ def action_links(stop_area = nil)
+ links = []
+ stop_area ||= object
- if h.policy(Chouette::StopArea).new?
- links << Link.new(
- content: h.t('stop_areas.actions.new'),
- href: h.new_stop_area_referential_stop_area_path(
- stop_area.stop_area_referential
- )
+ if h.policy(Chouette::StopArea).new?
+ links << Link.new(
+ content: h.t('stop_areas.actions.new'),
+ href: h.new_stop_area_referential_stop_area_path(
+ stop_area.stop_area_referential
)
- end
-
- if h.policy(stop_area).update?
- links << Link.new(
- content: h.t('stop_areas.actions.edit'),
- href: h.edit_stop_area_referential_stop_area_path(
- stop_area.stop_area_referential,
- stop_area
- )
- )
- end
+ )
+ end
- if h.policy(stop_area).destroy?
- links << Link.new(
- content: h.destroy_link_content('stop_areas.actions.destroy'),
- href: h.stop_area_referential_stop_area_path(
- stop_area.stop_area_referential,
- stop_area
- ),
- method: :delete,
- data: { confirm: t('stop_areas.actions.destroy_confirm') }
+ if h.policy(stop_area).update?
+ links << Link.new(
+ content: h.t('stop_areas.actions.edit'),
+ href: h.edit_stop_area_referential_stop_area_path(
+ stop_area.stop_area_referential,
+ stop_area
)
- end
+ )
+ end
- links
+ if h.policy(stop_area).destroy?
+ links << Link.new(
+ content: h.destroy_link_content('stop_areas.actions.destroy'),
+ href: h.stop_area_referential_stop_area_path(
+ stop_area.stop_area_referential,
+ stop_area
+ ),
+ method: :delete,
+ data: { confirm: t('stop_areas.actions.destroy_confirm') }
+ )
end
+
+ links
end
+end
diff --git a/app/decorators/stop_point_decorator.rb b/app/decorators/stop_point_decorator.rb
index f87db73e8..196d6d490 100644
--- a/app/decorators/stop_point_decorator.rb
+++ b/app/decorators/stop_point_decorator.rb
@@ -1,9 +1,9 @@
- class StopPointDecorator < StopAreaDecorator
- decorates Chouette::StopPoint
+class StopPointDecorator < StopAreaDecorator
+ decorates Chouette::StopPoint
- delegate_all
+ delegate_all
- def action_links
- super(object.stop_area)
- end
+ def action_links
+ super(object.stop_area)
end
+end
diff --git a/app/decorators/time_table_decorator.rb b/app/decorators/time_table_decorator.rb
index e2a5a7a97..c6eeac176 100644
--- a/app/decorators/time_table_decorator.rb
+++ b/app/decorators/time_table_decorator.rb
@@ -1,55 +1,55 @@
- class TimeTableDecorator < Draper::Decorator
- decorates Chouette::TimeTable
+class TimeTableDecorator < Draper::Decorator
+ decorates Chouette::TimeTable
- delegate_all
+ delegate_all
- # Requires:
- # context: {
- # referential: ,
- # }
- def action_links
- links = []
+ # Requires:
+ # context: {
+ # referential: ,
+ # }
+ def action_links
+ links = []
- if object.calendar
- links << Link.new(
- content: h.t('actions.actualize'),
- href: h.actualize_referential_time_table_path(
- context[:referential],
- object
- ),
- method: :post
- )
- end
-
- if h.policy(object).edit?
- links << Link.new(
- content: h.t('actions.combine'),
- href: h.new_referential_time_table_time_table_combination_path(
- context[:referential],
- object
- )
- )
- end
+ if object.calendar
+ links << Link.new(
+ content: h.t('actions.actualize'),
+ href: h.actualize_referential_time_table_path(
+ context[:referential],
+ object
+ ),
+ method: :post
+ )
+ end
- if h.policy(object).duplicate?
- links << Link.new(
- content: h.t('actions.duplicate'),
- href: h.duplicate_referential_time_table_path(
- context[:referential],
- object
- )
+ if h.policy(object).edit?
+ links << Link.new(
+ content: h.t('actions.combine'),
+ href: h.new_referential_time_table_time_table_combination_path(
+ context[:referential],
+ object
)
- end
+ )
+ end
- if h.policy(object).destroy?
- links << Link.new(
- content: h.destroy_link_content,
- href: h.referential_time_table_path(context[:referential], object),
- method: :delete,
- data: { confirm: h.t('time_tables.actions.destroy_confirm') }
+ if h.policy(object).duplicate?
+ links << Link.new(
+ content: h.t('actions.duplicate'),
+ href: h.duplicate_referential_time_table_path(
+ context[:referential],
+ object
)
- end
+ )
+ end
- links
+ if h.policy(object).destroy?
+ links << Link.new(
+ content: h.destroy_link_content,
+ href: h.referential_time_table_path(context[:referential], object),
+ method: :delete,
+ data: { confirm: h.t('time_tables.actions.destroy_confirm') }
+ )
end
+
+ links
end
+end
diff --git a/app/helpers/custom_view_helper.rb b/app/helpers/custom_view_helper.rb
new file mode 100644
index 000000000..7e7291c81
--- /dev/null
+++ b/app/helpers/custom_view_helper.rb
@@ -0,0 +1,9 @@
+module CustomViewHelper
+
+ def render_custom_view(view)
+ view_name = [view, current_organisation.try(:custom_view)].compact.join('_')
+ Rails.logger.debug "Render custom view #{view_name}"
+ render partial: view_name
+ end
+
+end
diff --git a/app/helpers/import_resources_helper.rb b/app/helpers/import_resources_helper.rb
index 3ee96eb9b..1d870f68e 100644
--- a/app/helpers/import_resources_helper.rb
+++ b/app/helpers/import_resources_helper.rb
@@ -12,4 +12,8 @@ module ImportResourcesHelper
content_tag :span, '', class: "fa fa-circle text-#{cls}"
end
+ def import_resoruce_metrics(metrics)
+ metrics.delete_if {|k,v| !k.include?("count")}.deep_symbolize_keys
+ end
+
end
diff --git a/app/javascript/journey_patterns/actions/index.js b/app/javascript/journey_patterns/actions/index.js
index 8bea5a990..4ff3f77ea 100644
--- a/app/javascript/journey_patterns/actions/index.js
+++ b/app/javascript/journey_patterns/actions/index.js
@@ -90,10 +90,6 @@ const actions = {
resetValidation: (target) => {
$(target).parent().removeClass('has-error').children('.help-block').remove()
},
- humanOID : (oid) => {
- let shortOId = oid.split(':')[2].split("-").pop()
- return shortOId.length > 10 ? `${shortOId.slice(0, 10)}...` : shortOId
- },
validateFields : (fields) => {
const test = []
@@ -201,6 +197,7 @@ const actions = {
journeyPatterns.push({
name: val.name,
object_id: val.object_id,
+ short_id: val.short_id,
published_name: val.published_name,
registration_number: val.registration_number,
stop_points: val.route_short_description.stop_points,
diff --git a/app/javascript/journey_patterns/components/JourneyPattern.js b/app/javascript/journey_patterns/components/JourneyPattern.js
index 34d102c5d..d4c9816ec 100644
--- a/app/javascript/journey_patterns/components/JourneyPattern.js
+++ b/app/javascript/journey_patterns/components/JourneyPattern.js
@@ -68,7 +68,7 @@ export default class JourneyPattern extends Component{
{/* this.props.value.errors ? this.getErrors(this.props.value.errors) : '' */}
<div className='th'>
- <div className='strong mb-xs'>{this.props.value.object_id ? actions.humanOID(this.props.value.object_id) : '-'}</div>
+ <div className='strong mb-xs'>{this.props.value.object_id ? this.props.value.short_id : '-'}</div>
<div>{this.props.value.registration_number}</div>
<div>{actions.getChecked(this.props.value.stop_points).length} arrêt(s)</div>
diff --git a/app/javascript/vehicle_journeys/actions/index.js b/app/javascript/vehicle_journeys/actions/index.js
index 95c739893..ddb54d615 100644
--- a/app/javascript/vehicle_journeys/actions/index.js
+++ b/app/javascript/vehicle_journeys/actions/index.js
@@ -269,10 +269,6 @@ const actions = {
type: 'RECEIVE_TOTAL_COUNT',
total
}),
- humanOID: (oid) => {
- let shortOId = oid.split(':')[2].split("-").pop()
- return shortOId.length > 10 ? `${shortOId.slice(0, 10)}...` : shortOId
- },
fetchVehicleJourneys : (dispatch, currentPage, nextPage, queryString) => {
if(currentPage == undefined){
currentPage = 1
@@ -334,6 +330,7 @@ const actions = {
journey_pattern: val.journey_pattern,
published_journey_name: val.published_journey_name,
objectid: val.objectid,
+ short_id: val.short_id,
footnotes: val.footnotes,
time_tables: timeTables,
vehicle_journey_at_stops: vjasWithDelta,
diff --git a/app/javascript/vehicle_journeys/components/VehicleJourney.js b/app/javascript/vehicle_journeys/components/VehicleJourney.js
index 13f8eced2..8fb4b8a7e 100644
--- a/app/javascript/vehicle_journeys/components/VehicleJourney.js
+++ b/app/javascript/vehicle_journeys/components/VehicleJourney.js
@@ -49,8 +49,8 @@ export default class VehicleJourney extends Component {
return (
<div className={'t2e-item' + (this.props.value.deletable ? ' disabled' : '') + (this.props.value.errors ? ' has-error': '')}>
<div className='th'>
- <div className='strong mb-xs'>{this.props.value.objectid ? actions.humanOID(this.props.value.objectid) : '-'}</div>
- <div>{actions.humanOID(this.props.value.journey_pattern.objectid)}</div>
+ <div className='strong mb-xs'>{this.props.value.objectid ? this.props.value.short_id : '-'}</div>
+ <div>{this.props.value.journey_pattern.short_id}</div>
<div>
{time_tables.slice(0,3).map((tt, i)=>
<span key={i} className='vj_tt'>{this.timeTableURL(tt)}</span>
diff --git a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js
index 7ad3cf510..7d91896eb 100644
--- a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js
+++ b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js
@@ -72,7 +72,7 @@ export default class EditVehicleJourney extends Component {
<input
type='text'
className='form-control'
- value={actions.humanOID(this.props.modal.modalProps.vehicleJourney.journey_pattern.objectid) + ' - ' + (this.props.modal.modalProps.vehicleJourney.journey_pattern.name)}
+ value={this.props.modal.modalProps.vehicleJourney.journey_pattern.short_id + ' - ' + (this.props.modal.modalProps.vehicleJourney.journey_pattern.name)}
disabled={true}
/>
</div>
diff --git a/app/javascript/vehicle_journeys/components/tools/ShiftVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/ShiftVehicleJourney.js
index ebfbed9eb..a54e40502 100644
--- a/app/javascript/vehicle_journeys/components/tools/ShiftVehicleJourney.js
+++ b/app/javascript/vehicle_journeys/components/tools/ShiftVehicleJourney.js
@@ -49,7 +49,7 @@ export default class ShiftVehicleJourney extends Component {
<div className='modal-header'>
<h4 className='modal-title'>Mettre à jour une course</h4>
{(this.props.modal.type == 'shift') && (
- <em>Mettre à jour les horaires de la course {actions.humanOID(actions.getSelected(this.props.vehicleJourneys)[0].objectid)}</em>
+ <em>Mettre à jour les horaires de la course {actions.getSelected(this.props.vehicleJourneys)[0].short_id}</em>
)}
<span type="button" className="close modal-close" data-dismiss="modal">&times;</span>
</div>
diff --git a/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js b/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js
index 6069bf089..5b4ae564c 100644
--- a/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js
+++ b/app/javascript/vehicle_journeys/components/tools/select2s/MissionSelect2.js
@@ -42,7 +42,7 @@ export default class BSelect4 extends Component {
item => _.assign(
{},
item,
- { text: "<strong>" + item.published_name + " - " + actions.humanOID(item.object_id) + "</strong><br/><small>" + item.registration_number + "</small>" }
+ { text: "<strong>" + item.published_name + " - " + item.short_id + "</strong><br/><small>" + item.registration_number + "</small>" }
)
)
};
diff --git a/app/javascript/vehicle_journeys/components/tools/select2s/TimetableSelect2.js b/app/javascript/vehicle_journeys/components/tools/select2s/TimetableSelect2.js
index 60c3eab83..a90a9f7b8 100644
--- a/app/javascript/vehicle_journeys/components/tools/select2s/TimetableSelect2.js
+++ b/app/javascript/vehicle_journeys/components/tools/select2s/TimetableSelect2.js
@@ -44,7 +44,7 @@ export default class BSelect4 extends Component {
item => _.assign(
{},
item,
- {text: '<strong>' + "<span class='fa fa-circle' style='color:" + (item.color ? item.color : '#4B4B4B') + "'></span> " + item.comment + ' - ' + actions.humanOID(item.objectid) + '</strong><br/><small>' + (item.day_types ? item.day_types.match(/[A-Z]?[a-z]+/g).join(', ') : "") + '</small>'}
+ {text: '<strong>' + "<span class='fa fa-circle' style='color:" + (item.color ? item.color : '#4B4B4B') + "'></span> " + item.comment + ' - ' + item.short_id + '</strong><br/><small>' + (item.day_types ? item.day_types.match(/[A-Z]?[a-z]+/g).join(', ') : "") + '</small>'}
)
)
};
diff --git a/app/javascript/vehicle_journeys/components/tools/select2s/VJSelect2.js b/app/javascript/vehicle_journeys/components/tools/select2s/VJSelect2.js
index 7cccbbc05..37628fce0 100644
--- a/app/javascript/vehicle_journeys/components/tools/select2s/VJSelect2.js
+++ b/app/javascript/vehicle_journeys/components/tools/select2s/VJSelect2.js
@@ -42,7 +42,7 @@ export default class BSelect4b extends Component {
item => _.assign(
{},
item,
- { id: item.objectid, text: actions.humanOID(item.objectid) }
+ { id: item.objectid, text: item.short_id }
)
)
};
diff --git a/app/models/chouette.rb b/app/models/chouette.rb
deleted file mode 100644
index fe49300d4..000000000
--- a/app/models/chouette.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-module Chouette
- def self.use_relative_model_naming?
- true
- end
-end \ No newline at end of file
diff --git a/app/models/chouette/company.rb b/app/models/chouette/company.rb
index a06bf5d91..d79e5ff59 100644
--- a/app/models/chouette/company.rb
+++ b/app/models/chouette/company.rb
@@ -8,7 +8,6 @@ module Chouette
validates_format_of :registration_number, :with => %r{\A[0-9A-Za-z_-]+\Z}, :allow_nil => true, :allow_blank => true
validates_presence_of :name
- validates_presence_of :objectid_format
validates_format_of :url, :with => %r{\Ahttps?:\/\/([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?\Z}, :allow_nil => true, :allow_blank => true
def self.nullable_attributes
diff --git a/app/models/chouette/connection_link_type.rb b/app/models/chouette/connection_link_type.rb
index ca27ed5da..516395ed9 100644
--- a/app/models/chouette/connection_link_type.rb
+++ b/app/models/chouette/connection_link_type.rb
@@ -1,6 +1,5 @@
module Chouette
class ConnectionLinkType < ActiveSupport::StringInquirer
-
def initialize(text_code, numerical_code)
super text_code.to_s
@numerical_code = numerical_code
@@ -47,6 +46,5 @@ module Chouette
new(text_code, numerical_code)
end
end
-
end
end \ No newline at end of file
diff --git a/app/models/chouette/direction.rb b/app/models/chouette/direction.rb
index 41d703b56..2d3fea10a 100644
--- a/app/models/chouette/direction.rb
+++ b/app/models/chouette/direction.rb
@@ -1,6 +1,5 @@
module Chouette
class Direction < ActiveSupport::StringInquirer
-
def initialize(text_code, numerical_code)
super text_code.to_s
@numerical_code = numerical_code
@@ -56,6 +55,5 @@ module Chouette
new(text_code, numerical_code)
end
end
-
end
end \ No newline at end of file
diff --git a/app/models/chouette/journey_pattern_section.rb b/app/models/chouette/journey_pattern_section.rb
deleted file mode 100644
index 226a50c27..000000000
--- a/app/models/chouette/journey_pattern_section.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-module Chouette
- class JourneyPatternSection < Chouette::ActiveRecord
- belongs_to :journey_pattern
- belongs_to :route_section
-
- validates :journey_pattern_id, presence: true
- validates :route_section_id, presence: true
- validates :rank, presence: true, numericality: :only_integer
- validates :journey_pattern_id, uniqueness: { scope: [:route_section_id, :rank] }
-
- default_scope { order(:rank) }
-
- def self.update_by_journey_pattern_rank(journey_pattern_id, route_section_id, rank)
- jps = self.find_or_initialize_by(journey_pattern_id: journey_pattern_id, rank: rank)
- if route_section_id.present?
- jps.update_attributes(route_section_id: route_section_id)
- else
- jps.destroy
- end
- end
- end
-end \ No newline at end of file
diff --git a/app/models/chouette/network.rb b/app/models/chouette/network.rb
index c51de3984..3f07ebe0c 100644
--- a/app/models/chouette/network.rb
+++ b/app/models/chouette/network.rb
@@ -12,7 +12,6 @@ module Chouette
validates_format_of :registration_number, :with => %r{\A[0-9A-Za-z_-]+\Z}, :allow_nil => true, :allow_blank => true
validates_presence_of :name
- validates_presence_of :objectid_format
def self.object_id_key
"PTNetwork"
diff --git a/app/models/chouette/objectid/netex.rb b/app/models/chouette/objectid/netex.rb
index 57415ac98..5d27abb1f 100644
--- a/app/models/chouette/objectid/netex.rb
+++ b/app/models/chouette/objectid/netex.rb
@@ -8,10 +8,10 @@ module Chouette
validate :must_respect_format
def initialize(**attributes)
- @provider_id ||= (attributes[:provider_id] ||= 'chouette')
+ @provider_id = attributes[:provider_id] || 'chouette'
@object_type = attributes[:object_type]
@local_id = attributes[:local_id]
- @creation_id = (attributes[:creation_id] ||= 'LOC')
+ @creation_id = attributes[:creation_id] || 'LOC'
end
@@format = /^([A-Za-z_-]+):([A-Za-z]+):([0-9A-Za-z_-]+):([A-Za-z]+)$/
@@ -22,7 +22,7 @@ module Chouette
end
def must_respect_format
- self.to_s.match(format)
+ self.to_s.match(self.class.format)
end
def short_id
diff --git a/app/models/chouette/objectid/stif_netex.rb b/app/models/chouette/objectid/stif_netex.rb
index 80208af56..19fd42702 100644
--- a/app/models/chouette/objectid/stif_netex.rb
+++ b/app/models/chouette/objectid/stif_netex.rb
@@ -2,13 +2,15 @@ module Chouette
module Objectid
class StifNetex < Chouette::Objectid::Netex
+ @@format = Chouette::Objectid::Netex.format
+
def initialize(**attributes)
- @provider_id = (attributes[:provider_id] ||= 'stif')
+ @provider_id = attributes[:provider_id] ||= 'stif'
super
end
def short_id
- local_id.try(:split, "-").try(:[], -1)
+ local_id.try(:split, "-").try(:last)
end
end
end
diff --git a/app/models/chouette/objectid/stif_reflex.rb b/app/models/chouette/objectid/stif_reflex.rb
index cd0f62298..770f3c433 100644
--- a/app/models/chouette/objectid/stif_reflex.rb
+++ b/app/models/chouette/objectid/stif_reflex.rb
@@ -19,7 +19,7 @@ module Chouette
"#{self.country_code}:#{self.zip_code}:#{self.object_type}:#{self.local_id}:#{self.provider_id}"
end
- def short_id
+ def short_id
local_id
end
end
diff --git a/app/models/chouette/objectid_formatter/netex.rb b/app/models/chouette/objectid_formatter/netex.rb
index 7279fdaa5..00c539553 100644
--- a/app/models/chouette/objectid_formatter/netex.rb
+++ b/app/models/chouette/objectid_formatter/netex.rb
@@ -2,7 +2,8 @@ module Chouette
module ObjectidFormatter
class Netex
def before_validation(model)
- model.update_attributes(objectid: Chouette::Objectid::Netex.new(local_id: SecureRandom.uuid, object_type: model.class.name.gsub(/Chouette::/,'')).to_s) unless model.read_attribute(:objectid)
+ oid = Chouette::Objectid::Netex.new(local_id: SecureRandom.uuid, object_type: model.class.name.gsub('Chouette::',''))
+ model.update(objectid: oid.to_s) if oid.valid?
end
def after_commit(model)
@@ -11,7 +12,7 @@ module Chouette
def get_objectid(definition)
parts = definition.try(:split, ":")
- Chouette::Objectid::Netex.new(provider_id: parts[0], object_type: parts[1], local_id: parts[2], creation_id: parts[3]) rescue nil
+ Chouette::Objectid::Netex.new(provider_id: parts[0], object_type: parts[1], local_id: parts[2], creation_id: parts[3])
end
end
end
diff --git a/app/models/chouette/objectid_formatter/stif_codifligne.rb b/app/models/chouette/objectid_formatter/stif_codifligne.rb
index 0624fc8a8..eafd2a090 100644
--- a/app/models/chouette/objectid_formatter/stif_codifligne.rb
+++ b/app/models/chouette/objectid_formatter/stif_codifligne.rb
@@ -1,6 +1,6 @@
module Chouette
module ObjectidFormatter
- class Chouette::ObjectidFormatter::StifCodifligne
+ class StifCodifligne
def before_validation(model)
# unused method in this context
end
@@ -11,7 +11,7 @@ module Chouette
def get_objectid(definition)
parts = definition.try(:split, ":")
- Chouette::Objectid::StifCodifligne.new(provider_id: parts[0], sync_id: parts[1], object_type: parts[2], local_id: parts[3]) rescue nil
+ Chouette::Objectid::StifCodifligne.new(provider_id: parts[0], sync_id: parts[1], object_type: parts[2], local_id: parts[3])
end
end
end
diff --git a/app/models/chouette/objectid_formatter/stif_netex.rb b/app/models/chouette/objectid_formatter/stif_netex.rb
index 0256754bf..01ddfc528 100644
--- a/app/models/chouette/objectid_formatter/stif_netex.rb
+++ b/app/models/chouette/objectid_formatter/stif_netex.rb
@@ -1,17 +1,18 @@
module Chouette
module ObjectidFormatter
- class Chouette::ObjectidFormatter::StifNetex
+ class StifNetex
def before_validation(model)
- model.attributes = {objectid: "__pending_id__#{SecureRandom.uuid}"} unless model.read_attribute(:objectid)
+ model.attributes = {objectid: "__pending_id__#{SecureRandom.uuid}"}
end
def after_commit(model)
- model.update_attributes(objectid: Chouette::Objectid::StifNetex.new(provider_id: "stif", object_type: model.class.name.gsub(/Chouette::/,''), local_id: model.local_id).to_s)
+ oid = Chouette::Objectid::StifNetex.new(provider_id: "stif", object_type: model.class.name.gsub('Chouette::',''), local_id: model.local_id)
+ model.update(objectid: oid.to_s) if oid.valid?
end
def get_objectid(definition)
parts = definition.try(:split, ":")
- Chouette::Objectid::StifNetex.new(provider_id: parts[0], object_type: parts[1], local_id: parts[2], creation_id: parts[3]) rescue nil
+ Chouette::Objectid::StifNetex.new(provider_id: parts[0], object_type: parts[1], local_id: parts[2], creation_id: parts[3])
end
end
end
diff --git a/app/models/chouette/objectid_formatter/stif_reflex.rb b/app/models/chouette/objectid_formatter/stif_reflex.rb
index 5637f2806..5bfb21ecd 100644
--- a/app/models/chouette/objectid_formatter/stif_reflex.rb
+++ b/app/models/chouette/objectid_formatter/stif_reflex.rb
@@ -1,6 +1,6 @@
module Chouette
module ObjectidFormatter
- class Chouette::ObjectidFormatter::StifReflex
+ class StifReflex
def before_validation(model)
# unused method in this context
end
@@ -11,7 +11,7 @@ module Chouette
def get_objectid(definition)
parts = definition.try(:split, ":")
- Chouette::Objectid::StifReflex.new(country_code: parts[0], zip_code: parts[1], object_type: parts[2], local_id: parts[3], provider_id: parts[4]) rescue nil
+ Chouette::Objectid::StifReflex.new(country_code: parts[0], zip_code: parts[1], object_type: parts[2], local_id: parts[3], provider_id: parts[4])
end
end
end
diff --git a/app/models/chouette/route.rb b/app/models/chouette/route.rb
index d8e6533c4..1f4088aa7 100644
--- a/app/models/chouette/route.rb
+++ b/app/models/chouette/route.rb
@@ -183,12 +183,6 @@ module Chouette
return true
end
- def journey_patterns_control_route_sections
- self.journey_patterns.each do |jp|
- jp.control_route_sections
- end
- end
-
protected
def self.vehicle_journeys_timeless(stop_point_id)
diff --git a/app/models/chouette/route_section.rb b/app/models/chouette/route_section.rb
deleted file mode 100644
index e4b4347e7..000000000
--- a/app/models/chouette/route_section.rb
+++ /dev/null
@@ -1,83 +0,0 @@
-module Chouette
- class RouteSection < Chouette::TridentActiveRecord
- belongs_to :departure, class_name: 'Chouette::StopArea'
- belongs_to :arrival, class_name: 'Chouette::StopArea'
- has_many :journey_pattern_sections
- has_many :journey_patterns, through: :journey_pattern_sections, dependent: :destroy
-
- validates :departure, :arrival, :processed_geometry, presence: true
-
- scope :by_endpoint_name, ->(endpoint, name) do
- joins("INNER JOIN stop_areas #{endpoint} ON #{endpoint}.id = route_sections.#{endpoint}_id").where(["#{endpoint}.name ilike ?", "%#{name}%"])
- end
- scope :by_line_id, ->(line_id) do
- joins(:journey_pattern_sections, :journey_patterns).joins('INNER JOIN routes ON journey_patterns.route_id = routes.id').where("routes.line_id = #{line_id}")
- end
-
- def stop_areas
- [departure, arrival].compact
- end
-
- def default_geometry
- points = stop_areas.collect(&:geometry).compact
- GeoRuby::SimpleFeatures::LineString.from_points(points) if points.many?
- end
-
- def name
- stop_areas.map do |stop_area|
- stop_area.try(:name) or '?'
- end.join(' - ') + " (#{geometry_description})"
- end
-
- def via_count
- input_geometry ? [ input_geometry.points.count - 2, 0 ].max : 0
- end
-
- def geometry_description
- if input_geometry || processed_geometry
- [ "#{distance.to_i}m" ].tap do |parts|
- parts << "#{via_count} #{'via'.pluralize(via_count)}" if via_count > 0
- end.join(' - ')
- else
- "-"
- end
- end
-
- DEFAULT_PROCESSOR = Proc.new { |section| section.input_geometry || section.default_geometry.try(:to_rgeo) }
-
- @@processor = DEFAULT_PROCESSOR
- cattr_accessor :processor
-
- def instance_processor
- no_processing || processor.nil? ? DEFAULT_PROCESSOR : processor
- end
-
- def process_geometry
- if input_geometry_changed? || processed_geometry.nil?
- self.processed_geometry = instance_processor.call(self)
- self.distance = processed_geometry.to_georuby.to_wgs84.spherical_distance if processed_geometry
- end
-
- true
- end
- before_validation :process_geometry
-
- def editable_geometry=(geometry)
- self.input_geometry = geometry
- end
-
- def editable_geometry
- input_geometry.try(:to_georuby) or default_geometry
- end
-
- def editable_geometry_before_type_cast
- editable_geometry.to_ewkt
- end
-
- def geometry(mode = nil)
- mode ||= :processed
- mode == :editable ? editable_geometry : processed_geometry.to_georuby
- end
-
- end
-end \ No newline at end of file
diff --git a/app/models/chouette/routing_constraint_zone.rb b/app/models/chouette/routing_constraint_zone.rb
index 0691ef688..70b016a48 100644
--- a/app/models/chouette/routing_constraint_zone.rb
+++ b/app/models/chouette/routing_constraint_zone.rb
@@ -6,12 +6,12 @@ module Chouette
belongs_to :route
has_array_of :stop_points, class_name: 'Chouette::StopPoint'
- validates_presence_of :name, :stop_points, :route, :objectid_format
+ validates_presence_of :name, :stop_points, :route
# validates :stop_point_ids, length: { minimum: 2, too_short: I18n.t('activerecord.errors.models.routing_constraint_zone.attributes.stop_points.not_enough_stop_points') }
validate :stop_points_belong_to_route, :not_all_stop_points_selected
def local_id
- "IBOO-#{self.referential.id}-#{self.route.line.objectid.local_id}-#{self.route.objectid.local_id}-#{self.id}"
+ "IBOO-#{self.referential.id}-#{self.route.line.get_objectid.local_id}-#{self.route.id}-#{self.id}"
end
scope :order_by_stop_points_count, ->(direction) do
diff --git a/app/models/chouette/stop_area.rb b/app/models/chouette/stop_area.rb
index d96381ee8..5d8b5033f 100644
--- a/app/models/chouette/stop_area.rb
+++ b/app/models/chouette/stop_area.rb
@@ -3,11 +3,6 @@ require 'geo_ruby'
module Chouette
class StopArea < Chouette::ActiveRecord
- # FIXME http://jira.codehaus.org/browse/JRUBY-6358
- self.primary_key = "id"
-
- include Geokit::Mappable
- # include StifReflexAttributesSupport
include ProjectionFields
include StopAreaRestrictions
include StopAreaReferentialSupport
@@ -25,8 +20,6 @@ module Chouette
has_and_belongs_to_many :routing_lines, :class_name => 'Chouette::Line', :foreign_key => "stop_area_id", :association_foreign_key => "line_id", :join_table => "routing_constraints_lines", :order => "lines.number"
has_and_belongs_to_many :routing_stops, :class_name => 'Chouette::StopArea', :foreign_key => "parent_id", :association_foreign_key => "child_id", :join_table => "stop_areas_stop_areas", :order => "stop_areas.name"
- belongs_to :stop_area_referential
-
acts_as_tree :foreign_key => 'parent_id', :order => "name"
attr_accessor :stop_area_type
diff --git a/app/models/chouette/time_table.rb b/app/models/chouette/time_table.rb
index 172b73101..09d3e2244 100644
--- a/app/models/chouette/time_table.rb
+++ b/app/models/chouette/time_table.rb
@@ -53,7 +53,6 @@ module Chouette
accepts_nested_attributes_for :periods, :allow_destroy => :true
validates_presence_of :comment
- validates_presence_of :objectid_format
validates_associated :dates
validates_associated :periods
diff --git a/app/models/chouette/timeband.rb b/app/models/chouette/timeband.rb
index ec3ad43b9..21c81ab1c 100644
--- a/app/models/chouette/timeband.rb
+++ b/app/models/chouette/timeband.rb
@@ -15,9 +15,6 @@ module Chouette
validates :start_time, :end_time, presence: true
validates_with Chouette::TimebandValidator
- validates :start_time, :end_time, presence: true
- validates_with Chouette::TimebandValidator
-
default_scope { order(:start_time) }
def self.object_id_key
diff --git a/app/models/chouette/vehicle_journey.rb b/app/models/chouette/vehicle_journey.rb
index f178c9245..d7a660287 100644
--- a/app/models/chouette/vehicle_journey.rb
+++ b/app/models/chouette/vehicle_journey.rb
@@ -4,7 +4,6 @@ module Chouette
include VehicleJourneyRestrictions
include ObjectidSupport
include StifTransportModeEnumerations
-
# FIXME http://jira.codehaus.org/browse/JRUBY-6358
self.primary_key = "id"
@@ -66,7 +65,7 @@ module Chouette
[].tap do |attrs|
attrs << self.published_journey_name
attrs << self.published_journey_identifier
- attrs << self.try(:company).try(:objectid).try(:local_id)
+ attrs << self.try(:company).try(:get_objectid).try(:local_id)
attrs << self.footnotes.map(&:checksum).sort
attrs << self.vehicle_journey_at_stops.map(&:checksum).sort
end
diff --git a/app/models/compliance_control.rb b/app/models/compliance_control.rb
index 146c4e838..65e22643d 100644
--- a/app/models/compliance_control.rb
+++ b/app/models/compliance_control.rb
@@ -83,7 +83,7 @@ require_dependency 'route_control/omnibus_journey_pattern'
require_dependency 'route_control/opposite_route_terminus'
require_dependency 'route_control/opposite_route'
require_dependency 'route_control/stop_points_in_journey_pattern'
-require_dependency 'route_control/unactivated_stop_points'
+require_dependency 'route_control/unactivated_stop_point'
require_dependency 'route_control/zdl_stop_area'
require_dependency 'routing_constraint_zone_control/maximum_length'
require_dependency 'routing_constraint_zone_control/minimum_length'
diff --git a/app/models/concerns/line_referential_support.rb b/app/models/concerns/line_referential_support.rb
index 406730ddb..5eade3557 100644
--- a/app/models/concerns/line_referential_support.rb
+++ b/app/models/concerns/line_referential_support.rb
@@ -3,6 +3,7 @@ module LineReferentialSupport
included do
belongs_to :line_referential
+ validates_presence_of :line_referential
alias_method :referential, :line_referential
end
diff --git a/app/models/concerns/netex_attributes_support.rb b/app/models/concerns/netex_attributes_support.rb
deleted file mode 100644
index d78528dbf..000000000
--- a/app/models/concerns/netex_attributes_support.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-module NetexAttributesSupport
- extend ActiveSupport::Concern
-
- included do
- before_validation :prepare_auto_columns
-
- validates_presence_of :objectid
- validates_uniqueness_of :objectid
- validates_numericality_of :object_version
- validate :objectid_format_compliance
-
- before_validation :default_values, :on => :create
- end
-
- module ClassMethods
- def object_id_key
- model_name
- end
-
- def model_name
- ActiveModel::Name.new self, Chouette, self.name.demodulize
- end
- end
-
- def objectid
- Chouette::NetexObjectId.new read_attribute(:objectid)
- end
-
- def prepare_auto_columns
- if object_version.nil?
- self.object_version = 1
- else
- self.object_version += 1
- end
- self.creator_id = 'chouette'
- end
-
- def fix_uniq_objectid
- base_objectid = objectid.rpartition(":").first
- self.objectid = "#{base_objectid}:#{id}"
- if !valid?
- base_objectid="#{objectid}_"
- cnt=1
- while !valid?
- self.objectid = "#{base_objectid}#{cnt}"
- cnt += 1
- end
- end
-
- end
-
- def objectid_format_compliance
- if !objectid.valid?
- errors.add :objectid, I18n.t("activerecord.errors.models.trident.invalid_object_id", type: self.class.object_id_key)
- end
- end
-
- def uniq_objectid
- # OPTIMIZEME
- i = 0
- baseobjectid = objectid
- while self.class.exists?(:objectid => objectid)
- i += 1
- self.objectid = baseobjectid+"_"+i.to_s
- end
- end
-
- def default_values
- self.object_version ||= 1
- end
-
-end
diff --git a/app/models/concerns/objectid_formatter_support.rb b/app/models/concerns/objectid_formatter_support.rb
index 2138ac89e..34a51740f 100644
--- a/app/models/concerns/objectid_formatter_support.rb
+++ b/app/models/concerns/objectid_formatter_support.rb
@@ -2,13 +2,15 @@ module ObjectidFormatterSupport
extend ActiveSupport::Concern
included do
- validates_presence_of :objectid_formater_class
+ extend Enumerize
+ enumerize :objectid_format, in: %w(netex stif_netex stif_reflex stif_codifligne), default: 'netex'
+ validates_presence_of :objectid_format
- def objectid_formater
- objectid_formater_class.new
+ def objectid_formatter
+ objectid_formatter_class.new
end
- def objectid_formater_class
+ def objectid_formatter_class
"Chouette::ObjectidFormatter::#{read_attribute(:objectid_format).camelcase}".constantize if read_attribute(:objectid_format)
end
end
diff --git a/app/models/concerns/objectid_support.rb b/app/models/concerns/objectid_support.rb
index f20723f63..cec36678e 100644
--- a/app/models/concerns/objectid_support.rb
+++ b/app/models/concerns/objectid_support.rb
@@ -2,25 +2,21 @@ module ObjectidSupport
extend ActiveSupport::Concern
included do
- before_validation :before_validation_objectid
+ before_validation :before_validation_objectid, unless: Proc.new {|model| model.read_attribute(:objectid)}
after_commit :after_commit_objectid, on: :create, if: Proc.new {|model| model.read_attribute(:objectid).try(:include?, '__pending_id__')}
- validates_presence_of :objectid_format, :objectid
+ validates_presence_of :objectid
validates_uniqueness_of :objectid, skip_validation: Proc.new {|model| model.read_attribute(:objectid).nil?}
def before_validation_objectid
- self.referential.objectid_formater.before_validation self
+ self.referential.objectid_formatter.before_validation self
end
def after_commit_objectid
- self.referential.objectid_formater.after_commit self
+ self.referential.objectid_formatter.after_commit self
end
def get_objectid
- self.referential.objectid_formater.get_objectid read_attribute(:objectid) if objectid_format && read_attribute(:objectid)
- end
-
- def get_objectid
- self.referential.objectid_formater.get_objectid read_attribute(:objectid) if objectid_format && read_attribute(:objectid)
+ self.referential.objectid_formatter.get_objectid read_attribute(:objectid) if self.referential.objectid_format && read_attribute(:objectid)
end
def objectid
@@ -30,9 +26,5 @@ module ObjectidSupport
def objectid_class
get_objectid.try(:class)
end
-
- def objectid_format
- self.referential.objectid_format
- end
end
end
diff --git a/app/models/concerns/stif_codifligne_attributes_support.rb b/app/models/concerns/stif_codifligne_attributes_support.rb
deleted file mode 100644
index 0cd2cccc4..000000000
--- a/app/models/concerns/stif_codifligne_attributes_support.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-module StifCodifligneAttributesSupport
- extend ActiveSupport::Concern
-
- included do
- validates_presence_of :objectid
- end
-
- module ClassMethods
- def object_id_key
- model_name
- end
-
- def model_name
- ActiveModel::Name.new self, Chouette, self.name.demodulize
- end
- end
-
- def objectid
- Chouette::StifCodifligneObjectid.new read_attribute(:objectid)
- end
-end
diff --git a/app/models/concerns/stif_netex_attributes_support.rb b/app/models/concerns/stif_netex_attributes_support.rb
deleted file mode 100644
index 076acf491..000000000
--- a/app/models/concerns/stif_netex_attributes_support.rb
+++ /dev/null
@@ -1,58 +0,0 @@
-module StifNetexAttributesSupport
- extend ActiveSupport::Concern
-
- included do
- validates_numericality_of :object_version
- validates :objectid, uniqueness: true, presence: true
- validate :objectid_format_compliance
-
- after_save :build_objectid
- before_validation :default_values, on: :create
- end
-
- module ClassMethods
- def object_id_key
- model_name
- end
-
- def model_name
- ActiveModel::Name.new self, Chouette, self.name.demodulize
- end
- end
-
- def objectid_format_compliance
- errors.add :objectid, I18n.t("activerecord.errors.models.trident.invalid_object_id") if !objectid.valid?
- end
-
- def local_id
- "IBOO-#{self.referential.id}-#{self.id}"
- end
-
- def build_objectid
- if objectid.include? ':__pending_id__'
- self.objectid = Chouette::StifNetexObjectid.create(self.provider_id, self.model_name, self.local_id, self.boiv_id)
- self.save
- end
- end
-
- def default_values
- self.object_version ||= 1
-
- if self.objectid.to_s.empty?
- local_id = "__pending_id__#{rand(50)+ rand(50)}"
- self.objectid = Chouette::StifNetexObjectid.create(self.provider_id, self.model_name, local_id, self.boiv_id)
- end
- end
-
- def objectid
- Chouette::StifNetexObjectid.new read_attribute(:objectid)
- end
-
- def provider_id
- self.referential.workbench.organisation.code.underscore.parameterize
- end
-
- def boiv_id
- 'LOC'
- end
-end
diff --git a/app/models/concerns/stif_reflex_attributes_support.rb b/app/models/concerns/stif_reflex_attributes_support.rb
deleted file mode 100644
index 9dfd21f94..000000000
--- a/app/models/concerns/stif_reflex_attributes_support.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-module StifReflexAttributesSupport
- extend ActiveSupport::Concern
-
- included do
- validates_presence_of :objectid
- end
-
- module ClassMethods
- def object_id_key
- model_name
- end
-
- def model_name
- ActiveModel::Name.new self, Chouette, self.name.demodulize
- end
- end
-
- def objectid
- Chouette::StifReflexObjectid.new read_attribute(:objectid)
- end
-end
diff --git a/app/models/concerns/stop_area_referential_support.rb b/app/models/concerns/stop_area_referential_support.rb
index aa59cbd35..f29397b3a 100644
--- a/app/models/concerns/stop_area_referential_support.rb
+++ b/app/models/concerns/stop_area_referential_support.rb
@@ -3,6 +3,7 @@ module StopAreaReferentialSupport
included do
belongs_to :stop_area_referential
+ validates_presence_of :stop_area_referential
alias_method :referential, :stop_area_referential
end
diff --git a/app/models/line_referential.rb b/app/models/line_referential.rb
index d8cf74bda..15b2f6276 100644
--- a/app/models/line_referential.rb
+++ b/app/models/line_referential.rb
@@ -1,7 +1,6 @@
class LineReferential < ActiveRecord::Base
include ObjectidFormatterSupport
extend StifTransportModeEnumerations
- extend Enumerize
has_many :line_referential_memberships
has_many :organisations, through: :line_referential_memberships
@@ -11,7 +10,6 @@ class LineReferential < ActiveRecord::Base
has_many :networks, class_name: 'Chouette::Network'
has_many :line_referential_syncs, -> { order created_at: :desc }
has_many :workbenches
- enumerize :objectid_format, in: %w(netex stif_netex stif_reflex stif_codifligne), default: 'netex'
def add_member(organisation, options = {})
attributes = options.merge organisation: organisation
@@ -22,7 +20,6 @@ class LineReferential < ActiveRecord::Base
validates :sync_interval, presence: true
# need to define precise validation rules
validates_inclusion_of :sync_interval, :in => 1..30
- validates_presence_of :objectid_format
def operating_lines
lines.where(deactivated: false)
diff --git a/app/models/referential.rb b/app/models/referential.rb
index fa6bcbcf1..ee74bd9f5 100644
--- a/app/models/referential.rb
+++ b/app/models/referential.rb
@@ -1,12 +1,10 @@
class Referential < ActiveRecord::Base
include DataFormatEnumerations
include ObjectidFormatterSupport
- extend Enumerize
validates_presence_of :name
validates_presence_of :slug
validates_presence_of :prefix
- validates_presence_of :objectid_format
# Fixme #3657
# validates_presence_of :time_zone
# validates_presence_of :upper_corner
@@ -56,7 +54,6 @@ class Referential < ActiveRecord::Base
belongs_to :referential_suite
- enumerize :objectid_format, in: %w(netex stif_netex stif_reflex stif_codifligne), default: 'netex'
scope :ready, -> { where(ready: true) }
scope :in_periode, ->(periode) { where(id: referential_ids_in_periode(periode)) }
diff --git a/app/models/route_control/unactivated_stop_points.rb b/app/models/route_control/unactivated_stop_point.rb
index a903fff53..3066bb523 100644
--- a/app/models/route_control/unactivated_stop_points.rb
+++ b/app/models/route_control/unactivated_stop_point.rb
@@ -1,5 +1,5 @@
module RouteControl
- class UnactivatedStopPoints < ComplianceControl
+ class UnactivatedStopPoint < ComplianceControl
def self.default_code; "3-Route-10" end
end
diff --git a/app/models/stop_area_referential.rb b/app/models/stop_area_referential.rb
index 159ee07b3..54e895cd0 100644
--- a/app/models/stop_area_referential.rb
+++ b/app/models/stop_area_referential.rb
@@ -1,5 +1,4 @@
class StopAreaReferential < ActiveRecord::Base
- extend Enumerize
include ObjectidFormatterSupport
has_many :stop_area_referential_memberships
has_many :organisations, through: :stop_area_referential_memberships
@@ -7,8 +6,6 @@ class StopAreaReferential < ActiveRecord::Base
has_many :stop_areas, class_name: 'Chouette::StopArea'
has_many :stop_area_referential_syncs, -> {order created_at: :desc}
has_many :workbenches
- enumerize :objectid_format, in: %w(netex stif_netex stif_reflex stif_codifligne), default: 'netex'
- validates_presence_of :objectid_format
def add_member(organisation, options = {})
attributes = options.merge organisation: organisation
diff --git a/app/models/workbench.rb b/app/models/workbench.rb
index 95e4d1b68..e36589210 100644
--- a/app/models/workbench.rb
+++ b/app/models/workbench.rb
@@ -1,11 +1,9 @@
class Workbench < ActiveRecord::Base
include ObjectidFormatterSupport
- extend Enumerize
belongs_to :organisation
belongs_to :line_referential
belongs_to :stop_area_referential
belongs_to :output, class_name: 'ReferentialSuite'
- enumerize :objectid_format, in: %w(netex stif_netex stif_reflex stif_codifligne), default: 'netex'
has_many :lines, -> (workbench) { Stif::MyWorkbenchScopes.new(workbench).line_scope(self) }, through: :line_referential
has_many :networks, through: :line_referential
@@ -20,7 +18,6 @@ class Workbench < ActiveRecord::Base
validates :name, presence: true
validates :organisation, presence: true
validates :output, presence: true
- validates_presence_of :objectid_format
has_many :referentials
has_many :referential_metadatas, through: :referentials, source: :metadatas
diff --git a/app/policies/access_link_policy.rb b/app/policies/access_link_policy.rb
index 2b974ee71..1f1147f60 100644
--- a/app/policies/access_link_policy.rb
+++ b/app/policies/access_link_policy.rb
@@ -1,19 +1,19 @@
- class AccessLinkPolicy < ApplicationPolicy
- class Scope < Scope
- def resolve
- scope
- end
+class AccessLinkPolicy < ApplicationPolicy
+ class Scope < Scope
+ def resolve
+ scope
end
+ end
- def create?
- !archived? && organisation_match? && user.has_permission?('access_links.create')
- end
+ def create?
+ !archived? && organisation_match? && user.has_permission?('access_links.create')
+ end
- def update?
- !archived? && organisation_match? && user.has_permission?('access_links.update')
- end
+ def update?
+ !archived? && organisation_match? && user.has_permission?('access_links.update')
+ end
- def destroy?
- !archived? && organisation_match? && user.has_permission?('access_links.destroy')
- end
+ def destroy?
+ !archived? && organisation_match? && user.has_permission?('access_links.destroy')
end
+end
diff --git a/app/policies/access_point_policy.rb b/app/policies/access_point_policy.rb
index 368cf14e7..41436e77c 100644
--- a/app/policies/access_point_policy.rb
+++ b/app/policies/access_point_policy.rb
@@ -1,19 +1,19 @@
- class AccessPointPolicy < ApplicationPolicy
- class Scope < Scope
- def resolve
- scope
- end
+class AccessPointPolicy < ApplicationPolicy
+ class Scope < Scope
+ def resolve
+ scope
end
+ end
- def create?
- !archived? && organisation_match? && user.has_permission?('access_points.create')
- end
+ def create?
+ !archived? && organisation_match? && user.has_permission?('access_points.create')
+ end
- def update?
- !archived? && organisation_match? && user.has_permission?('access_points.update')
- end
+ def update?
+ !archived? && organisation_match? && user.has_permission?('access_points.update')
+ end
- def destroy?
- !archived? && organisation_match? && user.has_permission?('access_points.destroy')
- end
+ def destroy?
+ !archived? && organisation_match? && user.has_permission?('access_points.destroy')
end
+end
diff --git a/app/policies/company_policy.rb b/app/policies/company_policy.rb
index d29836e07..45386aba4 100644
--- a/app/policies/company_policy.rb
+++ b/app/policies/company_policy.rb
@@ -1,7 +1,7 @@
- class CompanyPolicy < ApplicationPolicy
- class Scope < Scope
- def resolve
- scope
- end
+class CompanyPolicy < ApplicationPolicy
+ class Scope < Scope
+ def resolve
+ scope
end
end
+ end
diff --git a/app/policies/connection_link_policy.rb b/app/policies/connection_link_policy.rb
index 7cf0b7131..240c2a804 100644
--- a/app/policies/connection_link_policy.rb
+++ b/app/policies/connection_link_policy.rb
@@ -1,19 +1,19 @@
- class ConnectionLinkPolicy < ApplicationPolicy
- class Scope < Scope
- def resolve
- scope
- end
+class ConnectionLinkPolicy < ApplicationPolicy
+ class Scope < Scope
+ def resolve
+ scope
end
+ end
- def create?
- !archived? && organisation_match? && user.has_permission?('connection_links.create')
- end
+ def create?
+ !archived? && organisation_match? && user.has_permission?('connection_links.create')
+ end
- def destroy?
- !archived? && organisation_match? && user.has_permission?('connection_links.destroy')
- end
+ def destroy?
+ !archived? && organisation_match? && user.has_permission?('connection_links.destroy')
+ end
- def update?
- !archived? && organisation_match? && user.has_permission?('connection_links.update')
- end
+ def update?
+ !archived? && organisation_match? && user.has_permission?('connection_links.update')
end
+end
diff --git a/app/policies/group_of_line_policy.rb b/app/policies/group_of_line_policy.rb
index 60c60184c..03e94449d 100644
--- a/app/policies/group_of_line_policy.rb
+++ b/app/policies/group_of_line_policy.rb
@@ -1,7 +1,7 @@
- class GroupOfLinePolicy < ApplicationPolicy
- class Scope < Scope
- def resolve
- scope
- end
+class GroupOfLinePolicy < ApplicationPolicy
+ class Scope < Scope
+ def resolve
+ scope
end
end
+end
diff --git a/app/policies/journey_pattern_policy.rb b/app/policies/journey_pattern_policy.rb
index c0c9218c2..12bcced17 100644
--- a/app/policies/journey_pattern_policy.rb
+++ b/app/policies/journey_pattern_policy.rb
@@ -1,20 +1,20 @@
- class JourneyPatternPolicy < ApplicationPolicy
+class JourneyPatternPolicy < ApplicationPolicy
- class Scope < Scope
- def resolve
- scope
- end
+ class Scope < Scope
+ def resolve
+ scope
end
+ end
- def create?
- !archived? && organisation_match? && user.has_permission?('journey_patterns.create')
- end
+ def create?
+ !archived? && organisation_match? && user.has_permission?('journey_patterns.create')
+ end
- def destroy?
- !archived? && organisation_match? && user.has_permission?('journey_patterns.destroy')
- end
+ def destroy?
+ !archived? && organisation_match? && user.has_permission?('journey_patterns.destroy')
+ end
- def update?
- !archived? && organisation_match? && user.has_permission?('journey_patterns.update')
- end
+ def update?
+ !archived? && organisation_match? && user.has_permission?('journey_patterns.update')
end
+end
diff --git a/app/policies/line_policy.rb b/app/policies/line_policy.rb
index 559f4e2f8..acb0d79e7 100644
--- a/app/policies/line_policy.rb
+++ b/app/policies/line_policy.rb
@@ -1,23 +1,23 @@
- class LinePolicy < ApplicationPolicy
+class LinePolicy < ApplicationPolicy
- class Scope < Scope
- def resolve
- scope
- end
- end
-
- def create_footnote?
- !archived? && organisation_match? && user.has_permission?('footnotes.create')
+ class Scope < Scope
+ def resolve
+ scope
end
+ end
- def edit_footnote?
- !archived? && organisation_match? && user.has_permission?('footnotes.update')
- end
+ def create_footnote?
+ !archived? && organisation_match? && user.has_permission?('footnotes.create')
+ end
- def destroy_footnote?
- !archived? && organisation_match? && user.has_permission?('footnotes.destroy')
- end
+ def edit_footnote?
+ !archived? && organisation_match? && user.has_permission?('footnotes.update')
+ end
- def update_footnote? ; edit_footnote? end
- def new_footnote? ; create_footnote? end
+ def destroy_footnote?
+ !archived? && organisation_match? && user.has_permission?('footnotes.destroy')
end
+
+ def update_footnote? ; edit_footnote? end
+ def new_footnote? ; create_footnote? end
+end
diff --git a/app/policies/network_policy.rb b/app/policies/network_policy.rb
index 75105b7f8..9f86451a5 100644
--- a/app/policies/network_policy.rb
+++ b/app/policies/network_policy.rb
@@ -1,7 +1,7 @@
- class NetworkPolicy < ApplicationPolicy
- class Scope < Scope
- def resolve
- scope
- end
+class NetworkPolicy < ApplicationPolicy
+ class Scope < Scope
+ def resolve
+ scope
end
end
+end
diff --git a/app/policies/route_policy.rb b/app/policies/route_policy.rb
index b49f7bca7..7e9fe251a 100644
--- a/app/policies/route_policy.rb
+++ b/app/policies/route_policy.rb
@@ -1,23 +1,23 @@
- class RoutePolicy < ApplicationPolicy
- class Scope < Scope
- def resolve
- scope
- end
+class RoutePolicy < ApplicationPolicy
+ class Scope < Scope
+ def resolve
+ scope
end
+ end
- def create?
- !archived? && organisation_match? && user.has_permission?('routes.create')
- end
+ def create?
+ !archived? && organisation_match? && user.has_permission?('routes.create')
+ end
- def destroy?
- !archived? && organisation_match? && user.has_permission?('routes.destroy')
- end
+ def destroy?
+ !archived? && organisation_match? && user.has_permission?('routes.destroy')
+ end
- def update?
- !archived? && organisation_match? && user.has_permission?('routes.update')
- end
+ def update?
+ !archived? && organisation_match? && user.has_permission?('routes.update')
+ end
- def duplicate?
- create?
- end
+ def duplicate?
+ create?
end
+end
diff --git a/app/policies/routing_constraint_zone_policy.rb b/app/policies/routing_constraint_zone_policy.rb
index 6bdc69d5c..3cfcf46ff 100644
--- a/app/policies/routing_constraint_zone_policy.rb
+++ b/app/policies/routing_constraint_zone_policy.rb
@@ -1,19 +1,19 @@
- class RoutingConstraintZonePolicy < ApplicationPolicy
- class Scope < Scope
- def resolve
- scope
- end
+class RoutingConstraintZonePolicy < ApplicationPolicy
+ class Scope < Scope
+ def resolve
+ scope
end
+ end
- def create?
- !archived? && organisation_match? && user.has_permission?('routing_constraint_zones.create')
- end
+ def create?
+ !archived? && organisation_match? && user.has_permission?('routing_constraint_zones.create')
+ end
- def destroy?
- !archived? && organisation_match? && user.has_permission?('routing_constraint_zones.destroy')
- end
+ def destroy?
+ !archived? && organisation_match? && user.has_permission?('routing_constraint_zones.destroy')
+ end
- def update?
- !archived? && organisation_match? && user.has_permission?('routing_constraint_zones.update')
- end
+ def update?
+ !archived? && organisation_match? && user.has_permission?('routing_constraint_zones.update')
end
+end
diff --git a/app/policies/stop_area_policy.rb b/app/policies/stop_area_policy.rb
index eaf4efe60..de8ecda8d 100644
--- a/app/policies/stop_area_policy.rb
+++ b/app/policies/stop_area_policy.rb
@@ -1,7 +1,7 @@
- class StopAreaPolicy < ApplicationPolicy
- class Scope < Scope
- def resolve
- scope
- end
+class StopAreaPolicy < ApplicationPolicy
+ class Scope < Scope
+ def resolve
+ scope
end
end
+end
diff --git a/app/policies/time_table_policy.rb b/app/policies/time_table_policy.rb
index 4638eabd8..92d3aef3e 100644
--- a/app/policies/time_table_policy.rb
+++ b/app/policies/time_table_policy.rb
@@ -1,32 +1,32 @@
- class TimeTablePolicy < ApplicationPolicy
+class TimeTablePolicy < ApplicationPolicy
- class Scope < Scope
- def resolve
- scope
- end
+ class Scope < Scope
+ def resolve
+ scope
end
+ end
- def create?
- !archived? && organisation_match? && user.has_permission?('time_tables.create')
- end
+ def create?
+ !archived? && organisation_match? && user.has_permission?('time_tables.create')
+ end
- def destroy?
- !archived? && organisation_match? && user.has_permission?('time_tables.destroy')
- end
+ def destroy?
+ !archived? && organisation_match? && user.has_permission?('time_tables.destroy')
+ end
- def update?
- !archived? && organisation_match? && user.has_permission?('time_tables.update')
- end
+ def update?
+ !archived? && organisation_match? && user.has_permission?('time_tables.update')
+ end
- def actualize?
- !archived? && organisation_match? && edit?
- end
+ def actualize?
+ !archived? && organisation_match? && edit?
+ end
- def duplicate?
- !archived? && organisation_match? && create?
- end
+ def duplicate?
+ !archived? && organisation_match? && create?
+ end
- def month?
- update?
- end
+ def month?
+ update?
end
+end
diff --git a/app/policies/vehicle_journey_policy.rb b/app/policies/vehicle_journey_policy.rb
index 1aa7a812e..24040455f 100644
--- a/app/policies/vehicle_journey_policy.rb
+++ b/app/policies/vehicle_journey_policy.rb
@@ -1,19 +1,19 @@
- class VehicleJourneyPolicy < ApplicationPolicy
- class Scope < Scope
- def resolve
- scope
- end
+class VehicleJourneyPolicy < ApplicationPolicy
+ class Scope < Scope
+ def resolve
+ scope
end
+ end
- def create?
- !archived? && organisation_match? && user.has_permission?('vehicle_journeys.create')
- end
+ def create?
+ !archived? && organisation_match? && user.has_permission?('vehicle_journeys.create')
+ end
- def destroy?
- !archived? && organisation_match? && user.has_permission?('vehicle_journeys.destroy')
- end
+ def destroy?
+ !archived? && organisation_match? && user.has_permission?('vehicle_journeys.destroy')
+ end
- def update?
- !archived? && organisation_match? && user.has_permission?('vehicle_journeys.update')
- end
+ def update?
+ !archived? && organisation_match? && user.has_permission?('vehicle_journeys.update')
end
+end
diff --git a/app/views/api/v1/journey_patterns/show.rabl b/app/views/api/v1/journey_patterns/show.rabl
index 7c3af52fc..3ea1bb6ff 100644
--- a/app/views/api/v1/journey_patterns/show.rabl
+++ b/app/views/api/v1/journey_patterns/show.rabl
@@ -5,13 +5,6 @@ extends "api/v1/trident_objects/show"
attributes attr, :unless => lambda { |m| m.send( attr).nil?}
end
-node do |jp|
- {
- short_id: jp.objectid.parts.try(:third)
- }
-
-end
-
node(:route_short_description) do |journey_pattern|
partial("api/v1/routes/short_description", :object => journey_pattern.route)
end
diff --git a/app/views/api/v1/trident_objects/show.rabl b/app/views/api/v1/trident_objects/show.rabl
index e53a791ef..e58c0a866 100644
--- a/app/views/api/v1/trident_objects/show.rabl
+++ b/app/views/api/v1/trident_objects/show.rabl
@@ -3,3 +3,4 @@ attributes :objectid => :object_id
attributes attr, :unless => lambda { |m| m.send( attr).nil?}
end
+node { |model| {short_id: model.get_objectid.short_id} } \ No newline at end of file
diff --git a/app/views/autocomplete_time_tables/index.rabl b/app/views/autocomplete_time_tables/index.rabl
index 7aafdca16..b17411684 100644
--- a/app/views/autocomplete_time_tables/index.rabl
+++ b/app/views/autocomplete_time_tables/index.rabl
@@ -10,7 +10,7 @@ node do |time_table|
:tags => time_table.tags.join(','),
:color => time_table.color,
:day_types => time_table.display_day_types,
- :short_id => time_table.objectid.parts.try(:third),
- :text => "<strong><span class='fa fa-circle' style='color:" + (time_table.color ? time_table.color : '#4b4b4b') + "'></span> " + time_table.comment + " - " + time_table.objectid.parts.try(:third) + "</strong><br/><small>" + time_table.display_day_types + "</small>"
+ :short_id => time_table.get_objectid.short_id,
+ :text => "<strong><span class='fa fa-circle' style='color:" + (time_table.color ? time_table.color : '#4b4b4b') + "'></span> " + time_table.comment + " - " + time_table.get_objectid.short_id + "</strong><br/><small>" + time_table.display_day_types + "</small>"
}
end
diff --git a/app/views/compliance_controls/_form.html.slim b/app/views/compliance_controls/_form.html.slim
index d342f120a..1bcfc093e 100644
--- a/app/views/compliance_controls/_form.html.slim
+++ b/app/views/compliance_controls/_form.html.slim
@@ -6,7 +6,7 @@
= f.input :compliance_control_set_id, as: :hidden, input_html: { value: @compliance_control_set.id }
= f.input :code
= f.input :criticity
- = f.association :compliance_control_block, collection: @compliance_control_set.compliance_control_blocks, label_method: lambda { |block| transport_mode(block.transport_mode, block.transport_submode) }
+ = f.association :compliance_control_block, collection: @compliance_control_set.compliance_control_blocks, label_method: lambda { |block| transport_mode_text(block) }
= f.input :comment
- f.object.class.dynamic_attributes.each do |attribute|
- if attribute == :target
diff --git a/app/views/dashboards/_dashboard.html.slim b/app/views/dashboards/_dashboard.html.slim
new file mode 100644
index 000000000..0b5deffc6
--- /dev/null
+++ b/app/views/dashboards/_dashboard.html.slim
@@ -0,0 +1,37 @@
+.row
+ .col-lg-6.col-md-6.col-sm-6.col-xs-12
+ - @dashboard.current_organisation.workbenches.each do |workbench|
+ .panel.panel-default
+ .panel-heading
+ h3.panel-title.with_actions
+ div
+ = workbench.name
+ span.badge.ml-xs = workbench.referentials.count if workbench.referentials.present?
+
+ div
+ = link_to '', workbench_path(workbench), class: ' fa fa-chevron-right pull-right', title: t('.offers.see')
+
+ - if workbench.referentials.present?
+ .list-group
+ - workbench.referentials.limit(5).each do |referential|
+ = link_to referential.name, referential_path(referential, workbench_id: referential.workbench_id, current_workbench_id: workbench.id), class: 'list-group-item'
+ - else
+ .panel-body
+ em.small.text-muted = t('.offers.no_content')
+
+ .col-lg-6.col-md-6.col-sm-6.col-xs-12
+ .panel.panel-default
+ .panel-heading
+ h3.panel-title
+ = "Référentiels d'arrêts"
+ .list-group
+ - @dashboard.current_organisation.stop_area_referentials.each do |referential|
+ = link_to referential.name, stop_area_referential_stop_areas_path(referential), class: 'list-group-item'
+
+ .panel.panel-default
+ .panel-heading
+ h3.panel-title
+ = "Référentiels de lignes"
+ .list-group
+ - @dashboard.current_organisation.line_referentials.all.each do |referential|
+ = link_to referential.name, line_referential_lines_path(referential), class: 'list-group-item'
diff --git a/app/views/import_resources/index.html.slim b/app/views/import_resources/index.html.slim
index 849ed6d8d..57c83ce82 100644
--- a/app/views/import_resources/index.html.slim
+++ b/app/views/import_resources/index.html.slim
@@ -38,7 +38,7 @@
), \
TableBuilderHelper::Column.new( \
name: 'Résultat des tests' , \
- attribute: Proc.new { |n| I18n.t('import_resources.index.metrics', n.metrics.deep_symbolize_keys) }, \
+ attribute: Proc.new { |n| I18n.t('import_resources.index.metrics', import_resoruce_metrics(n.metrics) }, \
sortable: false, \
), \
TableBuilderHelper::Column.new( \
diff --git a/app/views/imports/show.html.slim b/app/views/imports/show.html.slim
index 69ee44f9f..775b09e8b 100644
--- a/app/views/imports/show.html.slim
+++ b/app/views/imports/show.html.slim
@@ -58,7 +58,7 @@
overhead: [ \
{}, \
{ \
- title: "#{@import.children_succeedeed} jeu de données validé sur #{@import.children.count} présents dans l'archive", \
+ title: "#{@import.children_succeedeed} jeu de données validé sur #{@import.children.count} présent(s) dans l'archive", \
width: 1, \
cls: "#{@import.import_status_css_class} full-border" \
}, { \
diff --git a/app/views/layouts/navigation/_main_nav_left.html.slim b/app/views/layouts/navigation/_main_nav_left.html.slim
index 837b9cb73..b63c2dd1c 100644
--- a/app/views/layouts/navigation/_main_nav_left.html.slim
+++ b/app/views/layouts/navigation/_main_nav_left.html.slim
@@ -1,5 +1,3 @@
-- @localizationUrl = "#{params[:controller]}##{params[:action]}"
-
.nav-menu#menu_left
.openMenu title='Ouvrir le menu'
@@ -7,108 +5,4 @@
.closeMenu title='Fermer le menu'
.brandname = t('brandname')
- #menu-items.panel-group
- .menu-item.panel
- .panel-heading
- h4.panel-title
- = link_to '#miOne', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do
- |Offres courantes
-
- #miOne.panel-collapse.collapse
- .list-group
- = link_to root_path, class: "list-group-item #{(@localizationUrl == 'workbenches#index') ? 'active' : ''}" do
- span Tableau de bord
- = link_to '#', class: 'list-group-item' do
- span Offre de mon organisation
- = link_to '#', class: 'list-group-item' do
- span Offre IDF
-
- .menu-item.panel
- .panel-heading
- h4.panel-title
- = link_to '#miTwo', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do
- |Espace de travail
-
- #miTwo.panel-collapse.collapse
- .list-group
- - if current_user
- = link_to workbench_path(current_offer_workbench), class: "list-group-item #{params[:controller] == 'workbenches' ? 'active' : ''}" do
- span Jeux de données
- = link_to workbench_imports_path(current_offer_workbench), class: "list-group-item #{(params[:controller] == 'imports') ? 'active' : ''}" do
- span Import
- = link_to calendars_path, class: 'list-group-item' do
- span Modèles de calendrier
- = link_to workbench_compliance_check_sets_path(current_offer_workbench), class: 'list-group-item' do
- span Rapport de contrôle
- = link_to compliance_control_sets_path, class: 'list-group-item' do
- span Jeux de contrôle
-
- .menu-item.panel
- .panel-heading
- h4.panel-title
- = link_to '#miThree', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do
- |Données
-
- #miThree.panel-collapse.collapse
- - if @referential.try(:id) && respond_to?(:current_referential)
- .list-group
- .list-group-item
- = (current_referential.name).upcase
- .list-group
- = link_to referential_networks_path(current_referential), class: 'list-group-item' do
- span = t('networks.index.title')
-
- = link_to referential_companies_path(current_referential), class: 'list-group-item' do
- span = t('companies.index.title')
-
- = link_to '#', class: 'list-group-item disabled' do
- span Tracés
-
- = link_to referential_time_tables_path(current_referential), class: 'list-group-item' do
- span = t('time_tables.index.title')
-
- - else
- .panel-body
- em.text-muted
- = "Sélectionnez un jeu de données pour accéder à plus de fonctionnalités"
-
- .menu-item.panel
- .panel-heading
- h4.panel-title
- = link_to '#miFour', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do
- |Synchronisation
-
- #miFour.panel-collapse.collapse
- .list-group
- = link_to line_referential_path(1), class: "list-group-item #{(@localizationUrl == 'line_referentials#show') ? 'active' : ''}" do
- span Synchronisation iLICO
- = link_to stop_area_referential_path(1), class: "list-group-item #{(@localizationUrl == 'stop_area_referentials#show') ? 'active' : ''}" do
- span Synchronisation iCAR
-
- .menu-item.panel
- .panel-heading
- h4.panel-title
- = link_to '#miFive', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do
- |Outils
-
- #miFive.panel-collapse.collapse
- .list-group
- = link_to Rails.application.config.try(:portal_url), target: '_blank', class: 'list-group-item' do
- span
- span.fa.fa-2x.fa-circle
- |Portail (POSTIF)
-
- = link_to Rails.application.config.try(:codifligne_url), target: '_blank', class: 'list-group-item' do
- span
- span.fa.fa-2x.fa-circle
- |iLICO
-
- = link_to Rails.application.config.try(:reflex_url), target: '_blank', class: 'list-group-item' do
- span
- span.fa.fa-2x.fa-circle
- |iCAR
-
- = link_to '#', target: '_blank', class: 'list-group-item' do
- span
- span.fa.fa-2x.fa-circle
- |Support
+ = render_custom_view 'layouts/navigation/main_nav_left_content'
diff --git a/app/views/layouts/navigation/_main_nav_left_content.html.slim b/app/views/layouts/navigation/_main_nav_left_content.html.slim
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/app/views/layouts/navigation/_main_nav_left_content.html.slim
diff --git a/app/views/layouts/navigation/_main_nav_left_content_stif.html.slim b/app/views/layouts/navigation/_main_nav_left_content_stif.html.slim
new file mode 100644
index 000000000..3963d4cd4
--- /dev/null
+++ b/app/views/layouts/navigation/_main_nav_left_content_stif.html.slim
@@ -0,0 +1,107 @@
+- @localizationUrl = "#{params[:controller]}##{params[:action]}"
+
+#menu-items.panel-group
+ .menu-item.panel
+ .panel-heading
+ h4.panel-title
+ = link_to '#miOne', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do
+ |Offres courantes
+
+ #miOne.panel-collapse.collapse
+ .list-group
+ = link_to root_path, class: "list-group-item #{(@localizationUrl == 'workbenches#index') ? 'active' : ''}" do
+ span Tableau de bord
+ = link_to '#', class: 'list-group-item' do
+ span Offre de mon organisation
+ = link_to '#', class: 'list-group-item' do
+ span Offre IDF
+
+ .menu-item.panel
+ .panel-heading
+ h4.panel-title
+ = link_to '#miTwo', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do
+ |Espace de travail
+
+ #miTwo.panel-collapse.collapse
+ .list-group
+ - if current_user
+ = link_to workbench_path(current_offer_workbench), class: "list-group-item #{params[:controller] == 'workbenches' ? 'active' : ''}" do
+ span Jeux de données
+ = link_to workbench_imports_path(current_offer_workbench), class: "list-group-item #{(params[:controller] == 'imports') ? 'active' : ''}" do
+ span Import
+ = link_to calendars_path, class: 'list-group-item' do
+ span Modèles de calendrier
+ = link_to workbench_compliance_check_sets_path(current_offer_workbench), class: 'list-group-item' do
+ span Rapport de contrôle
+ = link_to compliance_control_sets_path, class: 'list-group-item' do
+ span Jeux de contrôle
+
+ .menu-item.panel
+ .panel-heading
+ h4.panel-title
+ = link_to '#miThree', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do
+ |Données
+
+ #miThree.panel-collapse.collapse
+ - if @referential.try(:id) && respond_to?(:current_referential)
+ .list-group
+ .list-group-item
+ = (current_referential.name).upcase
+ .list-group
+ = link_to referential_networks_path(current_referential), class: 'list-group-item' do
+ span = t('networks.index.title')
+
+ = link_to referential_companies_path(current_referential), class: 'list-group-item' do
+ span = t('companies.index.title')
+
+ = link_to '#', class: 'list-group-item disabled' do
+ span Tracés
+
+ = link_to referential_time_tables_path(current_referential), class: 'list-group-item' do
+ span = t('time_tables.index.title')
+
+ - else
+ .panel-body
+ em.text-muted
+ = "Sélectionnez un jeu de données pour accéder à plus de fonctionnalités"
+
+ .menu-item.panel
+ .panel-heading
+ h4.panel-title
+ = link_to '#miFour', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do
+ |Synchronisation
+
+ #miFour.panel-collapse.collapse
+ .list-group
+ = link_to line_referential_path(1), class: "list-group-item #{(@localizationUrl == 'line_referentials#show') ? 'active' : ''}" do
+ span Synchronisation iLICO
+ = link_to stop_area_referential_path(1), class: "list-group-item #{(@localizationUrl == 'stop_area_referentials#show') ? 'active' : ''}" do
+ span Synchronisation iCAR
+
+ .menu-item.panel
+ .panel-heading
+ h4.panel-title
+ = link_to '#miFive', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do
+ |Outils
+
+ #miFive.panel-collapse.collapse
+ .list-group
+ = link_to Rails.application.config.try(:portal_url), target: '_blank', class: 'list-group-item' do
+ span
+ span.fa.fa-2x.fa-circle
+ |Portail (POSTIF)
+
+ = link_to Rails.application.config.try(:codifligne_url), target: '_blank', class: 'list-group-item' do
+ span
+ span.fa.fa-2x.fa-circle
+ |iLICO
+
+ = link_to Rails.application.config.try(:reflex_url), target: '_blank', class: 'list-group-item' do
+ span
+ span.fa.fa-2x.fa-circle
+ |iCAR
+
+ = link_to '#', target: '_blank', class: 'list-group-item' do
+ span
+ span.fa.fa-2x.fa-circle
+ |Support
diff --git a/app/views/lines/index.html.slim b/app/views/lines/index.html.slim
index 0cb7ab493..911c95e0c 100644
--- a/app/views/lines/index.html.slim
+++ b/app/views/lines/index.html.slim
@@ -20,8 +20,8 @@
= table_builder_2 @lines,
[ \
TableBuilderHelper::Column.new( \
- name: 'ID Codifligne', \
- attribute: Proc.new { |n| n.get_objectid.local_id }, \
+ name: t('id_codif'), \
+ attribute: Proc.new { |n| n.get_objectid.short_id }, \
sortable: false \
), \
TableBuilderHelper::Column.new( \
diff --git a/app/views/lines/show.html.slim b/app/views/lines/show.html.slim
index 4c6c6fc95..ccf237154 100644
--- a/app/views/lines/show.html.slim
+++ b/app/views/lines/show.html.slim
@@ -21,7 +21,7 @@
.row
.col-lg-6.col-md-6.col-sm-12.col-xs-12
= definition_list t('metadatas'),
- { 'ID Codif' => @line.get_objectid.local_id,
+ { 'ID Codif' => @line.get_objectid.short_id,
'Activé' => (@line.deactivated? ? t('false') : t('true')),
@line.human_attribute_name(:network) => (@line.network.nil? ? t('lines.index.unset') : @line.network.name),
@line.human_attribute_name(:company) => (@line.company.nil? ? t('lines.index.unset') : @line.company.name),
diff --git a/app/views/referential_companies/index.html.slim b/app/views/referential_companies/index.html.slim
index 9f5cd5d62..3348dc722 100644
--- a/app/views/referential_companies/index.html.slim
+++ b/app/views/referential_companies/index.html.slim
@@ -26,7 +26,7 @@
= table_builder_2 @companies,
[ \
TableBuilderHelper::Column.new( \
- name: 'ID Codifligne', \
+ name: t('id_codif'), \
attribute: Proc.new { |n| n.try(:objectid).try(:local_id) }, \
sortable: false \
), \
diff --git a/app/views/referential_lines/show.html.slim b/app/views/referential_lines/show.html.slim
index 74542d2b6..7607c391b 100644
--- a/app/views/referential_lines/show.html.slim
+++ b/app/views/referential_lines/show.html.slim
@@ -21,7 +21,7 @@
.row
.col-lg-6.col-md-6.col-sm-12.col-xs-12
= definition_list t('metadatas'),
- { t('id_codif') => @line.get_objectid.local_id,
+ { t('id_codif') => @line.get_objectid.short_id,
'Activé' => (@line.deactivated? ? t('false') : t('true')),
@line.human_attribute_name(:network) => (@line.network.nil? ? t('lines.index.unset') : link_to(@line.network.name, [@referential, @line.network]) ),
@line.human_attribute_name(:company) => (@line.company.nil? ? t('lines.index.unset') : link_to(@line.company.name, [@referential, @line.company]) ),
@@ -47,7 +47,7 @@
= table_builder_2 @routes,
[ \
TableBuilderHelper::Column.new( \
- name: 'ID', \
+ name: 'Oid', \
attribute: Proc.new { |n| n.get_objectid.short_id }, \
sortable: false \
), \
diff --git a/app/views/referential_networks/index.html.slim b/app/views/referential_networks/index.html.slim
index 57d3e7f1f..6a2df6d16 100644
--- a/app/views/referential_networks/index.html.slim
+++ b/app/views/referential_networks/index.html.slim
@@ -26,8 +26,8 @@
= table_builder_2 @networks,
[ \
TableBuilderHelper::Column.new( \
- name: 'ID Codifligne', \
- attribute: Proc.new { |n| n.try(:objectid).try(:local_id) }, \
+ name: t('id_codif'), \
+ attribute: Proc.new { |n| n.get_objectid.try(:short_id) }, \
sortable: false \
),
TableBuilderHelper::Column.new( \
diff --git a/app/views/referential_networks/show.html.slim b/app/views/referential_networks/show.html.slim
index eab0cd51a..c2cc79e0d 100644
--- a/app/views/referential_networks/show.html.slim
+++ b/app/views/referential_networks/show.html.slim
@@ -21,4 +21,4 @@
.row
.col-lg-6.col-md-6.col-sm-12.col-xs-12
= definition_list t('metadatas'),
- { t('id_codif') => @network.try(:objectid).try(:local_id) }
+ { t('id_codif') => @network.try(:get_objectid).try(:local_id) }
diff --git a/app/views/referential_stop_areas/show.html.slim b/app/views/referential_stop_areas/show.html.slim
index b9a1c9899..7cc078ee0 100644
--- a/app/views/referential_stop_areas/show.html.slim
+++ b/app/views/referential_stop_areas/show.html.slim
@@ -19,7 +19,7 @@
.row
.col-lg-6.col-md-6.col-sm-12.col-xs-12
= definition_list t('metadatas'),
- { 'ID Reflex' => @stop_area.try(:user_objectid),
+ { t('id_reflex') => @stop_area.try(:user_objectid),
'Activé' => (@stop_area.deleted_at ? t('false') : t('true')),
@stop_area.human_attribute_name(:comment) => @stop_area.try(:comment),
@stop_area.human_attribute_name(:stop_area_type) => t("area_types.label.#{@stop_area.stop_area_type}"),
diff --git a/app/views/referentials/show.html.slim b/app/views/referentials/show.html.slim
index 33dc07567..0abeb0669 100644
--- a/app/views/referentials/show.html.slim
+++ b/app/views/referentials/show.html.slim
@@ -43,7 +43,7 @@
[ \
TableBuilderHelper::Column.new( \
name: t('id_codif'), \
- attribute: Proc.new { |n| n.get_objectid.local_id }, \
+ attribute: Proc.new { |n| n.get_objectid.short_id }, \
sortable: false \
), \
TableBuilderHelper::Column.new( \
diff --git a/app/views/routes/show.html.slim b/app/views/routes/show.html.slim
index 329be4b5f..734d6ebf3 100644
--- a/app/views/routes/show.html.slim
+++ b/app/views/routes/show.html.slim
@@ -38,7 +38,7 @@
= table_builder_2 @route_sp,
[ \
TableBuilderHelper::Column.new( \
- name: 'ID Reflex', \
+ name: t('id_reflex'), \
attribute: Proc.new { |s| s.try(:stop_area).try(:user_objectid) } \
), \
TableBuilderHelper::Column.new( \
diff --git a/app/views/stop_areas/index.html.slim b/app/views/stop_areas/index.html.slim
index 6bffbd1a0..3e84d2bdc 100644
--- a/app/views/stop_areas/index.html.slim
+++ b/app/views/stop_areas/index.html.slim
@@ -20,8 +20,8 @@
= table_builder_2 @stop_areas,
[ \
TableBuilderHelper::Column.new( \
- name: 'ID Reflex', \
- attribute: Proc.new { |n| n.try(:user_objectid) }, \
+ name: t('id_reflex'), \
+ attribute: Proc.new { |n| n.get_objectid.try(:short_id) }, \
sortable: false \
), \
TableBuilderHelper::Column.new( \
diff --git a/app/views/stop_areas/show.html.slim b/app/views/stop_areas/show.html.slim
index bc9cc2ac0..7f7c2e07f 100644
--- a/app/views/stop_areas/show.html.slim
+++ b/app/views/stop_areas/show.html.slim
@@ -19,9 +19,9 @@
.row
.col-lg-6.col-md-6.col-sm-12.col-xs-12
= definition_list t('metadatas'),
- { @stop_area.human_attribute_name(:stop_area_type) => t("area_types.label.#{@stop_area.stop_area_type}"),
+ { t('id_reflex') => @stop_area.get_objectid.short_id,
+ @stop_area.human_attribute_name(:stop_area_type) => t("area_types.label.#{@stop_area.stop_area_type}"),
@stop_area.human_attribute_name(:registration_number) => @stop_area.registration_number,
- t('id_reflex') => @stop_area.user_objectid,
'Coordonnées' => geo_data(@stop_area, @stop_area_referential),
@stop_area.human_attribute_name(:zip_code) => @stop_area.zip_code,
@stop_area.human_attribute_name(:city_name) => @stop_area.city_name,
diff --git a/app/views/time_tables/show.rabl b/app/views/time_tables/show.rabl
index 53c9daec0..55744bf8c 100644
--- a/app/views/time_tables/show.rabl
+++ b/app/views/time_tables/show.rabl
@@ -10,7 +10,7 @@ node do |tt|
periode_range: month_periode_enum(3),
current_periode_range: Date.today.beginning_of_month,
color: tt.color ? tt.color : '',
- short_id: tt.objectid.parts.try(:third)
+ short_id: tt.get_objectid.short_id
}
end
diff --git a/app/views/vehicle_journeys/show.rabl b/app/views/vehicle_journeys/show.rabl
index fce16dfb3..830dee8bd 100644
--- a/app/views/vehicle_journeys/show.rabl
+++ b/app/views/vehicle_journeys/show.rabl
@@ -4,6 +4,8 @@ object @vehicle_journey
attributes attr, :unless => lambda { |m| m.send( attr).nil?}
end
+node { |vj| {short_id: vj.get_objectid.short_id} }
+
child(:company) do |company|
attributes :id, :objectid, :name
end
@@ -16,6 +18,7 @@ end
child(:journey_pattern) do |journey_pattern|
attributes :id, :objectid, :name, :published_name
+ node(:short_id) {journey_pattern.get_objectid.short_id}
end
child(:time_tables, :object_root => false) do |time_tables|
diff --git a/config/deploy.rb b/config/deploy.rb
index 5fff31a4a..a8d44d3e5 100644
--- a/config/deploy.rb
+++ b/config/deploy.rb
@@ -55,6 +55,12 @@ namespace :deploy do
end
after "bundle:install", "deploy:bundle_link"
+ desc "Run yarn install"
+ task :yarn do
+ run "cd #{release_path} && yarn --production --no-progress install"
+ end
+ after "bundle:install", "deploy:yarn"
+
desc "Symlinks shared configs and folders on each release"
task :symlink_shared, :except => { :no_release => true } do
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/"
diff --git a/config/initializers/apartment.rb b/config/initializers/apartment.rb
index 87bca0b45..69204a5d7 100644
--- a/config/initializers/apartment.rb
+++ b/config/initializers/apartment.rb
@@ -61,7 +61,7 @@ Apartment.configure do |config|
'RouteControl::OppositeRouteTerminus',
'RouteControl::OppositeRoute',
'RouteControl::StopPointsInJourneyPattern',
- 'RouteControl::UnactivatedStopPoints',
+ 'RouteControl::UnactivatedStopPoint',
'RouteControl::ZDLStopArea',
'RoutingConstraintZoneControl::MaximumLength',
'RoutingConstraintZoneControl::MinimumLength',
diff --git a/config/initializers/stif.rb b/config/initializers/stif.rb
index ca08a7756..eb918131b 100644
--- a/config/initializers/stif.rb
+++ b/config/initializers/stif.rb
@@ -14,5 +14,11 @@ Rails.application.config.to_prepare do
end unless Rails.env.test?
Rails.application.config.to_prepare do
+ Organisation.before_validation(on: :create) do |organisation|
+ organisation.custom_view = "stif"
+ end
+end
+
+Rails.application.config.to_prepare do
Dashboard.default_class = Stif::Dashboard
end
diff --git a/config/locales/compliance_controls.en.yml b/config/locales/compliance_controls.en.yml
index 9615bbf69..0c476a46d 100644
--- a/config/locales/compliance_controls.en.yml
+++ b/config/locales/compliance_controls.en.yml
@@ -160,7 +160,7 @@ en:
one: "A route must have at least 2 stop points"
route_control/omnibus_journey_pattern:
one: "A journey pattern of a route should connect all of a route's stop points"
- route_control/unactivated_stop_points:
+ route_control/unactivated_stop_point:
one: "Route and unactivated stop point"
route_control/stop_points_in_journey_pattern:
one: "The stop points of a route must be used by at least one journey pattern"
diff --git a/config/locales/compliance_controls.fr.yml b/config/locales/compliance_controls.fr.yml
index e23f879f5..70227b01f 100644
--- a/config/locales/compliance_controls.fr.yml
+++ b/config/locales/compliance_controls.fr.yml
@@ -106,7 +106,7 @@ fr:
3_vehiclejourney_5_1: "La course %{source_objectid} a un horaire d'arrivé %{error_value} supérieur à l'horaire de départ %{reference_value} à l'arrêt %{target_0_label} (%{target_0_objectid})"
3_vehiclejourney_5_2: "La course %{source_objectid} a un horaire de départ %{error_value} à l'arrêt %{target_0_label} (%{target_0_objectid}) supérieur à l'horaire d'arrivé % à l'arrêt suivant"
description: "L'horaire d'arrivée à un arrêt doit être antérieur à l'horaire de départ de cet arrêt ET les horaires de départ aux arrêts doivent être dans l'ordre chronologique croissant."
- routing_constraint_zone_control/vehicle_journey_at_stops:
+ routing_constraint_zone_control/unactivated_stop_point:
messages:
3_routingconstraint_1: "L'ITL %{source_objectid} référence un arrêt (ZDEp) désactivé %{target_0_label} (%{target_0_objectid})"
description: "Les arrêts d'une ITL ne doivent pas être désactivés"
@@ -159,7 +159,7 @@ fr:
one: "Un itinéraire doit contenir au moins 2 arrêts"
route_control/omnibus_journey_pattern:
one: "Existence d’une mission passant par tous les arrêts de l'itinéraire"
- route_control/unactivated_stop_points:
+ route_control/unactivated_stop_point:
one: "Itinéraire & arrêt désactivé"
route_control/stop_points_in_journey_pattern:
one: "Utilisation des arrêts par les missions"
diff --git a/config/locales/import_messages.en.yml b/config/locales/import_messages.en.yml
index bf6b45020..42d180abd 100644
--- a/config/locales/import_messages.en.yml
+++ b/config/locales/import_messages.en.yml
@@ -3,7 +3,7 @@ en:
compliance_check_messages:
corrupt_zip_file: "The zip file %{source_filename} is corrupted and cannot be read"
inconsistent_zip_file: "The zip file %{source_filename} contains unexpected directories: %{spurious_dirs}, which are ignored"
- referential_creation: "Le référentiel n'a pas pu être créé car un référentiel existe déjà sur les même périodes et lignes"
+ referential_creation: "Le référentiel n'a pas pu être créé car un référentiel existe déjà sur les mêmes périodes et lignes"
1_netexstif_2: "Le fichier %{source_filename} ne respecte pas la syntaxe XML ou la XSD NeTEx : erreur '%{error_value}' rencontré"
1_netexstif_5: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet %{source_label} d'identifiant %{source_objectid} a une date de mise à jour dans le futur"
2_netexstif_1_1: "Le fichier commun.xml ne contient pas de frame nommée NETEX_COMMUN"
diff --git a/config/locales/import_messages.fr.yml b/config/locales/import_messages.fr.yml
index 7d3bbf23b..e29da05f9 100644
--- a/config/locales/import_messages.fr.yml
+++ b/config/locales/import_messages.fr.yml
@@ -3,7 +3,7 @@ fr:
compliance_check_messages:
corrupt_zip_file: "Le fichier zip %{source_filename} est corrompu, et ne peut être lu"
inconsistent_zip_file: "Le fichier zip %{source_filename} contient des repertoires non prévus : %{spurious_dirs} qui seront ignorés"
- referential_creation: "Le référentiel n'a pas pu être créé car un référentiel existe déjà sur les même périodes et lignes"
+ referential_creation: "Le référentiel n'a pas pu être créé car un référentiel existe déjà sur les mêmes périodes et lignes"
1_netexstif_2: "Le fichier %{source_filename} ne respecte pas la syntaxe XML ou la XSD NeTEx : erreur '%{error_value}' rencontré"
1_netexstif_5: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet %{source_label} d'identifiant %{source_objectid} a une date de mise à jour dans le futur"
2_netexstif_1_1: "Le fichier commun.xml ne contient pas de frame nommée NETEX_COMMUN"
diff --git a/config/locales/import_resources.en.yml b/config/locales/import_resources.en.yml
index d98b3eacf..5f0f3213e 100644
--- a/config/locales/import_resources.en.yml
+++ b/config/locales/import_resources.en.yml
@@ -2,7 +2,7 @@ en:
import_resources:
index:
title: "NeTEx conformity"
- table_state: "%{lines_imported} lines imported on %{lines_in_zipfile} presents in zipfile"
+ table_state: "%{lines_imported} line(s) imported on %{lines_in_zipfile} presents in zipfile"
table_title: "Satus of anlyzed files"
table_explanation: "When calendriers.xml and/or commun.xml are not imported, then all lines file are not processed."
metrics: "%{ok_count} ok, %{error_count} errors, %{warning_count} warnings, %{uncheck_count} n/a"
diff --git a/config/locales/import_resources.fr.yml b/config/locales/import_resources.fr.yml
index 86c8d8e73..a271ae1ca 100644
--- a/config/locales/import_resources.fr.yml
+++ b/config/locales/import_resources.fr.yml
@@ -2,7 +2,7 @@ fr:
import_resources:
index:
title: "Rapport de conformité NeTEx"
- table_state: "%{lines_imported} lignes importées sur %{lines_in_zipfile} présentes dans l'archive"
+ table_state: "%{lines_imported} ligne(s) importée(s) sur %{lines_in_zipfile} présente(s) dans l'archive"
table_title: "Etat des fichiers analysés"
table_explanation: "Dans le cas ou le(s) fichiers calendriers.xml et/ou commun.xml sont dans un état non importé, alors tous les fichiers lignes sont automatiquement dans un état non traité."
metrics: "%{ok_count} ok, %{error_count} errors, %{warning_count} warnings, %{uncheck_count} n/a"
diff --git a/db/migrate/20171001100320_add_custom_view_to_organisations.rb b/db/migrate/20171001100320_add_custom_view_to_organisations.rb
new file mode 100644
index 000000000..bd8da50fc
--- /dev/null
+++ b/db/migrate/20171001100320_add_custom_view_to_organisations.rb
@@ -0,0 +1,5 @@
+class AddCustomViewToOrganisations < ActiveRecord::Migration
+ def change
+ add_column :organisations, :custom_view, :string
+ end
+end
diff --git a/db/migrate/20171001100642_stif_define_custom_view_for_organisations.rb b/db/migrate/20171001100642_stif_define_custom_view_for_organisations.rb
new file mode 100644
index 000000000..304c90a1a
--- /dev/null
+++ b/db/migrate/20171001100642_stif_define_custom_view_for_organisations.rb
@@ -0,0 +1,5 @@
+class StifDefineCustomViewForOrganisations < ActiveRecord::Migration
+ def change
+ Organisation.update_all custom_view: "stif"
+ end
+end
diff --git a/db/migrate/20171123110204_update_objectid_format_value_to_referentials.rb b/db/migrate/20171123110204_update_objectid_format_value_to_referentials.rb
new file mode 100644
index 000000000..c85a63b6e
--- /dev/null
+++ b/db/migrate/20171123110204_update_objectid_format_value_to_referentials.rb
@@ -0,0 +1,14 @@
+class UpdateObjectidFormatValueToReferentials < ActiveRecord::Migration
+ # Migration in the context of the STIF
+ # Not a definitive choice since it cannot be used for Chouette
+ def up
+ Workbench.update_all(objectid_format: 'stif_netex')
+ Referential.update_all(objectid_format: 'stif_netex')
+ LineReferential.update_all(objectid_format: 'stif_codifligne')
+ StopAreaReferential.update_all(objectid_format: 'stif_reflex')
+ end
+
+ def down
+ raise ActiveRecord::IrreversibleMigration
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 21aa73cd8..349d8e5eb 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20171114102438) do
+ActiveRecord::Schema.define(version: 20171123110204) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -559,6 +559,7 @@ ActiveRecord::Schema.define(version: 20171114102438) do
t.string "code"
t.datetime "synced_at"
t.hstore "sso_attributes"
+ t.string "custom_view"
end
add_index "organisations", ["code"], name: "index_organisations_on_code", unique: true, using: :btree
diff --git a/db/seeds/chouette.seeds.rb b/db/seeds/chouette.seeds.rb
index 6adafa3e9..1cbdb584d 100644
--- a/db/seeds/chouette.seeds.rb
+++ b/db/seeds/chouette.seeds.rb
@@ -1,38 +1,6 @@
-# coding: utf-8
-# This file should contain all the record creation needed to seed the database with its default values.
-# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
+path = File.join(File.expand_path('../seeds', __FILE__), "*.rb")
-stop_area_referential = StopAreaReferential.find_or_create_by!(name: "Reflex", objectid_format: "netex")
-line_referential = LineReferential.find_or_create_by!(name: "CodifLigne", objectid_format: "netex")
-
-# Organisations
-stif = Organisation.find_or_create_by!(code: "STIF") do |org|
- org.name = 'STIF'
-end
-operator = Organisation.find_or_create_by!(code: 'transporteur-a') do |organisation|
- organisation.name = "Transporteur A"
+Dir.glob(path).sort.each do |file|
+ puts "Seed #{file}"
+ load file
end
-
-# Member
-line_referential.add_member stif, owner: true
-line_referential.add_member operator
-
-stop_area_referential.add_member stif, owner: true
-stop_area_referential.add_member operator
-
-# Users
-stif.users.find_or_create_by!(username: "admin") do |user|
- user.email = 'stif-boiv@af83.com'
- user.password = "secret"
- user.name = "STIF Administrateur"
-end
-
-operator.users.find_or_create_by!(username: "transporteur") do |user|
- user.email = 'stif-boiv+transporteur@af83.com'
- user.password = "secret"
- user.name = "Martin Lejeune"
-end
-
-# Include all Lines in organisation functional_scope
-stif.update sso_attributes: { functional_scope: line_referential.lines.pluck(:objectid) }
-operator.update sso_attributes: { functional_scope: line_referential.lines.limit(3).pluck(:objectid) }
diff --git a/db/seeds/stif.rb b/db/seeds/stif.rb
new file mode 100644
index 000000000..d31a35cfc
--- /dev/null
+++ b/db/seeds/stif.rb
@@ -0,0 +1,38 @@
+# coding: utf-8
+# This file should contain all the record creation needed to seed the database with its default values.
+# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
+
+stop_area_referential = StopAreaReferential.find_or_create_by!(name: "Reflex")
+line_referential = LineReferential.find_or_create_by!(name: "CodifLigne")
+
+# Organisations
+stif = Organisation.find_or_create_by!(code: "STIF") do |org|
+ org.name = 'STIF'
+end
+operator = Organisation.find_or_create_by!(code: 'transporteur-a') do |organisation|
+ organisation.name = "Transporteur A"
+end
+
+# Member
+line_referential.add_member stif, owner: true
+line_referential.add_member operator
+
+stop_area_referential.add_member stif, owner: true
+stop_area_referential.add_member operator
+
+# Users
+stif.users.find_or_create_by!(username: "admin") do |user|
+ user.email = 'stif-boiv@af83.com'
+ user.password = "secret"
+ user.name = "STIF Administrateur"
+end
+
+operator.users.find_or_create_by!(username: "transporteur") do |user|
+ user.email = 'stif-boiv+transporteur@af83.com'
+ user.password = "secret"
+ user.name = "Martin Lejeune"
+end
+
+# Include all Lines in organisation functional_scope
+stif.update sso_attributes: { functional_scope: line_referential.lines.pluck(:objectid) }
+operator.update sso_attributes: { functional_scope: line_referential.lines.limit(3).pluck(:objectid) }
diff --git a/spec/controllers/devise/cas_sessions_controller_spec.rb b/spec/controllers/devise/cas_sessions_controller_spec.rb
index e4436f6c1..934bc1da2 100644
--- a/spec/controllers/devise/cas_sessions_controller_spec.rb
+++ b/spec/controllers/devise/cas_sessions_controller_spec.rb
@@ -22,7 +22,7 @@ RSpec.describe Devise::CasSessionsController, type: :controller do
it 'cannot login and will be redirected to the login page, with a corresponding message' do
get :service
- expect(controller).to set_flash[:alert].to(%r{IBOO})
+ expect(controller).to set_flash[:alert].to(%r{Vous ne pouvez pas vous connecter car vous n'avez pas les permissions})
expect(response).to redirect_to "http://stif-portail-dev.af83.priv/sessions/logout?service=http%3A%2F%2Ftest.host%2Fusers%2Fservice"
end
end
diff --git a/spec/factories/chouette_lines.rb b/spec/factories/chouette_lines.rb
index f6542bf82..95f760174 100644
--- a/spec/factories/chouette_lines.rb
+++ b/spec/factories/chouette_lines.rb
@@ -44,6 +44,11 @@ FactoryGirl.define do
end
+ factory :line_with_after_commit do |line|
+ line.run_callbacks(:commit)
+
+ end
+
end
end
diff --git a/spec/factories/chouette_routes.rb b/spec/factories/chouette_routes.rb
index 4986ab70e..4e20059fe 100644
--- a/spec/factories/chouette_routes.rb
+++ b/spec/factories/chouette_routes.rb
@@ -33,6 +33,13 @@ FactoryGirl.define do
end
end
+ factory :route_with_after_commit do
+ sequence(:objectid) {nil}
+ after(:create) do |route|
+ route.run_callbacks(:commit)
+ end
+ end
+
end
end
diff --git a/spec/factories/compliance_controls/route_control_factories.rb b/spec/factories/compliance_controls/route_control_factories.rb
index 1462ca635..35d8f481f 100644
--- a/spec/factories/compliance_controls/route_control_factories.rb
+++ b/spec/factories/compliance_controls/route_control_factories.rb
@@ -28,7 +28,7 @@ FactoryGirl.define do
association :compliance_control_set
end
- factory :route_control_unactivated_stop_points, class: 'RouteControl::UnactivatedStopPoints' do
+ factory :route_control_unactivated_stop_point, class: 'RouteControl::UnactivatedStopPoint' do
association :compliance_control_set
end
diff --git a/spec/features/api_keys/edit_api_key_feature_spec.rb b/spec/features/api_keys/edit_api_key_feature_spec.rb
index 256c4218b..9248e2b17 100644
--- a/spec/features/api_keys/edit_api_key_feature_spec.rb
+++ b/spec/features/api_keys/edit_api_key_feature_spec.rb
@@ -12,6 +12,8 @@ RSpec.describe 'Edit API Key', type: :feature do
let( :unique_name ){ SecureRandom.uuid }
it 'complete workflow' do
+ skip "Specific to STIF Dashboard" if Dashboard.default_class != Stif::Dashboard
+
visit dashboard_path
# api_key's new name does not exist yet
expect( page ).not_to have_content(unique_name)
diff --git a/spec/features/api_keys/new_api_key_feature_spec.rb b/spec/features/api_keys/new_api_key_feature_spec.rb
index 988690f3c..fc5497788 100644
--- a/spec/features/api_keys/new_api_key_feature_spec.rb
+++ b/spec/features/api_keys/new_api_key_feature_spec.rb
@@ -13,6 +13,8 @@ RSpec.describe 'New API Key', type: :feature do
it 'complete workflow' do
+ skip "Specific to STIF Dashboard" if Dashboard.default_class != Stif::Dashboard
+
# /workbenches
visit dashboard_path
expect(page).to have_link(create_label, href: new_api_key_path)
diff --git a/spec/models/chouette/company_spec.rb b/spec/models/chouette/company_spec.rb
index 067501c85..a3101d79c 100644
--- a/spec/models/chouette/company_spec.rb
+++ b/spec/models/chouette/company_spec.rb
@@ -4,12 +4,6 @@ describe Chouette::Company, :type => :model do
subject { create(:company) }
it { should validate_presence_of :name }
- describe "#objectid_format" do
- it "sould not be nil" do
- expect(subject.objectid_format).not_to be_nil
- end
- end
-
describe "#nullables empty" do
it "should set null empty nullable attributes" do
subject.organizational_unit = ''
diff --git a/spec/models/chouette/journey_pattern_spec.rb b/spec/models/chouette/journey_pattern_spec.rb
index d631511a3..047022ade 100644
--- a/spec/models/chouette/journey_pattern_spec.rb
+++ b/spec/models/chouette/journey_pattern_spec.rb
@@ -30,12 +30,6 @@ describe Chouette::JourneyPattern, :type => :model do
# end
# end
- describe "#objectid_format" do
- it "sould not be nil" do
- expect(subject.objectid_format).not_to be_nil
- end
- end
-
describe "state_update" do
def journey_pattern_to_state jp
jp.attributes.slice('name', 'published_name', 'registration_number').tap do |item|
diff --git a/spec/models/chouette/line_spec.rb b/spec/models/chouette/line_spec.rb
index eee672574..bc7b6e0c7 100644
--- a/spec/models/chouette/line_spec.rb
+++ b/spec/models/chouette/line_spec.rb
@@ -15,17 +15,6 @@ describe Chouette::Line, :type => :model do
end
end
- describe '#objectid' do
- subject { super().get_objectid }
- it { is_expected.to be_kind_of(Chouette::Objectid::StifCodifligne) }
- end
-
- describe "#objectid_format" do
- it "sould not be nil" do
- expect(subject.objectid_format).not_to be_nil
- end
- end
-
# it { should validate_numericality_of :objectversion }
# describe ".last_stop_areas_parents" do
diff --git a/spec/models/chouette/network_spec.rb b/spec/models/chouette/network_spec.rb
index 75fc17587..32bacc512 100644
--- a/spec/models/chouette/network_spec.rb
+++ b/spec/models/chouette/network_spec.rb
@@ -3,12 +3,6 @@ require 'spec_helper'
describe Chouette::Network, :type => :model do
subject { create(:network) }
it { should validate_presence_of :name }
-
- describe "#objectid_format" do
- it "sould not be nil" do
- expect(subject.objectid_format).not_to be_nil
- end
- end
describe "#stop_areas" do
let!(:line){create(:line, :network => subject)}
diff --git a/spec/models/chouette/object_id_spec.rb b/spec/models/chouette/object_id_spec.rb
deleted file mode 100644
index 7ac5fe5ca..000000000
--- a/spec/models/chouette/object_id_spec.rb
+++ /dev/null
@@ -1,149 +0,0 @@
-# require 'spec_helper'
-
-# describe Chouette::ObjectId, :type => :model do
-
-# def objectid(value = "abc:StopArea:abc123")
-# Chouette::ObjectId.new value
-# end
-
-# subject { objectid }
-
-# context "when invalid" do
-
-# subject { objectid("abc") }
-
-# it { is_expected.not_to be_valid }
-
-# describe '#parts' do
-# subject { super().parts }
-# it { is_expected.to be_nil }
-# end
-
-# describe '#system_id' do
-# subject { super().system_id }
-# it { is_expected.to be_nil }
-# end
-
-# end
-
-# context "when with spaces in last part" do
-
-# subject { objectid("abc:Line:Aze toto") }
-
-# it { is_expected.not_to be_valid }
-
-
-# end
-
-# context "when with spaces in first part" do
-
-# subject { objectid("ae abc:Line:Aze") }
-
-# it { is_expected.not_to be_valid }
-
-
-# end
-
-# context "when with spaces in middle part" do
-
-# subject { objectid("aeabc:Li ne:Aze") }
-
-# it { is_expected.not_to be_valid }
-
-
-# end
-
-# context "when invalid in first part" do
-
-# subject { objectid("Abc_+19:Line:Abc") }
-
-# it { is_expected.not_to be_valid }
-# end
-
-# context "when invalid in middle part" do
-
-# subject { objectid("Abc_19:Li56ne:Abc") }
-
-# it { is_expected.not_to be_valid }
-# end
-
-# context "when invalid in last part" do
-
-# subject { objectid("Abc_19:Line:Ab+c") }
-
-# it { is_expected.not_to be_valid }
-# end
-# context "when valid" do
-
-# subject { objectid("Abc_19:Line:Abc_12-") }
-
-# it { is_expected.to be_valid }
-# end
-
-# describe "#parts" do
-
-# it "should be the 3 parts of the ObjectId" do
-# expect(objectid("abc:StopArea:abc123").parts).to eq(%w{abc StopArea abc123})
-# end
-
-# end
-
-# describe "#system_id" do
-
-# it "should be the first ObjectId parts" do
-# expect(objectid("first:second:third").system_id).to eq("first")
-# end
-
-# end
-
-# describe "#object_type" do
-
-# it "should be the second ObjectId parts" do
-# expect(objectid("first:second:third").object_type).to eq("second")
-# end
-
-# end
-
-# describe "#local_id" do
-
-# it "should be the third ObjectId parts" do
-# expect(objectid("first:second:third").local_id).to eq("third")
-# end
-
-# end
-
-# it "should be valid when parts are found" do
-# allow(subject).to receive_messages :parts => "dummy"
-# expect(subject).to be_valid
-# end
-
-# describe ".create" do
-
-# let(:given_system_id) { "systemId" }
-# let(:given_object_type) { "objectType" }
-# let(:given_local_id) { "localId" }
-
-# subject { Chouette::ObjectId.create(given_system_id, given_object_type, given_local_id) }
-
-# it "should return ObjectId attributes" do
-# expect(subject.send(:system_id)).to eq(given_system_id)
-# expect(subject.send(:object_type)).to eq(given_object_type)
-# expect(subject.send(:local_id)).to eq(given_local_id)
-# end
-
-# end
-
-# describe ".new" do
-
-# it "should return an existing ObjectId" do
-# expect(Chouette::ObjectId.new(objectid)).to eq(objectid)
-# end
-
-# it "should create an empty ObjectId with nil" do
-# expect(Chouette::ObjectId.new(nil)).to be_empty
-# end
-
-# end
-
-
-# end
diff --git a/spec/models/chouette/objectid/netex_spec.rb b/spec/models/chouette/objectid/netex_spec.rb
new file mode 100644
index 000000000..3aee13624
--- /dev/null
+++ b/spec/models/chouette/objectid/netex_spec.rb
@@ -0,0 +1,10 @@
+require 'spec_helper'
+
+describe Chouette::Objectid::Netex, :type => :model do
+ subject { Chouette::Objectid::Netex.new(object_type: 'Route', local_id: SecureRandom.uuid) }
+ it { should validate_presence_of :provider_id }
+ it { should validate_presence_of :object_type }
+ it { should validate_presence_of :local_id }
+ it { should validate_presence_of :creation_id }
+ it { is_expected.to be_valid }
+end \ No newline at end of file
diff --git a/spec/models/chouette/objectid/stif_codifligne_spec.rb b/spec/models/chouette/objectid/stif_codifligne_spec.rb
new file mode 100644
index 000000000..533af3556
--- /dev/null
+++ b/spec/models/chouette/objectid/stif_codifligne_spec.rb
@@ -0,0 +1,10 @@
+require 'spec_helper'
+
+describe Chouette::Objectid::StifCodifligne, :type => :model do
+ subject { Chouette::Objectid::StifCodifligne.new(object_type: 'Line', local_id: 'C02008', sync_id: 'CODIFLIGNE', provider_id: 'STIF') }
+ it { should validate_presence_of :provider_id }
+ it { should validate_presence_of :object_type }
+ it { should validate_presence_of :local_id }
+ it { should validate_presence_of :sync_id }
+ it { is_expected.to be_valid }
+end \ No newline at end of file
diff --git a/spec/models/chouette/objectid/stif_netex_spec.rb b/spec/models/chouette/objectid/stif_netex_spec.rb
new file mode 100644
index 000000000..1d361ca86
--- /dev/null
+++ b/spec/models/chouette/objectid/stif_netex_spec.rb
@@ -0,0 +1,10 @@
+require 'spec_helper'
+
+describe Chouette::Objectid::StifNetex, :type => :model do
+ subject { Chouette::Objectid::StifNetex.new(object_type: 'Route', local_id: '13') }
+ it { should validate_presence_of :provider_id }
+ it { should validate_presence_of :object_type }
+ it { should validate_presence_of :local_id }
+ it { should validate_presence_of :creation_id }
+ it { is_expected.to be_valid }
+end \ No newline at end of file
diff --git a/spec/models/chouette/objectid/stif_reflex_spec.rb b/spec/models/chouette/objectid/stif_reflex_spec.rb
new file mode 100644
index 000000000..0846f27fa
--- /dev/null
+++ b/spec/models/chouette/objectid/stif_reflex_spec.rb
@@ -0,0 +1,11 @@
+require 'spec_helper'
+
+describe Chouette::Objectid::StifReflex, :type => :model do
+ subject { Chouette::Objectid::StifReflex.new(country_code: 'FR', zip_code: '78517', object_type: 'ZDL', local_id: '50015386', provider_id: 'STIF') }
+ it { should validate_presence_of :provider_id }
+ it { should validate_presence_of :object_type }
+ it { should validate_presence_of :local_id }
+ it { should validate_presence_of :country_code }
+ it { should validate_presence_of :zip_code }
+ it { is_expected.to be_valid }
+end \ No newline at end of file
diff --git a/spec/models/chouette/route/route_base_spec.rb b/spec/models/chouette/route/route_base_spec.rb
index ff86eefb6..79daeb6c2 100644
--- a/spec/models/chouette/route/route_base_spec.rb
+++ b/spec/models/chouette/route/route_base_spec.rb
@@ -5,17 +5,6 @@ RSpec.describe Chouette::Route, :type => :model do
it_behaves_like 'checksum support', :route
end
- describe '#objectid' do
- subject { super().get_objectid }
- it { is_expected.to be_kind_of(Chouette::Objectid::StifNetex) }
- end
-
- describe "#objectid_format" do
- it "sould not be nil" do
- expect(subject.objectid_format).not_to be_nil
- end
- end
-
it { is_expected.to enumerize(:direction).in(:straight_forward, :backward, :clockwise, :counter_clockwise, :north, :north_west, :west, :south_west, :south, :south_east, :east, :north_east) }
it { is_expected.to enumerize(:wayback).in(:outbound, :inbound) }
diff --git a/spec/models/chouette/routing_constraint_zone_spec.rb b/spec/models/chouette/routing_constraint_zone_spec.rb
index 32c3410a4..c344642e6 100644
--- a/spec/models/chouette/routing_constraint_zone_spec.rb
+++ b/spec/models/chouette/routing_constraint_zone_spec.rb
@@ -8,12 +8,6 @@ describe Chouette::RoutingConstraintZone, type: :model do
# shoulda matcher to validate length of array ?
xit { is_expected.to validate_length_of(:stop_point_ids).is_at_least(2) }
- describe "#objectid_format" do
- it "sould not be nil" do
- expect(subject.objectid_format).not_to be_nil
- end
- end
-
describe 'checksum' do
it_behaves_like 'checksum support', :routing_constraint_zone
end
diff --git a/spec/models/chouette/stop_area_spec.rb b/spec/models/chouette/stop_area_spec.rb
index 92fff4726..1e0b4af84 100644
--- a/spec/models/chouette/stop_area_spec.rb
+++ b/spec/models/chouette/stop_area_spec.rb
@@ -7,17 +7,6 @@ describe Chouette::StopArea, :type => :model do
let!(:commercial_stop_point) { create :stop_area, :area_type => "lda" }
let!(:stop_place) { create :stop_area, :area_type => "zdlp" }
- describe '#objectid' do
- subject { super().get_objectid }
- it { should be_kind_of(Chouette::Objectid::StifReflex) }
- end
-
- describe "#objectid_format" do
- it "sould not be nil" do
- expect(subject.objectid_format).not_to be_nil
- end
- end
-
it { should belong_to(:stop_area_referential) }
it { should validate_presence_of :name }
it { should validate_numericality_of :latitude }
diff --git a/spec/models/chouette/stop_point_spec.rb b/spec/models/chouette/stop_point_spec.rb
index b68d231b4..264fd26fc 100644
--- a/spec/models/chouette/stop_point_spec.rb
+++ b/spec/models/chouette/stop_point_spec.rb
@@ -1,7 +1,4 @@
-# From Chouette import what we need ™
-StopPoint = Chouette::StopPoint
-
-describe StopPoint, :type => :model do
+describe Chouette::StopPoint, :type => :model do
let!(:vehicle_journey) { create(:vehicle_journey)}
subject { Chouette::Route.find( vehicle_journey.route_id).stop_points.first }
@@ -13,12 +10,6 @@ describe StopPoint, :type => :model do
it { is_expected.to be_kind_of(Chouette::Objectid::StifNetex) }
end
- describe "#objectid_format" do
- it "sould not be nil" do
- expect(subject.objectid_format).not_to be_nil
- end
- end
-
describe "#destroy" do
before(:each) do
@vehicle = create(:vehicle_journey)
@@ -50,7 +41,7 @@ describe StopPoint, :type => :model do
let!( :new_route ){ create :route }
it 'creates a new instance' do
- expect{ subject.duplicate(for_route: new_route) }.to change{ StopPoint.count }.by(1)
+ expect{ subject.duplicate(for_route: new_route) }.to change{ Chouette::StopPoint.count }.by(1)
end
it 'new instance has a new route' do
expect(subject.duplicate(for_route: new_route).route).to eq(new_route)
diff --git a/spec/models/chouette/time_table_spec.rb b/spec/models/chouette/time_table_spec.rb
index 74809fa58..761c39e5b 100644
--- a/spec/models/chouette/time_table_spec.rb
+++ b/spec/models/chouette/time_table_spec.rb
@@ -6,12 +6,6 @@ describe Chouette::TimeTable, :type => :model do
it { is_expected.to validate_presence_of :comment }
it { is_expected.to validate_uniqueness_of :objectid }
-
- describe "#objectid_format" do
- it "sould not be nil" do
- expect(subject.objectid_format).not_to be_nil
- end
- end
def create_time_table_periode time_table, start_date, end_date
create(:time_table_period, time_table: time_table, :period_start => start_date, :period_end => end_date)
diff --git a/spec/models/chouette/trident_active_record_spec.rb b/spec/models/chouette/trident_active_record_spec.rb
deleted file mode 100644
index 50ca27233..000000000
--- a/spec/models/chouette/trident_active_record_spec.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-# require 'spec_helper'
-
-# describe Chouette::TridentActiveRecord, :type => :model do
-# subject { create(:time_table) }
-
-# it { should validate_presence_of :objectid }
-# it { should validate_uniqueness_of :objectid }
-
-# describe "#default_values" do
-# let(:object) { build(:time_table, objectid: nil) }
-
-# it 'should fill __pending_id__' do
-# object.default_values
-# expect(object.objectid.include?('__pending_id__')).to be_truthy
-# end
-# end
-
-# describe "#objectid" do
-# let(:object) { build(:time_table, objectid: nil) }
-
-# it 'should build objectid on create' do
-# object.save
-# objectid = object.get_objectid
-# id = "#{objectid.provider_id}:#{objectid.object_type}:#{objectid.local_id}:#{objectid.creation_id}"
-# expect(object.read_attribute(:objectid)).to eq(id)
-# end
-
-# it 'should not build new objectid is already set' do
-# id = "first:TimeTable:1-1:LOC"
-# object.objectid = id
-# object.save
-# expect(object.objectid).to eq(id)
-# end
-
-# xit 'should call default_values on create' do
-# expect(object).to receive(:default_values)
-# object.save
-# end
-
-# xit 'should not call default_values on update' do
-# object = create(:time_table)
-# expect(object).to_not receive(:default_values)
-# object.touch
-# end
-
-# it 'should create a new objectid when cleared' do
-# object.save
-# object.objectid = nil
-# object.save
-# expect(object.objectid).to be_truthy
-# end
-# end
-# end
diff --git a/spec/models/chouette/vehicle_journey_spec.rb b/spec/models/chouette/vehicle_journey_spec.rb
index ca438ffcc..86aa475f0 100644
--- a/spec/models/chouette/vehicle_journey_spec.rb
+++ b/spec/models/chouette/vehicle_journey_spec.rb
@@ -2,12 +2,6 @@ require 'spec_helper'
describe Chouette::VehicleJourney, :type => :model do
- describe "#objectid_format" do
- it "sould not be nil" do
- expect(subject.objectid_format).not_to be_nil
- end
- end
-
it "must be valid with an at-stop day offset of 1" do
vehicle_journey = create(
:vehicle_journey,
@@ -104,9 +98,10 @@ describe Chouette::VehicleJourney, :type => :model do
expect(collection.last['objectid']).not_to be_nil
- Chouette::VehicleJourney.last.run_callbacks(:commit)
+ obj = Chouette::VehicleJourney.last
+ obj.run_callbacks(:commit)
- expect(Chouette::VehicleJourney.last.published_journey_name).to eq 'dummy'
+ expect(obj.published_journey_name).to eq 'dummy'
end
it 'should save vehicle_journey_at_stops of newly created vj' do
diff --git a/spec/models/compliance_control_class_level_defaults/route_control/unactivated_stop_point_cccld_spec.rb b/spec/models/compliance_control_class_level_defaults/route_control/unactivated_stop_point_cccld_spec.rb
new file mode 100644
index 000000000..e9c335dea
--- /dev/null
+++ b/spec/models/compliance_control_class_level_defaults/route_control/unactivated_stop_point_cccld_spec.rb
@@ -0,0 +1,7 @@
+
+RSpec.describe RouteControl::UnactivatedStopPoint, type: :model do
+ let( :default_code ){ "3-Route-10" }
+ let( :factory ){ :route_control_unactivated_stop_point }
+
+ it_behaves_like 'ComplianceControl Class Level Defaults'
+end
diff --git a/spec/models/compliance_control_class_level_defaults/route_control/unactivated_stop_points_cccld_spec.rb b/spec/models/compliance_control_class_level_defaults/route_control/unactivated_stop_points_cccld_spec.rb
deleted file mode 100644
index bf725d743..000000000
--- a/spec/models/compliance_control_class_level_defaults/route_control/unactivated_stop_points_cccld_spec.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-
-RSpec.describe RouteControl::UnactivatedStopPoints, type: :model do
- let( :default_code ){ "3-Route-10" }
- let( :factory ){ :route_control_unactivated_stop_points }
-
- it_behaves_like 'ComplianceControl Class Level Defaults'
-end
diff --git a/spec/models/concerns/objectid_support_spec.rb b/spec/models/concerns/objectid_support_spec.rb
new file mode 100644
index 000000000..fabeeec11
--- /dev/null
+++ b/spec/models/concerns/objectid_support_spec.rb
@@ -0,0 +1,138 @@
+RSpec.describe ObjectidSupport do
+
+ context 'when referential has an objectid format of stif_netex' do
+ let(:object) { create(:time_table, objectid: nil) }
+
+ context "#objectid_format" do
+ it "should be stif_netex" do
+ expect(object.referential.objectid_format).to eq('stif_netex')
+ end
+ end
+
+ it 'should fill __pending_id__' do
+ expect(object.objectid.include?('__pending_id__')).to be_truthy
+ end
+
+ context "#get_objectid" do
+
+ before(:each) do
+ object.run_callbacks(:commit)
+ end
+
+ it "should be valid" do
+ expect(object.get_objectid).to be_valid
+ end
+
+ it "should have the same local id than the object" do
+ expect(object.get_objectid.local_id).to eq(object.local_id)
+ end
+
+ it "should be a Chouette::Objectid::StifNetex" do
+ expect(object.get_objectid).to be_kind_of(Chouette::Objectid::StifNetex)
+ end
+
+ context "#to_s" do
+ it "should return a string" do
+ expect(object.get_objectid.to_s).to be_kind_of(String)
+ end
+
+ it "should be the same as the db attribute" do
+ expect(object.get_objectid.to_s).to eq(object.read_attribute(:objectid))
+ expect(object.get_objectid.to_s).to eq(object.objectid)
+ end
+
+ context "#objectid" do
+
+ it 'should build objectid on create' do
+ object.save
+ object.run_callbacks(:commit)
+ objectid = object.get_objectid
+ id = "#{objectid.provider_id}:#{objectid.object_type}:#{objectid.local_id}:#{objectid.creation_id}"
+ expect(object.read_attribute(:objectid)).to eq(id)
+ end
+
+ it 'should not build new objectid is already set' do
+ id = "first:TimeTable:1-1:LOC"
+ object.attributes = {objectid: id}
+ object.save
+ expect(object.objectid).to eq(id)
+ end
+
+ it 'should create a new objectid when cleared' do
+ object.save
+ object.attributes = { objectid: nil}
+ object.save
+ expect(object.objectid).to be_truthy
+ end
+ end
+ end
+ end
+ end
+
+ context 'when referential has an objectid format of netex' do
+ before(:all) do
+ Referential.first.update(objectid_format: 'netex')
+ end
+
+ let(:object) { create(:time_table, objectid: nil) }
+
+
+ context "#objectid_format" do
+ it "should be netex" do
+ expect(object.referential.objectid_format).to eq('netex')
+ end
+ end
+
+ context "#get_objectid" do
+
+ it "should be valid" do
+ expect(object.get_objectid).to be_valid
+ end
+
+ it "should have the same local id than the object" do
+ expect(object.get_objectid.local_id).to match(/\w+-\w+-\w+-\w+-\w+/)
+ end
+
+ it "should be a Chouette::Objectid::StifNetex" do
+ expect(object.get_objectid).to be_kind_of(Chouette::Objectid::Netex)
+ end
+
+ context "#to_s" do
+ it "should return a string" do
+ expect(object.get_objectid.to_s).to be_kind_of(String)
+ end
+
+ it "should be the same as the db attribute" do
+ expect(object.get_objectid.to_s).to eq(object.read_attribute(:objectid))
+ expect(object.get_objectid.to_s).to eq(object.objectid)
+ end
+
+ context "#objectid" do
+
+ it 'should build objectid on create' do
+ object.save
+ object.run_callbacks(:commit)
+ objectid = object.get_objectid
+ id = "#{objectid.provider_id}:#{objectid.object_type}:#{objectid.local_id}:#{objectid.creation_id}"
+ expect(object.read_attribute(:objectid)).to eq(id)
+ end
+
+ it 'should not build new objectid is already set' do
+ id = "first:TimeTable:1-1:LOC"
+ object.attributes = {objectid: id}
+ object.save
+ expect(object.objectid).to eq(id)
+ end
+
+ it 'should create a new objectid when cleared' do
+ object.save
+ object.attributes = { objectid: nil}
+ object.save
+ expect(object.objectid).to be_truthy
+ end
+ end
+ end
+ end
+ end
+
+end \ No newline at end of file
diff --git a/spec/models/referential_spec.rb b/spec/models/referential_spec.rb
index 987eea30a..d0b1d6447 100644
--- a/spec/models/referential_spec.rb
+++ b/spec/models/referential_spec.rb
@@ -12,7 +12,11 @@ describe Referential, :type => :model do
it { should belong_to(:workbench) }
it { should belong_to(:referential_suite) }
- # it { should validate_presence_of(:objectid_format) }
+ context "validation" do
+ subject { build_stubbed(:referential) }
+
+ it { should validate_presence_of(:objectid_format) }
+ end
context ".referential_ids_in_periode" do
it 'should retrieve referential id in periode range' do