diff options
| author | Guillaume | 2017-11-27 16:52:38 +0100 |
|---|---|---|
| committer | Guillaume | 2017-11-27 16:52:38 +0100 |
| commit | 2b11404b58dad37cc9e5dae3e24bcf7b466f5c32 (patch) | |
| tree | 3091ac1c0be5f7584de79c9fd8a0a0b217753312 /app | |
| parent | c83002d8f281384244dc9c11432e2eb648b99b3b (diff) | |
| parent | 6bd0791839353750511ce4a49e6b75a462dfec51 (diff) | |
| download | chouette-core-2b11404b58dad37cc9e5dae3e24bcf7b466f5c32.tar.bz2 | |
Merge branch 'master' into 4824-create_line_referentials
Diffstat (limited to 'app')
90 files changed, 655 insertions, 933 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">×</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| |
