diff options
35 files changed, 491 insertions, 238 deletions
diff --git a/app/controllers/concerns/metadata_controller_support.rb b/app/controllers/concerns/metadata_controller_support.rb index db83e79ae..4dcbfe5d0 100644 --- a/app/controllers/concerns/metadata_controller_support.rb +++ b/app/controllers/concerns/metadata_controller_support.rb @@ -20,7 +20,7 @@ module MetadataControllerSupport def set_modifier_metadata _resource = @resources || [resource] _resource.flatten.each do |r| - r.try :set_metadata!, :modifier_username, user_for_metadata + r.try(:set_metadata!, :modifier_username, user_for_metadata) if r.valid? end end end diff --git a/app/controllers/merges_controller.rb b/app/controllers/merges_controller.rb index 1ce64ed58..663b6e750 100644 --- a/app/controllers/merges_controller.rb +++ b/app/controllers/merges_controller.rb @@ -1,5 +1,5 @@ class MergesController < ChouetteController - # include PolicyChecker + include PolicyChecker defaults resource_class: Merge belongs_to :workbench diff --git a/app/controllers/time_tables_controller.rb b/app/controllers/time_tables_controller.rb index 2ac8532e0..4ca2293f0 100644 --- a/app/controllers/time_tables_controller.rb +++ b/app/controllers/time_tables_controller.rb @@ -77,7 +77,7 @@ class TimeTablesController < ChouetteController end def index - request.format.kml? ? @per_page = nil : @per_page = 12 + # request.format.kml? ? @per_page = nil : @per_page = 12 index! do |format| format.html { @@ -130,6 +130,7 @@ class TimeTablesController < ChouetteController @time_tables ||= begin time_tables = @q.result(:distinct => true) + sort_column if sort_column == "bounding_dates" time_tables = @q.result(:distinct => false).paginate(page: params[:page], per_page: 10) ids = time_tables.pluck(:id).uniq @@ -186,10 +187,13 @@ class TimeTablesController < ChouetteController private def sort_column - valid_cols = referential.time_tables.column_names - valid_cols << "bounding_dates" - valid_cols << "vehicle_journeys_count" - valid_cols.include?(params[:sort]) ? params[:sort] : 'comment' + @@valid_cols ||= begin + valid_cols = %w(id color comment) + valid_cols << "bounding_dates" + valid_cols << "vehicle_journeys_count" + valid_cols + end + @@valid_cols.include?(params[:sort]) ? params[:sort] : 'comment' end def sort_direction %w[asc desc].include?(params[:direction]) ? params[:direction] : 'asc' diff --git a/app/decorators/line_decorator.rb b/app/decorators/line_decorator.rb index 0e7b6b9ae..077978c36 100644 --- a/app/decorators/line_decorator.rb +++ b/app/decorators/line_decorator.rb @@ -35,11 +35,6 @@ class LineDecorator < AF83::Decorator edit_action_link do |l| l.content {|l| l.primary? ? h.t('actions.edit') : h.t('lines.actions.edit') } end - - action_link on: :index, secondary: :index do |l| - l.content t('lines.actions.new') - l.href { h.new_line_referential_line_path(context[:line_referential]) } - end end ### the option :policy will automatically check for the corresponding method diff --git a/app/helpers/line_referential_syncs_helper.rb b/app/helpers/line_referential_syncs_helper.rb new file mode 100644 index 000000000..37f08b154 --- /dev/null +++ b/app/helpers/line_referential_syncs_helper.rb @@ -0,0 +1,31 @@ +module LineReferentialSyncsHelper + + def last_line_ref_sync_message(line_ref_sync) + line_ref_sync.line_referential_sync_messages.last + end + + def line_referential_sync_created_at(line_ref_sync) + l(last_line_ref_sync_message(line_ref_sync).created_at, format: :short_with_time) + end + + def line_referential_sync_status(line_ref_sync) + status = line_ref_sync.status + + if %w[new pending].include? status + content_tag :span, '', class: "fa fa-clock-o" + else + cls ='' + cls = 'success' if status == 'successful' + cls = 'danger' if status == 'failed' + + content_tag :span, '', class: "fa fa-circle text-#{cls}" + end + end + + def line_referential_sync_message(line_ref_sync) + last_line_ref_sync_message = last_line_ref_sync_message(line_ref_sync) + data = last_line_ref_sync_message.message_attributes.symbolize_keys! + data[:processing_time] = distance_of_time_in_words(data[:processing_time].to_i) + t("line_referential_sync.message.#{last_line_ref_sync_message.message_key}", last_line_ref_sync_message.message_attributes.symbolize_keys!).html_safe + end +end diff --git a/app/helpers/multiple_selection_toolbox_helper.rb b/app/helpers/multiple_selection_toolbox_helper.rb index 7e02c6d73..012851b4a 100644 --- a/app/helpers/multiple_selection_toolbox_helper.rb +++ b/app/helpers/multiple_selection_toolbox_helper.rb @@ -4,7 +4,7 @@ module MultipleSelectionToolboxHelper # #5206 method too long def multiple_selection_toolbox(actions, collection_name:) links = content_tag :ul do - + # #5206 `if params[:controller]` mieux passer comme parametre si besoin delete_path = nil @@ -19,8 +19,7 @@ module MultipleSelectionToolboxHelper method: :delete, data: { path: delete_path, - # #5206 Missing Translations - confirm: t('actions.are_you_sure') + confirm: t('are_you_sure') }, title: t("actions.#{action}") ) do @@ -38,7 +37,7 @@ module MultipleSelectionToolboxHelper class: 'info-msg' ) - content_tag :div, '', + content_tag :div, '', class: 'select_toolbox noselect', id: "selected-#{collection_name}-action-box" do links + label diff --git a/app/helpers/referentials_helper.rb b/app/helpers/referentials_helper.rb index 9c3852322..a01d901e6 100644 --- a/app/helpers/referentials_helper.rb +++ b/app/helpers/referentials_helper.rb @@ -1,13 +1,15 @@ module ReferentialsHelper # Outputs a green check icon and the text "Oui" or a red exclamation mark # icon and the text "Non" based on `status` - def line_status(status) + def line_status(status, verbose=true) if status - content_tag(:span, nil, class: 'fa fa-exclamation-circle fa-lg text-danger') + - t('activerecord.attributes.line.deactivated') + out = content_tag(:span, nil, class: 'fa fa-exclamation-circle fa-lg text-danger') + out += t('activerecord.attributes.line.deactivated') if verbose + out else - content_tag(:span, nil, class: 'fa fa-check-circle fa-lg text-success') + - t('activerecord.attributes.line.activated') + out = content_tag(:span, nil, class: 'fa fa-check-circle fa-lg text-success') + out += t('activerecord.attributes.line.activated') if verbose + out end end diff --git a/app/helpers/stop_area_referential_syncs_helper.rb b/app/helpers/stop_area_referential_syncs_helper.rb new file mode 100644 index 000000000..3e2837fda --- /dev/null +++ b/app/helpers/stop_area_referential_syncs_helper.rb @@ -0,0 +1,31 @@ +module StopAreaReferentialSyncsHelper + + def last_stop_area_ref_sync_message(stop_area_ref_sync) + stop_area_ref_sync.stop_area_referential_sync_messages.last + end + + def stop_area_referential_sync_created_at(stop_area_ref_sync) + l(last_stop_area_ref_sync_message(stop_area_ref_sync).created_at, format: :short_with_time) + end + + def stop_area_referential_sync_status(stop_area_ref_sync) + status = stop_area_ref_sync.status + + if %w[new pending].include? status + content_tag :span, '', class: "fa fa-clock-o" + else + cls ='' + cls = 'success' if status == 'successful' + cls = 'danger' if status == 'failed' + + content_tag :span, '', class: "fa fa-circle text-#{cls}" + end + end + + def stop_area_referential_sync_message(stop_area_ref_sync) + last_stop_area_ref_sync_message = last_stop_area_ref_sync_message(stop_area_ref_sync) + data = last_stop_area_ref_sync_message.message_attributes.symbolize_keys! + data[:processing_time] = distance_of_time_in_words(data[:processing_time].to_i) + t("stop_area_referential_sync.message.#{last_stop_area_ref_sync_message.message_key}", last_stop_area_ref_sync_message.message_attributes.symbolize_keys!).html_safe + end +end diff --git a/app/javascript/time_tables/components/Metas.js b/app/javascript/time_tables/components/Metas.js index d9746a379..186af540a 100644 --- a/app/javascript/time_tables/components/Metas.js +++ b/app/javascript/time_tables/components/Metas.js @@ -76,7 +76,6 @@ export default function Metas({metas, onUpdateDayTypes, onUpdateComment, onUpdat <label htmlFor="" className="control-label col-sm-4">{I18n.attribute_name('time_table', 'tag_list')}</label> <div className="col-sm-8"> <TagsSelect2 - initialTags={metas.initial_tags} tags={metas.tags} onSelect2Tags={(e) => onSelect2Tags(e)} onUnselect2Tags={(e) => onUnselect2Tags(e)} diff --git a/app/javascript/time_tables/components/TagsSelect2.js b/app/javascript/time_tables/components/TagsSelect2.js index dd8d6e9c0..fe610ed58 100644 --- a/app/javascript/time_tables/components/TagsSelect2.js +++ b/app/javascript/time_tables/components/TagsSelect2.js @@ -27,7 +27,7 @@ export default class TagsSelect2 extends Component { return ( <Select2 value={(this.props.tags.length) ? map(this.props.tags, 'id') : undefined} - data={(this.props.initialTags.length) ? this.mapKeys(this.props.initialTags) : undefined} + data={(this.props.tags.length) ? this.mapKeys(this.props.tags) : undefined} onSelect={(e) => this.props.onSelect2Tags(e)} onUnselect={(e) => setTimeout( () => this.props.onUnselect2Tags(e, 150))} multiple={true} @@ -74,4 +74,4 @@ export default class TagsSelect2 extends Component { const formatRepo = (props) => { if(props.name) return props.name -}
\ No newline at end of file +} diff --git a/app/javascript/time_tables/containers/Metas.js b/app/javascript/time_tables/containers/Metas.js index ebccf556e..7bc3ef4e1 100644 --- a/app/javascript/time_tables/containers/Metas.js +++ b/app/javascript/time_tables/containers/Metas.js @@ -24,6 +24,7 @@ const mapDispatchToProps = (dispatch) => { }, onSelect2Tags: (e) => { e.preventDefault() + $(e.target).find('[data-select2-tag]').remove() dispatch(actions.select2Tags(e.params.data)) }, onUnselect2Tags: (e) => { diff --git a/app/javascript/time_tables/reducers/metas.js b/app/javascript/time_tables/reducers/metas.js index 51e1ec149..012f29511 100644 --- a/app/javascript/time_tables/reducers/metas.js +++ b/app/javascript/time_tables/reducers/metas.js @@ -31,11 +31,13 @@ export default function metas(state = {}, action) { return assign({}, state, {color: action.color}) case 'UPDATE_SELECT_TAG': let tags = [...state.tags] - tags.push(action.selectedItem) + if(tags.length == 0 || tags[tags.length-1].name != action.selectedItem.name){ + tags.push(action.selectedItem) + } return assign({}, state, {tags: tags}) case 'UPDATE_UNSELECT_TAG': return assign({}, state, {tags: filter(state.tags, (t) => (t.id != action.selectedItem.id))}) default: return state } -}
\ No newline at end of file +} diff --git a/app/models/chouette/stop_area.rb b/app/models/chouette/stop_area.rb index 4ddc7403b..b933e1944 100644 --- a/app/models/chouette/stop_area.rb +++ b/app/models/chouette/stop_area.rb @@ -436,6 +436,12 @@ module Chouette ActiveSupport::TimeZone[time_zone]&.utc_offset end + def full_time_zone_name + return unless time_zone.present? + return unless ActiveSupport::TimeZone[time_zone].present? + ActiveSupport::TimeZone[time_zone].tzinfo.name + end + def country return unless country_code country = ISO3166::Country[country_code] diff --git a/app/models/import/gtfs.rb b/app/models/import/gtfs.rb index 70f448132..a20c468c1 100644 --- a/app/models/import/gtfs.rb +++ b/app/models/import/gtfs.rb @@ -56,12 +56,16 @@ class Import::Gtfs < Import::Base attr_accessor :download_host def download_host - @download_host ||= Rails.application.config.rails_host.gsub("http://","") + @download_host ||= Rails.application.config.rails_host end def local_temp_directory - Rails.application.config.try(:import_temporary_directory) || - Rails.root.join('tmp', 'imports') + @local_temp_directory ||= + begin + directory = Rails.application.config.try(:import_temporary_directory) || Rails.root.join('tmp', 'imports') + FileUtils.mkdir_p directory + directory + end end def local_temp_file(&block) @@ -75,11 +79,20 @@ class Import::Gtfs < Import::Base Rails.application.routes.url_helpers.download_workbench_import_path(workbench, id, token: token_download) end + def download_uri + @download_uri ||= + begin + host = download_host + host = "http://#{host}" unless host =~ %r{https?://} + URI.join(host, download_path) + end + end + def download_local_file local_temp_file do |file| begin - Net::HTTP.start(download_host) do |http| - http.request_get(download_path) do |response| + Net::HTTP.start(download_uri.host, download_uri.port) do |http| + http.request_get(download_uri.request_uri) do |response| response.read_body do |segment| file.write segment end diff --git a/app/policies/merge_policy.rb b/app/policies/merge_policy.rb index 82eb72e08..154dc63f5 100644 --- a/app/policies/merge_policy.rb +++ b/app/policies/merge_policy.rb @@ -8,8 +8,4 @@ class MergePolicy < ApplicationPolicy def create? user.has_permission?('merges.create') end - - def update? - user.has_permission?('merges.update') - end end diff --git a/app/views/layouts/navigation/_main_nav_left_content.html.slim b/app/views/layouts/navigation/_main_nav_left_content.html.slim index e69de29bb..f04d05700 100644 --- a/app/views/layouts/navigation/_main_nav_left_content.html.slim +++ b/app/views/layouts/navigation/_main_nav_left_content.html.slim @@ -0,0 +1,87 @@ +- if current_organisation + - current_organisation.workbenches.each do |workbench| + #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 + = t('layouts.navbar.current_offer.other') + + #miOne.panel-collapse.collapse + .list-group + = link_to root_path, class: "list-group-item" do + span = t('layouts.navbar.dashboard') + = link_to workbench_output_path(workbench), class: 'list-group-item' do + span = t('layouts.navbar.workbench_outputs.organisation') + = link_to '#', class: 'list-group-item disabled' do + span = t('layouts.navbar.workbench_outputs.workgroup') + + .menu-item.panel + .panel-heading + h4.panel-title + = link_to '#miTwo', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do + - t('activerecord.models.workbench.one').capitalize + + #miTwo.panel-collapse.collapse + .list-group + = link_to workbench_path(workbench), class: "list-group-item" do + span = t('activerecord.models.referential.other').capitalize + = link_to workbench_imports_path(workbench), class: "list-group-item" do + span = t('activerecord.models.import.other').capitalize + = link_to workbench_exports_path(workbench), class: "list-group-item" do + span = t('activerecord.models.export.other').capitalize + = link_to workgroup_calendars_path(workbench.workgroup), class: 'list-group-item' do + span = t('activerecord.models.calendar.other').capitalize + = link_to workbench_compliance_check_sets_path(workbench), class: 'list-group-item' do + span = t('activerecord.models.compliance_check_set.other').capitalize + = link_to compliance_control_sets_path, class: 'list-group-item' do + span = t('activerecord.models.compliance_control_set.other').capitalize + + .menu-item.panel + .panel-heading + h4.panel-title + = link_to '#miThree', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do + = t('layouts.navbar.referential_datas') + + #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_time_tables_path(current_referential), class: 'list-group-item' do + span = t('time_tables.index.title').capitalize + - if has_feature?(:purchase_windows) + = link_to referential_purchase_windows_path(current_referential), class: 'list-group-item' do + span = t('purchase_windows.index.title').capitalize + + - else + .panel-body + em.text-muted + = t('layouts.navbar.select_referential_for_more_features') + + .menu-item.panel + .panel-heading + h4.panel-title + = link_to '#miFour', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do + = t('layouts.navbar.line_referential') + + #miFour.panel-collapse.collapse + .list-group + = link_to line_referential_lines_path(workbench.line_referential), class: "list-group-item" do + span = Chouette::Line.t.capitalize + = link_to line_referential_networks_path(workbench.line_referential), class: "list-group-item" do + span = Chouette::Network.t.capitalize + = link_to line_referential_companies_path(workbench.line_referential), class: "list-group-item" do + span = Chouette::Company.t.capitalize + + .menu-item.panel + .panel-heading + h4.panel-title + = link_to '#miFive', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do + = t('layouts.navbar.stop_area_referential') + + #miFive.panel-collapse.collapse + .list-group + = link_to stop_area_referential_stop_areas_path(workbench.stop_area_referential), class: "list-group-item" do + span = Chouette::StopArea.t.capitalize 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 index 3741ef19b..589f99ae3 100644 --- a/app/views/layouts/navigation/_main_nav_left_content_stif.html.slim +++ b/app/views/layouts/navigation/_main_nav_left_content_stif.html.slim @@ -1,109 +1,125 @@ -- @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 - = t('layouts.navbar.current_offer.other') - - #miOne.panel-collapse.collapse - .list-group - = link_to root_path, class: "list-group-item #{(@localizationUrl == 'workbenches#index') ? 'active' : ''}" do - span = t('layouts.navbar.dashboard') - = link_to workbench_output_path(current_user.workbenches.first), class: 'list-group-item' do - span = t('layouts.navbar.workbench_outputs.organisation') - = link_to '#', class: 'list-group-item' do - span = t('layouts.navbar.workbench_outputs.idf') - - .menu-item.panel - .panel-heading - h4.panel-title - = link_to '#miTwo', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do - - t('activerecord.models.workbench.one').capitalize - - #miTwo.panel-collapse.collapse - .list-group - - current_user.workbenches.each do |current_workbench| - = link_to workbench_path(current_workbench), class: "list-group-item #{params[:controller] == 'workbenches' ? 'active' : ''}" do - span = t('activerecord.models.referential.other').capitalize - = link_to workbench_imports_path(current_workbench), class: "list-group-item #{(params[:controller] == 'imports') ? 'active' : ''}" do - span = t('activerecord.models.import.other').capitalize - = link_to workbench_exports_path(current_workbench), class: "list-group-item #{(params[:controller] == 'exports') ? 'active' : ''}" do - span = t('activerecord.models.export.other').capitalize - = link_to workgroup_calendars_path(current_workbench.workgroup), class: 'list-group-item' do - span = t('activerecord.models.calendar.other').capitalize - = link_to workbench_compliance_check_sets_path(current_workbench), class: 'list-group-item' do - span = t('activerecord.models.compliance_check_set.other').capitalize - = link_to compliance_control_sets_path, class: 'list-group-item' do - span = t('activerecord.models.compliance_control_set.other').capitalize - - .menu-item.panel - .panel-heading - h4.panel-title - = link_to '#miThree', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do - = t('layouts.navbar.referential_datas') - - #miThree.panel-collapse.collapse - - if @referential.try(:id) && respond_to?(:current_referential) - .list-group - .list-group-item - = (current_referential.name).upcase +- if current_organisation + - current_organisation.workbenches.each do |workbench| + #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 + = t('layouts.navbar.current_offer.other') + + #miOne.panel-collapse.collapse + .list-group + = link_to root_path, class: "list-group-item" do + span = t('layouts.navbar.dashboard') + = link_to workbench_output_path(workbench), class: 'list-group-item' do + span = t('layouts.navbar.workbench_outputs.organisation') + = link_to '#', class: 'list-group-item disabled' do + span = t('layouts.navbar.workbench_outputs.workgroup') + + .menu-item.panel + .panel-heading + h4.panel-title + = link_to '#miTwo', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do + - t('activerecord.models.workbench.one').capitalize + + #miTwo.panel-collapse.collapse + .list-group + = link_to workbench_path(workbench), class: "list-group-item" do + span = t('activerecord.models.referential.other').capitalize + = link_to workbench_imports_path(workbench), class: "list-group-item" do + span = t('activerecord.models.import.other').capitalize + = link_to workbench_exports_path(workbench), class: "list-group-item" do + span = t('activerecord.models.export.other').capitalize + = link_to workgroup_calendars_path(workbench.workgroup), class: 'list-group-item' do + span = t('activerecord.models.calendar.other').capitalize + = link_to workbench_compliance_check_sets_path(workbench), class: 'list-group-item' do + span = t('activerecord.models.compliance_check_set.other').capitalize + = link_to compliance_control_sets_path, class: 'list-group-item' do + span = t('activerecord.models.compliance_control_set.other').capitalize + + .menu-item.panel + .panel-heading + h4.panel-title + = link_to '#miThree', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do + = Referential.ts.capitalize + + #miThree.panel-collapse.collapse + - if @referential.try(:id) && respond_to?(:current_referential) .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 = t('layouts.navbar.shapes') - - = 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 - = t('layouts.navbar.select_referential_for_more_features') - - .menu-item.panel - .panel-heading - h4.panel-title - = link_to '#miFour', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do - = t('layouts.navbar.sync') - - #miFour.panel-collapse.collapse - .list-group - = link_to line_referential_path(1), class: "list-group-item #{(@localizationUrl == 'line_referentials#show') ? 'active' : ''}" do - span = t('layouts.navbar.sync_ilico') - = link_to stop_area_referential_path(1), class: "list-group-item #{(@localizationUrl == 'stop_area_referentials#show') ? 'active' : ''}" do - span = t('layouts.navbar.sync_icar') - - .menu-item.panel - .panel-heading - h4.panel-title - = link_to '#miFive', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do - = t('layouts.navbar.tools') - - #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 - = t('layouts.navbar.portal') - - = link_to Rails.application.config.try(:codifligne_url), target: '_blank', class: 'list-group-item' do - span - span.fa.fa-2x.fa-circle - = t('layouts.navbar.ilico') - - = link_to Rails.application.config.try(:reflex_url), target: '_blank', class: 'list-group-item' do - span - span.fa.fa-2x.fa-circle - = t('layouts.navbar.icar') - - = link_to '#', target: '_blank', class: 'list-group-item' do - span - span.fa.fa-2x.fa-circle - = t('layouts.navbar.support')
\ No newline at end of file + .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 = t('layouts.navbar.shapes') + + = 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 + = t('layouts.navbar.select_referential_for_more_features') + + .menu-item.panel + .panel-heading + h4.panel-title + = link_to '#miFour', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do + = t('layouts.navbar.line_referential') + + #miFour.panel-collapse.collapse + .list-group + = link_to line_referential_path(workbench.line_referential), class: "list-group-item" do + span = t('layouts.navbar.sync_ilico') + = link_to line_referential_lines_path(workbench.line_referential), class: "list-group-item" do + span = Chouette::Line.t.capitalize + = link_to line_referential_networks_path(workbench.line_referential), class: "list-group-item" do + span = Chouette::Network.t.capitalize + = link_to line_referential_companies_path(workbench.line_referential), class: "list-group-item" do + span = Chouette::Company.t.capitalize + + .menu-item.panel + .panel-heading + h4.panel-title + = link_to '#miFive', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do + = t('layouts.navbar.stop_area_referential') + + #miFive.panel-collapse.collapse + .list-group + = link_to stop_area_referential_path(workbench.stop_area_referential), class: "list-group-item" do + span = t('layouts.navbar.sync_icar') + = link_to stop_area_referential_stop_areas_path(workbench.stop_area_referential), class: "list-group-item" do + span = Chouette::StopArea.t.capitalize + + .menu-item.panel + .panel-heading + h4.panel-title + = link_to '#miSix', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do + = t('layouts.navbar.tools') + + #miSix.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 + = t('layouts.navbar.portal') + + = link_to Rails.application.config.try(:codifligne_url), target: '_blank', class: 'list-group-item' do + span + span.fa.fa-2x.fa-circle + = t('layouts.navbar.ilico') + + = link_to Rails.application.config.try(:reflex_url), target: '_blank', class: 'list-group-item' do + span + span.fa.fa-2x.fa-circle + = t('layouts.navbar.icar') + + = link_to '#', target: '_blank', class: 'list-group-item' do + span + span.fa.fa-2x.fa-circle + = t('layouts.navbar.support') diff --git a/app/views/line_referentials/show.html.slim b/app/views/line_referentials/show.html.slim index 763eb076e..4a4acc427 100644 --- a/app/views/line_referentials/show.html.slim +++ b/app/views/line_referentials/show.html.slim @@ -4,44 +4,29 @@ - content_for :page_header_actions do = link_to(t('actions.sync'), sync_line_referential_path(@line_referential), method: :post, class: 'btn btn-default') -- content_for :page_header_content do - .row.mb-md - .col-lg-12.text-right - = link_to line_referential_companies_path(@line_referential), class: 'btn btn-primary' do - = Referential.human_attribute_name(:companies) - em.small = " (#{@line_referential.companies.size})" - = link_to line_referential_networks_path(@line_referential), class: 'btn btn-primary' do - = Referential.human_attribute_name(:networks) - em.small = " (#{@line_referential.networks.size})" - = link_to line_referential_lines_path(@line_referential), class: 'btn btn-primary' do - = Referential.human_attribute_name(:lines) - em.small = " (#{@line_referential.lines.size})" - .page_content .container-fluid .row .col-lg-12 - - unless @line_referential.line_referential_syncs.empty? - table.table - thead - tr - th = t('.synchronized') - th = t('.status') - th = t('.message') + = table_builder_2 @line_referential.line_referential_syncs, + [ \ + TableBuilderHelper::Column.new( \ + name: t('.synchronized'), \ + attribute: Proc.new { |sync| line_referential_sync_created_at(sync) }, \ + ), \ + TableBuilderHelper::Column.new( \ + name: t('.status'), \ + attribute: Proc.new { |sync| line_referential_sync_status(sync) }, \ + ), \ + TableBuilderHelper::Column.new( \ + name: t('.message'), \ + attribute: Proc.new { |sync| line_referential_sync_message(sync) }, \ + ), \ + ], + sortable: false, + cls: 'table' - tbody - - @line_referential.line_referential_syncs.each_with_index do |sync, i| - / Display only 10 msgs - - if i < 10 - - unless sync.line_referential_sync_messages.empty? - - sync.line_referential_sync_messages.last.tap do |log| - - if log.criticity = log.criticity - tr - td style='width: 150px' - = l(log.created_at, format: :short_with_time) - td.text-center - .fa.fa-circle class="text-#{criticity_class(log.criticity)}" - td - - data = log.message_attributes.symbolize_keys! - - data[:processing_time] = distance_of_time_in_words(data[:processing_time].to_i) - = t("line_referential_sync.message.#{log.message_key}", log.message_attributes.symbolize_keys!).html_safe + - unless @line_referential.line_referential_syncs.any? + .row.mt-xs + .col-lg-12 + = replacement_msg t('line_referential_syncs.search_no_results') diff --git a/app/views/lines/show.html.slim b/app/views/lines/show.html.slim index 9e1ae6d6f..b683b9be6 100644 --- a/app/views/lines/show.html.slim +++ b/app/views/lines/show.html.slim @@ -7,13 +7,13 @@ .col-lg-6.col-md-6.col-sm-12.col-xs-12 = definition_list t('metadatas'), { t('objectid') => @line.get_objectid.short_id, - @line.human_attribute_name(:deactivated) => (@line.deactivated? ? t('false') : t('true')), - @line.human_attribute_name(:network_id) => (@line.network.nil? ? t('lines.index.unset') : @line.network.name), - @line.human_attribute_name(:company_id) => (@line.company.nil? ? t('lines.index.unset') : @line.company.name), - @line.human_attribute_name(:secondary_companies) => (@line.secondary_companies.nil? ? t('lines.index.unset') : array_to_html_list(@line.secondary_companies.collect(&:name))), - @line.human_attribute_name(:number) => @line.number, - @line.human_attribute_name(:registration_number) => (@line.registration_number ? @line.registration_number : '-'), - @line.human_attribute_name(:transport_mode) => (@line.transport_mode.present? ? t("enumerize.transport_mode.#{@line.transport_mode}") : '-'), - @line.human_attribute_name(:transport_submode) => (@line.transport_submode.present? ? t("enumerize.transport_submode.#{@line.transport_submode}") : '-'), - @line.human_attribute_name(:url) => (@line.url ? @line.url : '-'), - @line.human_attribute_name(:seasonal) => (@line.seasonal? ? t('true') : t('false')),} + Chouette::Line.tmf(:state) => line_status(@line.deactivated), + Chouette::Line.tmf(:network_id) => (@line.network.nil? ? t('lines.index.unset') : @line.network.name), + Chouette::Line.tmf(:company_id) => (@line.company.nil? ? t('lines.index.unset') : @line.company.name), + Chouette::Line.tmf(:secondary_companies) => (@line.secondary_companies.nil? ? t('lines.index.unset') : array_to_html_list(@line.secondary_companies.collect(&:name))), + Chouette::Line.tmf(:number) => @line.number, + Chouette::Line.tmf(:registration_number) => (@line.registration_number ? @line.registration_number : '-'), + Chouette::Line.tmf(:transport_mode) => (@line.transport_mode.present? ? t("enumerize.transport_mode.#{@line.transport_mode}") : '-'), + Chouette::Line.tmf(:transport_submode) => (@line.transport_submode.present? ? t("enumerize.transport_submode.#{@line.transport_submode}") : '-'), + Chouette::Line.tmf(:url) => (@line.url ? @line.url : '-'), + Chouette::Line.tmf(:seasonal) => (@line.seasonal? ? t('true') : t('false')),} diff --git a/app/views/referential_lines/show.html.slim b/app/views/referential_lines/show.html.slim index 91868a002..4804da527 100644 --- a/app/views/referential_lines/show.html.slim +++ b/app/views/referential_lines/show.html.slim @@ -7,10 +7,10 @@ .col-lg-6.col-md-6.col-sm-12.col-xs-12 = definition_list t('metadatas'), { t('id_codif') => @line.get_objectid.short_id, - Chouette::Line.tmf('activated') => (@line.deactivated? ? t('false') : t('true')), + Chouette::Line.tmf('state') => line_status(@line.deactivated), Chouette::Line.tmf('network_id') => (@line.network.nil? ? t('lines.index.unset') : link_to(@line.network.name, [@referential, @line.network]) ), Chouette::Line.tmf('company') => (@line.company.nil? ? t('lines.index.unset') : link_to(@line.company.name, [@referential, @line.company]) ), - Chouette::Line.tmf('secondary_company') => (@line.secondary_companies.nil? ? t('lines.index.unset') : @line.secondary_companies.collect(&:name).join(', ')), + Chouette::Line.tmf('secondary_companies') => (@line.secondary_companies.nil? ? t('lines.index.unset') : @line.secondary_companies.collect(&:name).join(', ')), Chouette::Line.tmf('registration_number') => @line.number, Chouette::Line.tmf('published_name') => (@line.registration_number ? @line.registration_number : '-'), Chouette::Line.tmf('transport_mode') => (@line.transport_mode.present? ? t("enumerize.transport_mode.#{@line.transport_mode}") : '-'), diff --git a/app/views/stop_area_referentials/show.html.slim b/app/views/stop_area_referentials/show.html.slim index 911006c39..9a0079330 100644 --- a/app/views/stop_area_referentials/show.html.slim +++ b/app/views/stop_area_referentials/show.html.slim @@ -2,40 +2,30 @@ - if policy(@stop_area_referential).synchronize? - content_for :page_header_actions do = link_to(t('actions.sync'), sync_stop_area_referential_path(@stop_area_referential), method: :post, class: 'btn btn-default') - -- content_for :page_header_content do - .row.mb-md - .col-lg-12.text-right - = link_to stop_area_referential_stop_areas_path(@stop_area_referential), class: 'btn btn-primary' do - = Referential.human_attribute_name(:stop_areas) - em.small = " (#{@stop_area_referential.stop_areas.count})" -- page_header_content_for @stop_area_referential - + .page_content .container-fluid .row .col-lg-12 - - unless @stop_area_referential.stop_area_referential_syncs.empty? - table.table - thead - tr - th Synchronisé - th Statut - th Message + = table_builder_2 @stop_area_referential.stop_area_referential_syncs, + [ \ + TableBuilderHelper::Column.new( \ + name: t('.synchronized'), \ + attribute: Proc.new { |sync| stop_area_referential_sync_created_at(sync) }, \ + ), \ + TableBuilderHelper::Column.new( \ + name: t('.status'), \ + attribute: Proc.new { |sync| stop_area_referential_sync_status(sync) }, \ + ), \ + TableBuilderHelper::Column.new( \ + name: t('.message'), \ + attribute: Proc.new { |sync| stop_area_referential_sync_message(sync) }, \ + ), \ + ], + sortable: false, + cls: 'table' - tbody - - @stop_area_referential.stop_area_referential_syncs.each_with_index do |sync, i| - / Display only 10 msgs - - if i < 10 - - unless sync.stop_area_referential_sync_messages.empty? - - sync.stop_area_referential_sync_messages.last.tap do |log| - - if log.criticity = log.criticity - tr - td style='width:150px' - = l(log.created_at, format: :short_with_time) - td.text-center - .fa.fa-circle class="text-#{criticity_class(log.criticity)}" - td - - data = log.message_attributes.symbolize_keys! - - data[:processing_time] = distance_of_time_in_words(data[:processing_time].to_i) - = t("stop_area_referential_sync.message.#{log.message_key}", log.message_attributes.symbolize_keys!).html_safe + - unless @stop_area_referential.stop_area_referential_syncs.any? + .row.mt-xs + .col-lg-12 + = replacement_msg t('stop_area_referential_syncs.search_no_results') diff --git a/config/breadcrumbs.rb b/config/breadcrumbs.rb index e57cbc4f2..e60ff187f 100644 --- a/config/breadcrumbs.rb +++ b/config/breadcrumbs.rb @@ -169,7 +169,6 @@ end crumb :companies do |line_referential| link I18n.t('companies.index.title'), line_referential_companies_path(line_referential) - parent :line_referential, line_referential end crumb :company do |company| @@ -179,7 +178,6 @@ end crumb :networks do |line_referential| link I18n.t('networks.index.title'), line_referential_networks_path(line_referential) - parent :line_referential, line_referential end crumb :network do |network| @@ -189,7 +187,6 @@ end crumb :group_of_lines do |line_referential| link I18n.t('group_of_lines.index.title'), line_referential_group_of_lines_path(line_referential) - parent :line_referential, line_referential end crumb :group_of_line do |group_of_line| @@ -199,7 +196,6 @@ end crumb :lines do |line_referential| link I18n.t('lines.index.title'), line_referential_lines_path - parent :line_referential, line_referential end crumb :line do |line| diff --git a/config/locales/layouts.en.yml b/config/locales/layouts.en.yml index 954525ac4..76a4d65d1 100644 --- a/config/locales/layouts.en.yml +++ b/config/locales/layouts.en.yml @@ -15,7 +15,9 @@ en: return_to_dashboard: "Return to Dashboard" dashboard: Dashboard referential_datas: "Datas" - current_offer: + line_referential: "Line referential" + stop_area_referential: "Stop area referential" + current_offer: one: Current offer other: Current offers workbench_output: @@ -68,4 +70,4 @@ en: attributes: author: "Edited by" created_at: "Created at" - updated_at: "Updated at"
\ No newline at end of file + updated_at: "Updated at" diff --git a/config/locales/layouts.fr.yml b/config/locales/layouts.fr.yml index f125a002d..019c72701 100644 --- a/config/locales/layouts.fr.yml +++ b/config/locales/layouts.fr.yml @@ -15,12 +15,14 @@ fr: return_to_dashboard: "Retour au Tableau de Bord" dashboard: Tableau de bord referential_datas: "Données" - current_offer: + line_referential: "Référentiel de lignes" + stop_area_referential: "Référentiel d'arrêts" + current_offer: one: Offres courante other: Offres courantes workbench_outputs: - organisation: Offres de mon organisation - idf: Offres IDF + organisation: Offre de mon organisation + workgroup: Offre du groupe de travail tools: Outils sync: Synchronisation sync_icar: Synchronisation iCAR diff --git a/config/locales/line_referential_syncs.en.yml b/config/locales/line_referential_syncs.en.yml index 5cbab1173..8d17fcefc 100644 --- a/config/locales/line_referential_syncs.en.yml +++ b/config/locales/line_referential_syncs.en.yml @@ -1,4 +1,6 @@ en: + line_referential_syncs: + search_no_results: "No line referential synchronisation matching your query" activerecord: errors: models: diff --git a/config/locales/line_referential_syncs.fr.yml b/config/locales/line_referential_syncs.fr.yml index 33827fac9..7f1b1ba75 100644 --- a/config/locales/line_referential_syncs.fr.yml +++ b/config/locales/line_referential_syncs.fr.yml @@ -1,4 +1,6 @@ fr: + line_referential_syncs: + search_no_results: "Aucun synchronisation de référentiel de lignes ne correspond à votre recherche" activerecord: errors: models: diff --git a/config/locales/lines.en.yml b/config/locales/lines.en.yml index 1cd5150db..3d1ddc149 100644 --- a/config/locales/lines.en.yml +++ b/config/locales/lines.en.yml @@ -78,7 +78,7 @@ en: name: "Network" company_id: "Company" company: "Company" - secondary_company: "Secondary company" + secondary_companies: "Secondary companies" companies: name: "Company" registration_number: "Registration number" diff --git a/config/locales/lines.fr.yml b/config/locales/lines.fr.yml index 6f4a2e9bf..47baf96f8 100644 --- a/config/locales/lines.fr.yml +++ b/config/locales/lines.fr.yml @@ -79,7 +79,7 @@ fr: name: "Réseau" company_id: "Transporteur principal" company: "Transporteur principal" - secondary_company: "Transporteurs secondaires" + secondary_companies: "Transporteurs secondaires" companies: name: "Transporteur principal" registration_number: "Nom court" diff --git a/config/locales/purchase_windows.fr.yml b/config/locales/purchase_windows.fr.yml index 3d5582ead..7f2ec259f 100644 --- a/config/locales/purchase_windows.fr.yml +++ b/config/locales/purchase_windows.fr.yml @@ -27,7 +27,7 @@ fr: show: "Consulter" edit: Editer destroy: Supprimer - destroy_confirm: Etes vous sûr de supprimer cet calendrier commercial ? + destroy_confirm: Etes vous sûr de vouloir supprimer ce calendrier commercial ? errors: overlapped_periods: Une autre période chevauche cette période short_period: "Une période doit être d'une durée de deux jours minimum" diff --git a/config/locales/stop_area_referential_syncs.en.yml b/config/locales/stop_area_referential_syncs.en.yml index 2bfe0bc0a..1605f73f2 100644 --- a/config/locales/stop_area_referential_syncs.en.yml +++ b/config/locales/stop_area_referential_syncs.en.yml @@ -1,4 +1,6 @@ en: + stop_area_referential_syncs: + search_no_results: "No stop area referential synchronisation matching your query" activerecord: errors: models: diff --git a/config/locales/stop_area_referential_syncs.fr.yml b/config/locales/stop_area_referential_syncs.fr.yml index cbed11883..b4ed7202b 100644 --- a/config/locales/stop_area_referential_syncs.fr.yml +++ b/config/locales/stop_area_referential_syncs.fr.yml @@ -1,4 +1,6 @@ fr: + stop_area_referential_syncs: + search_no_results: "Aucun synchronisation de référentiel d'arrêts ne correspond à votre recherche" activerecord: errors: models: diff --git a/config/locales/zzz-stif.yml b/config/locales/zzz-stif.yml new file mode 100644 index 000000000..a9e6a0ef4 --- /dev/null +++ b/config/locales/zzz-stif.yml @@ -0,0 +1,5 @@ +fr: + layouts: + navbar: + workbench_outputs: + workgroup: Offre IDF diff --git a/spec/features/merges_permissions_spec.rb b/spec/features/merges_permissions_spec.rb new file mode 100644 index 000000000..e8af3b5e8 --- /dev/null +++ b/spec/features/merges_permissions_spec.rb @@ -0,0 +1,31 @@ +describe "Merges", :type => :feature do + login_user + + describe 'permissions' do + before do + allow_any_instance_of(MergePolicy).to receive(:create?).and_return permission + visit path + end + + describe 'on show view' do + let( :path ){ workbench_output_path(referential.workbench) } + let(:button_text) { I18n.t('merges.actions.create') } + + context 'if present → ' do + let( :permission ){ true } + it 'view shows the corresponding buttons' do + expected_new_url = new_workbench_merge_path(referential.workbench) + expect( page ).to have_link(button_text, href: expected_new_url) + end + end + + context 'if absent → ' do + let( :permission ){ false } + it 'view does not show the corresponding buttons' do + expect( page ).not_to have_link(button_text) + end + end + end + + end +end diff --git a/spec/models/import/gtfs_spec.rb b/spec/models/import/gtfs_spec.rb index b4b23be00..96b93dc62 100644 --- a/spec/models/import/gtfs_spec.rb +++ b/spec/models/import/gtfs_spec.rb @@ -262,10 +262,53 @@ RSpec.describe Import::Gtfs do end end - describe "#download_host" do - it "should return host defined by Rails.application.config.rails_host (without http:// schema)" do - allow(Rails.application.config).to receive(:rails_host).and_return("http://download_host") + describe "#download_uri" do + let(:import) { Import::Gtfs.new } + + before do + allow(import).to receive(:download_path).and_return("/download_path") + end + + context "when download_host is 'front'" do + before { allow(import).to receive(:download_host).and_return("front") } + it "returns http://front/download_path" do + expect(import.download_uri.to_s).to eq('http://front/download_path') + end + end + + context "when download_host is 'front:3000'" do + before { allow(import).to receive(:download_host).and_return("front:3000") } + it "returns http://front:3000/download_path" do + expect(import.download_uri.to_s).to eq('http://front:3000/download_path') + end + end + + context "when download_host is 'http://front:3000'" do + before { allow(import).to receive(:download_host).and_return("http://front:3000") } + it "returns http://front:3000/download_path" do + expect(import.download_uri.to_s).to eq('http://front:3000/download_path') + end + end + + context "when download_host is 'https://front:3000'" do + before { allow(import).to receive(:download_host).and_return("https://front:3000") } + it "returns https://front:3000/download_path" do + expect(import.download_uri.to_s).to eq('https://front:3000/download_path') + end + end + context "when download_host is 'http://front'" do + before { allow(import).to receive(:download_host).and_return("http://front") } + it "returns http://front/download_path" do + expect(import.download_uri.to_s).to eq('http://front/download_path') + end + end + + end + + describe "#download_host" do + it "should return host defined by Rails.application.config.rails_host" do + allow(Rails.application.config).to receive(:rails_host).and_return("download_host") expect(Import::Gtfs.new.download_host).to eq("download_host") end end diff --git a/spec/policies/merge_policy_spec.rb b/spec/policies/merge_policy_spec.rb new file mode 100644 index 000000000..55d723080 --- /dev/null +++ b/spec/policies/merge_policy_spec.rb @@ -0,0 +1,9 @@ +RSpec.describe MergePolicy, type: :policy do + + let( :record ){ build_stubbed :route } + + permissions :create? do + it_behaves_like 'permitted policy outside referential', 'merges.create' + end + +end |
