aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/helpers/compliance_controls_helper.rb4
-rw-r--r--app/javascript/journey_patterns/actions/index.js2
-rw-r--r--app/javascript/journey_patterns/components/CreateModal.js4
-rw-r--r--app/javascript/journey_patterns/components/JourneyPattern.js2
-rw-r--r--app/javascript/journey_patterns/reducers/journeyPatterns.js2
-rw-r--r--app/javascript/time_tables/components/ConfirmModal.js8
-rw-r--r--app/javascript/time_tables/components/ErrorModal.js8
-rw-r--r--app/javascript/time_tables/components/Metas.js8
-rw-r--r--app/javascript/time_tables/components/PeriodForm.js8
-rw-r--r--app/javascript/time_tables/components/PeriodManager.js8
-rw-r--r--app/javascript/time_tables/components/TagsSelect2.js6
-rw-r--r--app/javascript/time_tables/components/Timetable.js14
-rw-r--r--app/javascript/vehicle_journeys/actions/index.js9
-rw-r--r--app/models/chouette/vehicle_journey.rb27
-rw-r--r--app/models/concerns/custom_fields_support.rb2
-rw-r--r--app/views/autocomplete_purchase_windows/index.rabl13
-rw-r--r--app/views/referentials/select_compliance_control_set.html.slim2
-rw-r--r--app/views/workbench_outputs/show.html.slim3
-rw-r--r--config/locales/compliance_check_sets.en.yml2
-rw-r--r--config/locales/compliance_check_sets.fr.yml2
-rw-r--r--config/locales/import_resources.en.yml2
-rw-r--r--config/locales/import_resources.fr.yml2
-rw-r--r--config/locales/referentials.fr.yml2
-rw-r--r--db/migrate/20180405133659_change_companies_custom_fields_values_type.rb8
-rw-r--r--db/schema.rb18
-rw-r--r--db/seeds/dev/custom_fields.seeds.rb52
-rw-r--r--db/seeds/development/custom_fields.seeds.rb52
-rw-r--r--db/seeds/seed_helpers.rb2
-rw-r--r--db/seeds/stif.seeds.rb2
-rw-r--r--lib/tasks/ci.rake17
-rw-r--r--spec/models/chouette/vehicle_journey_spec.rb51
31 files changed, 252 insertions, 90 deletions
diff --git a/app/helpers/compliance_controls_helper.rb b/app/helpers/compliance_controls_helper.rb
index 297ae3afa..abf909929 100644
--- a/app/helpers/compliance_controls_helper.rb
+++ b/app/helpers/compliance_controls_helper.rb
@@ -11,7 +11,7 @@ module ComplianceControlsHelper
def compliance_control_metadatas(compliance_control)
attributes = resource.class.dynamic_attributes
- attributes.push(*resource.control_attributes.keys) if resource.respond_to? :control_attributes
+ attributes.push(*resource.control_attributes.keys) if resource&.control_attributes&.keys
{}.tap do |hash|
attributes.each do |attribute|
@@ -19,4 +19,4 @@ module ComplianceControlsHelper
end
end
end
-end
+end
diff --git a/app/javascript/journey_patterns/actions/index.js b/app/javascript/journey_patterns/actions/index.js
index 666157ea4..ea54f4e05 100644
--- a/app/javascript/journey_patterns/actions/index.js
+++ b/app/javascript/journey_patterns/actions/index.js
@@ -43,7 +43,7 @@ const actions = {
}),
updateCheckboxValue : (e, index) => ({
type : 'UPDATE_CHECKBOX_VALUE',
- id : e.currentTarget.id,
+ position : e.currentTarget.id,
index
}),
checkConfirmModal : (event, callback, stateChanged,dispatch) => {
diff --git a/app/javascript/journey_patterns/components/CreateModal.js b/app/javascript/journey_patterns/components/CreateModal.js
index 36b5740dc..946c13d9c 100644
--- a/app/javascript/journey_patterns/components/CreateModal.js
+++ b/app/javascript/journey_patterns/components/CreateModal.js
@@ -57,7 +57,7 @@ export default class CreateModal extends Component {
<div className='row'>
<div className='col-lg-6 col-md-6 col-sm-6 col-xs-6'>
<div className='form-group'>
- <label className='control-label is-required'>{I18n.attribute_name('journey_pattern', 'published_name')}c</label>
+ <label className='control-label is-required'>{I18n.attribute_name('journey_pattern', 'published_name')}</label>
<input
type='text'
ref='published_name'
@@ -120,4 +120,4 @@ CreateModal.propTypes = {
onOpenCreateModal: PropTypes.func.isRequired,
onModalClose: PropTypes.func.isRequired,
onAddJourneyPattern: PropTypes.func.isRequired
-} \ No newline at end of file
+}
diff --git a/app/javascript/journey_patterns/components/JourneyPattern.js b/app/javascript/journey_patterns/components/JourneyPattern.js
index d381b0d50..4eba80030 100644
--- a/app/javascript/journey_patterns/components/JourneyPattern.js
+++ b/app/javascript/journey_patterns/components/JourneyPattern.js
@@ -45,7 +45,7 @@ export default class JourneyPattern extends Component{
<input
onChange = {(e) => this.props.onCheckboxChange(e)}
type='checkbox'
- id={sp.id}
+ id={sp.position}
checked={sp.checked}
disabled={(this.props.value.deletable || this.props.status.policy['journey_patterns.update'] == false || this.props.editMode == false) ? 'disabled' : ''}
>
diff --git a/app/javascript/journey_patterns/reducers/journeyPatterns.js b/app/javascript/journey_patterns/reducers/journeyPatterns.js
index 6c38e9288..b046f2b38 100644
--- a/app/javascript/journey_patterns/reducers/journeyPatterns.js
+++ b/app/javascript/journey_patterns/reducers/journeyPatterns.js
@@ -22,7 +22,7 @@ const journeyPattern = (state = {}, action) =>{
}
case 'UPDATE_CHECKBOX_VALUE':
var updatedStopPoints = state.stop_points.map((s) => {
- if (String(s.id) == action.id) {
+ if (String(s.position) == action.position) {
return _.assign({}, s, {checked : !s.checked})
}else {
return s
diff --git a/app/javascript/time_tables/components/ConfirmModal.js b/app/javascript/time_tables/components/ConfirmModal.js
index 4e8583bc0..e4219348d 100644
--- a/app/javascript/time_tables/components/ConfirmModal.js
+++ b/app/javascript/time_tables/components/ConfirmModal.js
@@ -2,7 +2,7 @@ import React from 'react'
import PropTypes from 'prop-types'
-export default function ConfirmModal({dispatch, modal, onModalAccept, onModalCancel, timetable, metas}, {I18n}) {
+export default function ConfirmModal({dispatch, modal, onModalAccept, onModalCancel, timetable, metas}) {
return (
<div className={'modal fade ' + ((modal.type == 'confirm') ? 'in' : '')} id='ConfirmModal'>
<div className='modal-container'>
@@ -45,8 +45,4 @@ ConfirmModal.propTypes = {
modal: PropTypes.object.isRequired,
onModalAccept: PropTypes.func.isRequired,
onModalCancel: PropTypes.func.isRequired
-}
-
-ConfirmModal.contextTypes = {
- I18n: PropTypes.object
-}
+} \ No newline at end of file
diff --git a/app/javascript/time_tables/components/ErrorModal.js b/app/javascript/time_tables/components/ErrorModal.js
index 8af12f1d1..a512d28fd 100644
--- a/app/javascript/time_tables/components/ErrorModal.js
+++ b/app/javascript/time_tables/components/ErrorModal.js
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
import actions from '../actions'
-export default function ErrorModal({dispatch, modal, onModalClose}, {I18n}) {
+export default function ErrorModal({dispatch, modal, onModalClose}) {
return (
<div className={'modal fade ' + ((modal.type == 'error') ? 'in' : '')} id='ErrorModal'>
<div className='modal-container'>
@@ -37,8 +37,4 @@ export default function ErrorModal({dispatch, modal, onModalClose}, {I18n}) {
ErrorModal.propTypes = {
modal: PropTypes.object.isRequired,
onModalClose: PropTypes.func.isRequired
-}
-
-ErrorModal.contextTypes = {
- I18n: PropTypes.object
-}
+} \ No newline at end of file
diff --git a/app/javascript/time_tables/components/Metas.js b/app/javascript/time_tables/components/Metas.js
index 08a6e26fe..d9746a379 100644
--- a/app/javascript/time_tables/components/Metas.js
+++ b/app/javascript/time_tables/components/Metas.js
@@ -4,7 +4,7 @@ import PropTypes from 'prop-types'
import actions from '../actions'
import TagsSelect2 from './TagsSelect2'
-export default function Metas({metas, onUpdateDayTypes, onUpdateComment, onUpdateColor, onSelect2Tags, onUnselect2Tags}, {I18n}) {
+export default function Metas({metas, onUpdateDayTypes, onUpdateComment, onUpdateColor, onSelect2Tags, onUnselect2Tags}) {
let colorList = ["", "#9B9B9B", "#FFA070", "#C67300", "#7F551B", "#41CCE3", "#09B09C", "#3655D7", "#6321A0", "#E796C6", "#DD2DAA"]
return (
<div className='form-horizontal'>
@@ -134,8 +134,4 @@ Metas.propTypes = {
onUpdateColor: PropTypes.func.isRequired,
onSelect2Tags: PropTypes.func.isRequired,
onUnselect2Tags: PropTypes.func.isRequired
-}
-
-Metas.contextTypes = {
- I18n: PropTypes.object
-}
+} \ No newline at end of file
diff --git a/app/javascript/time_tables/components/PeriodForm.js b/app/javascript/time_tables/components/PeriodForm.js
index d17a246f7..36ed6cfdf 100644
--- a/app/javascript/time_tables/components/PeriodForm.js
+++ b/app/javascript/time_tables/components/PeriodForm.js
@@ -33,7 +33,7 @@ const makeYearsOptions = (yearSelected) => {
return arr
}
-export default function PeriodForm({modal, timetable, metas, onOpenAddPeriodForm, onClosePeriodForm, onUpdatePeriodForm, onValidatePeriodForm}, {I18n}) {
+export default function PeriodForm({modal, timetable, metas, onOpenAddPeriodForm, onClosePeriodForm, onUpdatePeriodForm, onValidatePeriodForm}) {
return (
<div className="container-fluid">
<div className="row">
@@ -143,8 +143,4 @@ PeriodForm.propTypes = {
onUpdatePeriodForm: PropTypes.func.isRequired,
onValidatePeriodForm: PropTypes.func.isRequired,
timetable: PropTypes.object.isRequired
-}
-
-PeriodForm.contextTypes = {
- I18n: PropTypes.object
-}
+} \ No newline at end of file
diff --git a/app/javascript/time_tables/components/PeriodManager.js b/app/javascript/time_tables/components/PeriodManager.js
index 6b817fe73..6871d0b9b 100644
--- a/app/javascript/time_tables/components/PeriodManager.js
+++ b/app/javascript/time_tables/components/PeriodManager.js
@@ -55,7 +55,7 @@ export default class PeriodManager extends Component {
type='button'
onClick={() => this.props.onOpenEditPeriodForm(this.props.value, this.props.index)}
>
- Modifier
+ {I18n.t('actions.edit')}
</button>
</li>
<li className='delete-action'>
@@ -64,7 +64,7 @@ export default class PeriodManager extends Component {
onClick={() => this.props.onDeletePeriod(this.props.index, this.props.metas.day_types)}
>
<span className='fa fa-trash'></span>
- Supprimer
+ {I18n.t('actions.destroy')}
</button>
</li>
</ul>
@@ -79,8 +79,4 @@ PeriodManager.propTypes = {
currentDate: PropTypes.object.isRequired,
onDeletePeriod: PropTypes.func.isRequired,
onOpenEditPeriodForm: PropTypes.func.isRequired
-}
-
-PeriodManager.contextTypes = {
- I18n: PropTypes.object
} \ No newline at end of file
diff --git a/app/javascript/time_tables/components/TagsSelect2.js b/app/javascript/time_tables/components/TagsSelect2.js
index 43cf59fdf..dd8d6e9c0 100644
--- a/app/javascript/time_tables/components/TagsSelect2.js
+++ b/app/javascript/time_tables/components/TagsSelect2.js
@@ -40,7 +40,7 @@ export default class TagsSelect2 extends Component {
allowClear: true,
theme: 'bootstrap',
width: '100%',
- placeholder: this.context.I18n.t('time_tables.edit.select2.tag.placeholder'),
+ placeholder: I18n.t('time_tables.edit.select2.tag.placeholder'),
ajax: {
url: origin + path + '/tags.json',
dataType: 'json',
@@ -74,8 +74,4 @@ export default class TagsSelect2 extends Component {
const formatRepo = (props) => {
if(props.name) return props.name
-}
-
-TagsSelect2.contextTypes = {
- I18n: PropTypes.object
} \ No newline at end of file
diff --git a/app/javascript/time_tables/components/Timetable.js b/app/javascript/time_tables/components/Timetable.js
index 991f31435..3779fa2d0 100644
--- a/app/javascript/time_tables/components/Timetable.js
+++ b/app/javascript/time_tables/components/Timetable.js
@@ -31,11 +31,11 @@ export default class Timetable extends Component {
<div className="table table-2entries mb-sm">
<div className="t2e-head w20">
<div className="th">
- <div className="strong">{this.context.I18n.t('time_tables.edit.synthesis')}</div>
+ <div className="strong">{I18n.t('time_tables.edit.synthesis')}</div>
</div>
- <div className="td"><span>{this.context.I18n.t('time_tables.edit.day_types')}</span></div>
- <div className="td"><span>{this.context.I18n.t('time_tables.edit.periods')}</span></div>
- <div className="td"><span>{this.context.I18n.t('time_tables.edit.exceptions')}</span></div>
+ <div className="td"><span>{I18n.t('time_tables.edit.day_types')}</span></div>
+ <div className="td"><span>{I18n.t('time_tables.edit.periods')}</span></div>
+ <div className="td"><span>{I18n.t('time_tables.edit.exceptions')}</span></div>
</div>
<div className="t2e-item-list w80">
<div>
@@ -109,8 +109,4 @@ Timetable.propTypes = {
onDeletePeriod: PropTypes.func.isRequired,
onExcludeDateFromPeriod: PropTypes.func.isRequired,
onIncludeDateInPeriod: PropTypes.func.isRequired
-}
-
-Timetable.contextTypes = {
- I18n: PropTypes.object
-}
+} \ No newline at end of file
diff --git a/app/javascript/vehicle_journeys/actions/index.js b/app/javascript/vehicle_journeys/actions/index.js
index e00e9b1b0..537dcfc06 100644
--- a/app/javascript/vehicle_journeys/actions/index.js
+++ b/app/javascript/vehicle_journeys/actions/index.js
@@ -113,14 +113,9 @@ const actions = {
type : 'EDIT_PURCHASE_WINDOWS_VEHICLEJOURNEY_MODAL',
vehicleJourneys
}),
- selectPurchaseWindowsModal: (selectedWindow) =>({
+ selectPurchaseWindowsModal: (selectedItem) =>({
type: 'SELECT_PURCHASE_WINDOW_MODAL',
- selectedItem:{
- id: selectedWindow.id,
- name: selectedWindow.name,
- color: selectedWindow.color,
- objectid: selectedWindow.objectid
- }
+ selectedItem
}),
addSelectedPurchaseWindow: () => ({
type: 'ADD_SELECTED_PURCHASE_WINDOW'
diff --git a/app/models/chouette/vehicle_journey.rb b/app/models/chouette/vehicle_journey.rb
index 525036077..be05d4053 100644
--- a/app/models/chouette/vehicle_journey.rb
+++ b/app/models/chouette/vehicle_journey.rb
@@ -346,6 +346,33 @@ module Chouette
end
end
+ def fill_passing_time_at_borders
+ encountered_borders = []
+ previous_stop = nil
+ vehicle_journey_at_stops.each do |vjas|
+ sp = vjas.stop_point
+ if sp.stop_area.area_type == "border"
+ encountered_borders << vjas
+ else
+ if encountered_borders.any?
+ before_cost = journey_pattern.costs_between previous_stop.stop_point, encountered_borders.first.stop_point
+ after_cost = journey_pattern.costs_between encountered_borders.last.stop_point, sp
+ if before_cost && before_cost[:distance] && after_cost && after_cost[:distance]
+ before_distance = before_cost[:distance].to_f
+ after_distance = after_cost[:distance].to_f
+ time = previous_stop.departure_time + before_distance / (before_distance+after_distance) * (vjas.arrival_time - previous_stop.departure_time)
+ encountered_borders.each do |b|
+ b.update_attribute :arrival_time, time
+ b.update_attribute :departure_time, time
+ end
+ end
+ encountered_borders = []
+ end
+ previous_stop = vjas
+ end
+ end
+ end
+
def self.matrix(vehicle_journeys)
Hash[*VehicleJourneyAtStop.where(vehicle_journey_id: vehicle_journeys.pluck(:id)).map do |vjas|
[ "#{vjas.vehicle_journey_id}-#{vjas.stop_point_id}", vjas]
diff --git a/app/models/concerns/custom_fields_support.rb b/app/models/concerns/custom_fields_support.rb
index ef6b4f4af..017f496a8 100644
--- a/app/models/concerns/custom_fields_support.rb
+++ b/app/models/concerns/custom_fields_support.rb
@@ -12,7 +12,7 @@ module CustomFieldsSupport
end
def method_missing method_name, *args
- if method_name =~ /custom_field_*/ && !@custom_fields_initialized
+ if method_name =~ /custom_field_*/ && method_name.to_sym != :custom_field_values && !@custom_fields_initialized
initialize_custom_fields
send method_name, *args
else
diff --git a/app/views/autocomplete_purchase_windows/index.rabl b/app/views/autocomplete_purchase_windows/index.rabl
index 1d0287602..bdc513c31 100644
--- a/app/views/autocomplete_purchase_windows/index.rabl
+++ b/app/views/autocomplete_purchase_windows/index.rabl
@@ -2,11 +2,12 @@ collection @purchase_windows, :object_root => false
node do |window|
{
- :id => window.id,
- :name => window.name,
- :objectid => window.objectid,
- :color => window.color,
- :short_id => window.get_objectid.short_id,
- :text => "<strong><span class='fa fa-circle' style='color:" + (window.color ? window.color : '#4b4b4b') + "'></span> " + window.name + " - " + window.get_objectid.short_id + "</strong>"
+ id: window.id,
+ name: window.name,
+ objectid: window.objectid,
+ color: window.color,
+ short_id: window.get_objectid.short_id,
+ bounding_dates: window.bounding_dates,
+ text: "<strong><span class='fa fa-circle' style='color:" + (window.color ? window.color : '#4b4b4b') + "'></span> " + window.name + " - " + window.get_objectid.short_id + "</strong>"
}
end
diff --git a/app/views/referentials/select_compliance_control_set.html.slim b/app/views/referentials/select_compliance_control_set.html.slim
index 3550bb202..7be82364d 100644
--- a/app/views/referentials/select_compliance_control_set.html.slim
+++ b/app/views/referentials/select_compliance_control_set.html.slim
@@ -8,7 +8,7 @@
.row
.col-lg-12
.form-group
- = label_tag 'name', nil, class: 'string required col-sm-4 col-xs-5 control-label'
+ = label_tag ComplianceControlSet.ts, nil, class: 'string required col-sm-4 col-xs-5 control-label'
.col-sm-8.col-xs-7
= select_tag :compliance_control_set, options_from_collection_for_select(@compliance_control_sets, "id", "name"), class: 'select optional form-control'
.separator
diff --git a/app/views/workbench_outputs/show.html.slim b/app/views/workbench_outputs/show.html.slim
index a9e106dbb..b310119e6 100644
--- a/app/views/workbench_outputs/show.html.slim
+++ b/app/views/workbench_outputs/show.html.slim
@@ -6,7 +6,8 @@
.row.mb-sm
.col-lg-12.text-right
= link_to t('.see_current_output'), referential_path(@workbench.output.current), class: 'btn btn-primary' if @workbench.output&.current
- = link_to t('merges.actions.create'), new_workbench_merge_path(@workbench), class: 'btn btn-primary'
+ - if policy(Merge).create?
+ = link_to t('merges.actions.create'), new_workbench_merge_path(@workbench), class: 'btn btn-primary'
.page_content
.container-fluid
diff --git a/config/locales/compliance_check_sets.en.yml b/config/locales/compliance_check_sets.en.yml
index 63708328b..73ecf8996 100644
--- a/config/locales/compliance_check_sets.en.yml
+++ b/config/locales/compliance_check_sets.en.yml
@@ -23,7 +23,7 @@ en:
table_state: "%{lines_status} lines imported out of %{lines_in_compliance_check_set} in the archive"
table_explanation: "These controls apply to all imported data and condition the construction of your organization's offer."
table_title: Analysed lines state
- metrics: "%{ok_count} ok, %{error_count} errors, %{warning_count} warnings, %{uncheck_count} n/a"
+ metrics: "%{error_count} errors, %{warning_count} warnings"
metadatas:
referential: "Object analysed"
referential_type: "Apply to"
diff --git a/config/locales/compliance_check_sets.fr.yml b/config/locales/compliance_check_sets.fr.yml
index 20bf11d85..045fed4ce 100644
--- a/config/locales/compliance_check_sets.fr.yml
+++ b/config/locales/compliance_check_sets.fr.yml
@@ -19,7 +19,7 @@ fr:
table_state: "%{lines_status} lignes valides sur %{lines_in_compliance_check_set} présentes dans l'offre de transport"
table_explanation: Ces contrôles s’appliquent pour toutes les données importées et conditionnent la construction de l’offre de votre organisation
table_title: État des lignes analysées
- metrics: "%{ok_count} ok, %{error_count} errors, %{warning_count} warnings, %{uncheck_count} n/a"
+ metrics: "%{error_count} errors, %{warning_count} warnings"
metadatas:
referential: "Objet analysé"
referential_type: "Appliqué à"
diff --git a/config/locales/import_resources.en.yml b/config/locales/import_resources.en.yml
index 386039319..4b1f9c394 100644
--- a/config/locales/import_resources.en.yml
+++ b/config/locales/import_resources.en.yml
@@ -6,7 +6,7 @@ en:
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"
+ metrics: "%{error_count} errors, %{warning_count} warnings"
import_resources:
<<: *resources
activerecord:
diff --git a/config/locales/import_resources.fr.yml b/config/locales/import_resources.fr.yml
index 50fb7f1ca..93a576f01 100644
--- a/config/locales/import_resources.fr.yml
+++ b/config/locales/import_resources.fr.yml
@@ -6,7 +6,7 @@ fr:
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"
+ metrics: "%{error_count} errors, %{warning_count} warnings"
import_resources:
<<: *resources
activerecord:
diff --git a/config/locales/referentials.fr.yml b/config/locales/referentials.fr.yml
index ec6c7c643..cf012ef8e 100644
--- a/config/locales/referentials.fr.yml
+++ b/config/locales/referentials.fr.yml
@@ -32,7 +32,7 @@ fr:
title: 'Dupliquer un jeu de données'
submit: "Valider"
select_compliance_control_set:
- title: "Sélection du jeu de contôles"
+ title: "Sélection du jeu de contrôles"
actions:
new: "Créer un jeu de données"
destroy_confirm: "Etes vous sûr de vouloir supprimer ce jeu de données ?"
diff --git a/db/migrate/20180405133659_change_companies_custom_fields_values_type.rb b/db/migrate/20180405133659_change_companies_custom_fields_values_type.rb
new file mode 100644
index 000000000..7248c29f6
--- /dev/null
+++ b/db/migrate/20180405133659_change_companies_custom_fields_values_type.rb
@@ -0,0 +1,8 @@
+class ChangeCompaniesCustomFieldsValuesType < ActiveRecord::Migration
+ def change
+ reversible do |dir|
+ dir.up { change_column :companies, :custom_field_values, 'jsonb USING CAST(custom_field_values AS jsonb)', :default => {} }
+ dir.down { change_column :companies, :custom_field_values, 'json USING CAST(custom_field_values AS json)', :default => {} }
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 0f6f21b83..023cdc7eb 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,14 +11,13 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20180319043333) do
+ActiveRecord::Schema.define(version: 20180405133659) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
- enable_extension "hstore"
enable_extension "postgis"
+ enable_extension "hstore"
enable_extension "unaccent"
- enable_extension "objectid"
create_table "access_links", id: :bigserial, force: :cascade do |t|
t.integer "access_point_id", limit: 8
@@ -118,13 +117,12 @@ ActiveRecord::Schema.define(version: 20180319043333) do
t.datetime "updated_at"
t.date "end_date"
t.string "date_type"
- t.string "mode"
end
add_index "clean_ups", ["referential_id"], name: "index_clean_ups_on_referential_id", using: :btree
create_table "companies", id: :bigserial, force: :cascade do |t|
- t.string "objectid", null: false
+ t.string "objectid", null: false
t.integer "object_version", limit: 8
t.string "name"
t.string "short_name"
@@ -141,7 +139,7 @@ ActiveRecord::Schema.define(version: 20180319043333) do
t.text "import_xml"
t.datetime "created_at"
t.datetime "updated_at"
- t.json "custom_field_values"
+ t.jsonb "custom_field_values", default: {}
end
add_index "companies", ["line_referential_id"], name: "index_companies_on_line_referential_id", using: :btree
@@ -462,9 +460,9 @@ ActiveRecord::Schema.define(version: 20180319043333) do
t.string "type"
t.integer "parent_id", limit: 8
t.string "parent_type"
+ t.datetime "notified_parent_at"
t.integer "current_step", default: 0
t.integer "total_steps", default: 0
- t.datetime "notified_parent_at"
t.string "creator"
end
@@ -1074,8 +1072,10 @@ ActiveRecord::Schema.define(version: 20180319043333) do
t.string "name"
t.integer "line_referential_id", limit: 8
t.integer "stop_area_referential_id", limit: 8
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.string "import_types", default: [], array: true
+ t.string "export_types", default: [], array: true
end
add_foreign_key "access_links", "access_points", name: "aclk_acpt_fkey"
diff --git a/db/seeds/dev/custom_fields.seeds.rb b/db/seeds/dev/custom_fields.seeds.rb
new file mode 100644
index 000000000..eb3afc394
--- /dev/null
+++ b/db/seeds/dev/custom_fields.seeds.rb
@@ -0,0 +1,52 @@
+# coding: utf-8
+
+require_relative '../seed_helpers'
+
+Workgroup.find_each do |workgroup|
+ puts workgroup.inspect
+
+ workgroup.custom_fields.seed_by(code: "capacity") do |field|
+ field.resource_type = "VehicleJourney"
+ field.name = "Bus Capacity"
+ field.field_type = "list"
+ field.options = { list_values: { "0": "", "1": "48 places", "2": "54 places" }}
+ end
+
+ workgroup.custom_fields.seed_by(code: "company_commercial_name") do |field|
+ field.resource_type = "Company"
+ field.name = "Nom commercial"
+ field.field_type = "list"
+ field.options = { list_values: { "0": "", "1": "OuiBus", "2": "Alsa" }}
+ end
+
+ workgroup.custom_fields.seed_by(code: "company_contact_name") do |field|
+ field.resource_type = "Company"
+ field.name = "Nom du référent"
+ field.field_type = "string"
+ end
+
+ workgroup.custom_fields.seed_by(code: "stop_area_test_list") do |field|
+ field.resource_type = "StopArea"
+ field.name = "Test de Liste"
+ field.field_type = "list"
+ field.options = { list_values: { "0": "", "1": "Valeur 1", "2": "Valeur 2" }}
+ end
+
+ workgroup.custom_fields.seed_by(code: "stop_area_test_string") do |field|
+ field.resource_type = "StopArea"
+ field.name = "Test de Texte"
+ field.field_type = "string"
+ end
+
+ workgroup.custom_fields.seed_by(code: "stop_area_test_integer") do |field|
+ field.resource_type = "StopArea"
+ field.name = "Test de Nomber"
+ field.field_type = "integer"
+ end
+
+ workgroup.custom_fields.seed_by(code: "stop_area_test_attachment") do |field|
+ field.resource_type = "StopArea"
+ field.name = "Test de Piece Jointe"
+ field.field_type = "attachment"
+ end
+end
diff --git a/db/seeds/development/custom_fields.seeds.rb b/db/seeds/development/custom_fields.seeds.rb
new file mode 100644
index 000000000..eb3afc394
--- /dev/null
+++ b/db/seeds/development/custom_fields.seeds.rb
@@ -0,0 +1,52 @@
+# coding: utf-8
+
+require_relative '../seed_helpers'
+
+Workgroup.find_each do |workgroup|
+ puts workgroup.inspect
+
+ workgroup.custom_fields.seed_by(code: "capacity") do |field|
+ field.resource_type = "VehicleJourney"
+ field.name = "Bus Capacity"
+ field.field_type = "list"
+ field.options = { list_values: { "0": "", "1": "48 places", "2": "54 places" }}
+ end
+
+ workgroup.custom_fields.seed_by(code: "company_commercial_name") do |field|
+ field.resource_type = "Company"
+ field.name = "Nom commercial"
+ field.field_type = "list"
+ field.options = { list_values: { "0": "", "1": "OuiBus", "2": "Alsa" }}
+ end
+
+ workgroup.custom_fields.seed_by(code: "company_contact_name") do |field|
+ field.resource_type = "Company"
+ field.name = "Nom du référent"
+ field.field_type = "string"
+ end
+
+ workgroup.custom_fields.seed_by(code: "stop_area_test_list") do |field|
+ field.resource_type = "StopArea"
+ field.name = "Test de Liste"
+ field.field_type = "list"
+ field.options = { list_values: { "0": "", "1": "Valeur 1", "2": "Valeur 2" }}
+ end
+
+ workgroup.custom_fields.seed_by(code: "stop_area_test_string") do |field|
+ field.resource_type = "StopArea"
+ field.name = "Test de Texte"
+ field.field_type = "string"
+ end
+
+ workgroup.custom_fields.seed_by(code: "stop_area_test_integer") do |field|
+ field.resource_type = "StopArea"
+ field.name = "Test de Nomber"
+ field.field_type = "integer"
+ end
+
+ workgroup.custom_fields.seed_by(code: "stop_area_test_attachment") do |field|
+ field.resource_type = "StopArea"
+ field.name = "Test de Piece Jointe"
+ field.field_type = "attachment"
+ end
+end
diff --git a/db/seeds/seed_helpers.rb b/db/seeds/seed_helpers.rb
index 8e47e10bd..708362a6c 100644
--- a/db/seeds/seed_helpers.rb
+++ b/db/seeds/seed_helpers.rb
@@ -1,6 +1,6 @@
class ActiveRecord::Base
def self.seed_by(key_attribute, &block)
- model = find_or_create_by! key_attribute
+ model = find_or_initialize_by key_attribute
print "Seed #{name} #{key_attribute.inspect} "
yield model
diff --git a/db/seeds/stif.seeds.rb b/db/seeds/stif.seeds.rb
index bb73b0b9c..98192385f 100644
--- a/db/seeds/stif.seeds.rb
+++ b/db/seeds/stif.seeds.rb
@@ -12,7 +12,7 @@ stop_area_referential = StopAreaReferential.seed_by(name: "Reflex") do |r|
end
line_referential = LineReferential.seed_by(name: "CodifLigne") do |r|
- r.objectid_format = "stif_netex"
+ r.objectid_format = "stif_codifligne"
r.add_member stif, owner: true
end
diff --git a/lib/tasks/ci.rake b/lib/tasks/ci.rake
index 5b2c8ae3c..d025a9bf1 100644
--- a/lib/tasks/ci.rake
+++ b/lib/tasks/ci.rake
@@ -10,6 +10,7 @@ namespace :ci do
desc "Prepare CI build"
task :setup do
+ cp "config/database.yml", "config/database.yml.orig"
cp "config/database/ci.yml", "config/database.yml"
puts "Use #{database_name} database"
sh "RAILS_ENV=test rake db:drop db:create db:migrate"
@@ -28,6 +29,7 @@ namespace :ci do
end
def deploy_env
+ return ENV["DEPLOY_ENV"] if ENV["DEPLOY_ENV"]
if git_branch == "master"
"dev"
elsif git_branch.in?(deploy_envs)
@@ -54,12 +56,12 @@ namespace :ci do
desc "Deploy after CI"
task :deploy do
- return if ENV["CHOUETTE_DEPLOY_DISABLED"]
-
- if deploy_env
- sh "cap #{deploy_env} deploy:migrations"
- else
- puts "No deploy for branch #{git_branch}"
+ unless ENV["CHOUETTE_DEPLOY_DISABLED"]
+ if deploy_env
+ sh "cap #{deploy_env} deploy:migrations deploy:seed"
+ else
+ puts "No deploy for branch #{git_branch}"
+ end
end
end
@@ -75,6 +77,9 @@ namespace :ci do
task :clean do
puts "Drop #{database_name} database"
sh "RAILS_ENV=test rake db:drop"
+
+ # Restore projet config/database.yml
+ cp "config/database.yml.orig", "config/database.yml" if File.exists?("config/database.yml.orig")
end
end
diff --git a/spec/models/chouette/vehicle_journey_spec.rb b/spec/models/chouette/vehicle_journey_spec.rb
index 7292f09f9..41ac5d7d0 100644
--- a/spec/models/chouette/vehicle_journey_spec.rb
+++ b/spec/models/chouette/vehicle_journey_spec.rb
@@ -868,7 +868,6 @@ describe Chouette::VehicleJourney, :type => :model do
let!( :footnote_first) {create( :footnote, :code => "1", :label => "dummy 1", :line => route.line)}
let!( :footnote_second) {create( :footnote, :code => "2", :label => "dummy 2", :line => route.line)}
-
it "should update vehicle's footnotes" do
expect(Chouette::VehicleJourney.find(subject.id).footnotes).to be_empty
subject.footnote_ids = [ footnote_first.id ]
@@ -877,4 +876,54 @@ describe Chouette::VehicleJourney, :type => :model do
end
end
end
+
+ describe "#fill_passing_time_at_borders" do
+ before do
+ start = create :stop_area
+ border = create :stop_area, kind: :non_commercial, area_type: :border
+ border_2 = create :stop_area, kind: :non_commercial, area_type: :border
+ middle = create :stop_area
+ border_3 = create :stop_area, kind: :non_commercial, area_type: :border
+ border_4 = create :stop_area, kind: :non_commercial, area_type: :border
+ _end = create :stop_area
+ journey_pattern = create :journey_pattern
+ journey_pattern.stop_points.destroy_all
+ journey_pattern.stop_points << start_point = create(:stop_point, stop_area: start, position: 0)
+ journey_pattern.stop_points << border_point = create(:stop_point, stop_area: border, position: 1)
+ journey_pattern.stop_points << border_point_2 = create(:stop_point, stop_area: border_2, position: 2)
+ journey_pattern.stop_points << middle_point = create(:stop_point, stop_area: middle, position: 3)
+ journey_pattern.stop_points << border_point_3 = create(:stop_point, stop_area: border_3, position: 4)
+ journey_pattern.stop_points << border_point_4 = create(:stop_point, stop_area: border_4, position: 5)
+ journey_pattern.stop_points << end_point = create(:stop_point, stop_area: _end, position: 6)
+ journey_pattern.update_attribute :costs, {
+ "#{start_point.stop_area_id}-#{border_point.stop_area_id}" => {distance: 50},
+ "#{border_point.stop_area_id}-#{border_point_2.stop_area_id}" => {distance: 0},
+ "#{border_point_2.stop_area_id}-#{middle_point.stop_area_id}" => {distance: 100},
+ "#{middle_point.stop_area_id}-#{border_point_3.stop_area_id}" => {distance: 100},
+ "#{border_point_3.stop_area_id}-#{border_point_4.stop_area_id}" => {distance: 0},
+ "#{border_point_4.stop_area_id}-#{end_point.stop_area_id}" => {distance: 100}
+ }
+ @journey = create :vehicle_journey, journey_pattern: journey_pattern
+ @journey.vehicle_journey_at_stops.destroy_all
+ @start = create :vehicle_journey_at_stop, stop_point: start_point, vehicle_journey: @journey
+ @target = create :vehicle_journey_at_stop, stop_point: border_point, vehicle_journey: @journey, arrival_time: nil, departure_time: nil
+ @target_2 = create :vehicle_journey_at_stop, stop_point: border_point_2, vehicle_journey: @journey, arrival_time: nil, departure_time: nil
+ @middle = create :vehicle_journey_at_stop, stop_point: middle_point, vehicle_journey: @journey, arrival_time: @start.arrival_time + 4.hours, departure_time: @start.departure_time + 4.hours
+ @target_3 = create :vehicle_journey_at_stop, stop_point: border_point_3, vehicle_journey: @journey, arrival_time: nil, departure_time: nil
+ @target_4 = create :vehicle_journey_at_stop, stop_point: border_point_4, vehicle_journey: @journey, arrival_time: nil, departure_time: nil
+ @end = create :vehicle_journey_at_stop, stop_point: end_point, vehicle_journey: @journey, arrival_time: @middle.arrival_time + 4.hours, departure_time: @middle.departure_time + 4.hours
+ end
+
+ it "should compute passing time" do
+ @journey.reload.fill_passing_time_at_borders
+ expect(@target.reload.arrival_time.to_i).to eq (@start.reload.departure_time + 1.0/3 * (@middle.reload.arrival_time - @start.departure_time)).to_i
+ expect(@target_2.reload.arrival_time).to eq @target.arrival_time
+ expect(@target.departure_time).to eq @target.arrival_time
+ expect(@target_2.departure_time).to eq @target.arrival_time
+ expect(@target_3.reload.arrival_time.to_i).to eq (@middle.reload.departure_time + 0.5 * (@end.reload.arrival_time - @middle.departure_time)).to_i
+ expect(@target_4.reload.arrival_time).to eq @target_3.arrival_time
+ expect(@target_3.departure_time).to eq @target_3.arrival_time
+ expect(@target_4.departure_time).to eq @target_3.arrival_time
+ end
+ end
end