aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/concerns/metadata_controller_support.rb2
-rw-r--r--app/controllers/time_tables_controller.rb14
-rw-r--r--app/helpers/multiple_selection_toolbox_helper.rb7
-rw-r--r--app/helpers/referentials_helper.rb12
-rw-r--r--app/models/import/gtfs.rb8
-rw-r--r--app/views/lines/show.html.slim20
-rw-r--r--app/views/referential_lines/show.html.slim4
7 files changed, 38 insertions, 29 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/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/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/models/import/gtfs.rb b/app/models/import/gtfs.rb
index 70f448132..f017c8ee5 100644
--- a/app/models/import/gtfs.rb
+++ b/app/models/import/gtfs.rb
@@ -60,8 +60,12 @@ class Import::Gtfs < Import::Base
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)
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}") : '-'),