aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorMichel Etienne2014-11-24 10:53:58 +0100
committerMichel Etienne2014-11-24 10:53:58 +0100
commit47ae076cff0e3cc65f00a266db05fdc4496089cd (patch)
tree045b222d6cc9d0c46e2e672c6a6575ddd4e6c48c /app
parent8f54c31ac1775b1bc1efcf555750fcdd6fc61639 (diff)
parent4db22a974de47194687560e122372dad4c88a9a5 (diff)
downloadchouette-core-47ae076cff0e3cc65f00a266db05fdc4496089cd.tar.bz2
Merge branch 'V2_5' of github.com:afimb/chouette2 into V2_5
Diffstat (limited to 'app')
-rw-r--r--app/controllers/exports_controller.rb13
-rw-r--r--app/exporters/chouette/hub/exporter.rb11
-rw-r--r--app/views/exports/_fields_hub_export.erb1
3 files changed, 20 insertions, 5 deletions
diff --git a/app/controllers/exports_controller.rb b/app/controllers/exports_controller.rb
index cb555a3dd..e8c140dd7 100644
--- a/app/controllers/exports_controller.rb
+++ b/app/controllers/exports_controller.rb
@@ -14,9 +14,16 @@ class ExportsController < ChouetteController
end
def create
- create! do |success, failure|
- available_exports
- success.html { flash[:notice] = I18n.t('exports.new.flash')+"<br/>"+I18n.t('exports.new.flash2'); redirect_to referential_exports_path(@referential) }
+ if (params[:export][:type] == "HubExport") && Chouette::VehicleJourneyAtStop.all.count > 50000
+ flash[:notice] = I18n.t("formtastic.titles.export.vjas.size", size: Chouette::VehicleJourneyAtStop.all.count)
+ redirect_to new_referential_export_path(@referential)
+ elsif (params[:export][:type] == "HubExport") && (params[:export][:start_date].empty? || params[:export][:end_date].empty?)
+ flash[:notice] = I18n.t("formtastic.titles.export.dates.not_nul")
+ redirect_to new_referential_export_path(@referential)
+ else
+ create! do |success, failure|
+ success.html { flash[:notice] = I18n.t('exports.new.flash')+"<br/>"+I18n.t('exports.new.flash2'); redirect_to referential_exports_path(@referential) }
+ end
end
end
diff --git a/app/exporters/chouette/hub/exporter.rb b/app/exporters/chouette/hub/exporter.rb
index 58454a0cb..27ac4e7ee 100644
--- a/app/exporters/chouette/hub/exporter.rb
+++ b/app/exporters/chouette/hub/exporter.rb
@@ -42,6 +42,10 @@ class Chouette::Hub::Exporter
end
end
+ def referential_exportable?
+ Chouette::VehicleJourneyAtStop.all.count < 50000
+ end
+
def time_tables_exportable?
time_tables
end
@@ -71,10 +75,12 @@ class Chouette::Hub::Exporter
def export(zip_file_path, options = {})
begin
referential.switch
+
+ if referential_exportable? && options[:start_date] && options[:end_date]
- FileUtils.rm(zip_file_path) if File.exists? zip_file_path
+ FileUtils.rm(zip_file_path) if File.exists? zip_file_path
- hub_export.log_messages.create( :severity => "ok", :key => "EXPORT", :arguments => {"0" => "HUB"})
+ hub_export.log_messages.create( :severity => "ok", :key => "EXPORT", :arguments => {"0" => "HUB"})
Dir.mktmpdir(nil, "/tmp"){ |temp_dir|
@@ -239,6 +245,7 @@ class Chouette::Hub::Exporter
end
end
}
+ end
ensure
# Always cleanup files
#FileUtils.remove_entry(temp_directory)
diff --git a/app/views/exports/_fields_hub_export.erb b/app/views/exports/_fields_hub_export.erb
index fc7cf7112..8f51c104b 100644
--- a/app/views/exports/_fields_hub_export.erb
+++ b/app/views/exports/_fields_hub_export.erb
@@ -1,2 +1,3 @@
+<%= I18n.t("formtastic.titles.export.vjas.size", size: Chouette::VehicleJourneyAtStop.all.count) if Chouette::VehicleJourneyAtStop.all.count > 50000 %>
<%= form.input :start_date, :as => :date_picker, :input_html => { :title => t("formtastic.titles.export.start_date")} %>
<%= form.input :end_date, :as => :date_picker, :input_html => { :title => t("formtastic.titles.export.end_date")} %>