From 0a44390146ef87422fe2213158a7abcba0253ed1 Mon Sep 17 00:00:00 2001 From: Alban Peignier Date: Wed, 11 Jul 2012 12:01:27 +0200 Subject: Add a StopAreaController#default_geometry to compute missing geometries. Fixes #47 --- Gemfile.lock | 2 +- app/controllers/stop_areas_controller.rb | 6 ++++++ app/views/stop_areas/index.html.erb | 3 ++- config/locales/stop_areas.yml | 4 ++++ config/routes.rb | 3 +++ 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index fe315519f..d2c22f5d4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: git://chouette.dryade.priv/ninoxe - revision: cebb174290257773b95eb663cdcb107dccf1fca6 + revision: f75aaa8ba65bc798d663a2d8b9b4c2bd45986fce specs: ninoxe (0.0.8) GeoRuby diff --git a/app/controllers/stop_areas_controller.rb b/app/controllers/stop_areas_controller.rb index 8d55a49d5..4f8aec734 100644 --- a/app/controllers/stop_areas_controller.rb +++ b/app/controllers/stop_areas_controller.rb @@ -58,6 +58,12 @@ class StopAreasController < ChouetteController edit! end + def default_geometry + count = referential.stop_areas.without_geometry.default_geometry! + flash[:notice] = I18n.translate("stop_areas.default_geometry_success", :count => count) + redirect_to referential_stop_areas_path(@referential) + end + protected alias_method :stop_area, :resource diff --git a/app/views/stop_areas/index.html.erb b/app/views/stop_areas/index.html.erb index 0d2a925cc..a8a12ee52 100644 --- a/app/views/stop_areas/index.html.erb +++ b/app/views/stop_areas/index.html.erb @@ -24,7 +24,8 @@ <% content_for :sidebar do %>

<%= t(".selection") %>

diff --git a/config/locales/stop_areas.yml b/config/locales/stop_areas.yml index 2aeb158db..2d920435d 100644 --- a/config/locales/stop_areas.yml +++ b/config/locales/stop_areas.yml @@ -1,5 +1,6 @@ en: stop_areas: + default_geometry_success: "%{count} modified stop areas" stop_area: no_position: No Position lines: "Lines :" @@ -12,6 +13,7 @@ en: add_children: Manage Children add_routing_lines: "Manage constraint's lines" add_routing_stops: "Manage constraint's stops" + default_geometry: "Compute missing geometries" new: title: Add a new stop edit: @@ -74,6 +76,7 @@ en: fr: stop_areas: + default_geometry_success: "%{count} arrêts modifiés" stop_area: no_position: Pas de position lines: "Lignes :" @@ -86,6 +89,7 @@ fr: add_children: Gérer les fils add_routing_lines: "Gérer les lignes de l'ITL" add_routing_stops: "Gérer les arrêts de l'ITL" + default_geometry: "Calculer les géométries manquantes" new: title: Ajouter un arrêt edit: diff --git a/config/routes.rb b/config/routes.rb index a5bc53230..de74fa522 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -66,6 +66,9 @@ ChouetteIhm::Application.routes.draw do get 'add_routing_lines' get 'add_routing_stops' end + collection do + put 'default_geometry' + end end resources :connection_links do -- cgit v1.2.3 From a9fb2e2926723dd50c8a0e51843edfd0154bf45d Mon Sep 17 00:00:00 2001 From: Alban Peignier Date: Wed, 11 Jul 2012 15:02:22 +0200 Subject: Enable threaded mode in production. Refs #91 --- config/environments/production.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index b3e0c7ce0..d6433e201 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -53,7 +53,8 @@ ChouetteIhm::Application.configure do # config.action_mailer.raise_delivery_errors = false # Enable threaded mode - # config.threadsafe! + # NOTICE : With Rails 3.2, Delayed::JRubyWorker blocks the application without threaded mode + config.threadsafe! # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation can not be found) -- cgit v1.2.3 From 725f83bb5d68d3d8f77d6dd8e4a1b4fbf535e10f Mon Sep 17 00:00:00 2001 From: Alban Peignier Date: Wed, 11 Jul 2012 15:09:36 +0200 Subject: Use Time.zone as default in Referential. Fixes #53 --- app/models/referential.rb | 7 +++++++ config/application.rb | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/models/referential.rb b/app/models/referential.rb index 35d4e9141..4a9fc33aa 100644 --- a/app/models/referential.rb +++ b/app/models/referential.rb @@ -1,4 +1,5 @@ class Referential < ActiveRecord::Base + validates_presence_of :name validates_presence_of :slug validates_presence_of :prefix @@ -39,6 +40,12 @@ class Referential < ActiveRecord::Base Chouette::ConnectionLink.scoped end + after_initialize :define_default_attributes + + def define_default_attributes + self.time_zone ||= Time.zone.name + end + def switch raise "Referential not created" if new_record? Apartment::Database.switch(slug) diff --git a/config/application.rb b/config/application.rb index a5efb4799..837542855 100644 --- a/config/application.rb +++ b/config/application.rb @@ -32,7 +32,7 @@ module ChouetteIhm # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. - # config.time_zone = 'Central Time (US & Canada)' + config.time_zone = "Paris" # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] -- cgit v1.2.3 From b26ece76b66cca7d773d2a906dba67907398a329 Mon Sep 17 00:00:00 2001 From: Alban Peignier Date: Wed, 11 Jul 2012 16:16:03 +0200 Subject: Display a collection of SRIDs to create a Referential. Fixes #54 --- app/models/referential.rb | 12 ++++++++++++ app/views/referentials/_form.erb | 6 +++--- config/locales/referentials.yml | 2 -- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/models/referential.rb b/app/models/referential.rb index 4a9fc33aa..9ab9b332f 100644 --- a/app/models/referential.rb +++ b/app/models/referential.rb @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- class Referential < ActiveRecord::Base validates_presence_of :name @@ -52,6 +53,17 @@ class Referential < ActiveRecord::Base self end + def self.available_srids + [ + [ "NTF Lambert Zone 1 (27561)", 27561 ], + [ "NTF Lambert Zone 2 (27562)", 27562 ], + [ "NTF Lambert Zone 3 (27563)", 27563 ], + [ "NTF Lambert Zone 4 (27564)", 27564 ], + [ "NTF Lambert 2 étendu (27572)", 27582 ], + ["RGF 93 Lambert 93 (2154)", 2154 ] + ] + end + before_create :create_schema before_destroy :destroy_schema diff --git a/app/views/referentials/_form.erb b/app/views/referentials/_form.erb index d794d828c..f9beb480e 100644 --- a/app/views/referentials/_form.erb +++ b/app/views/referentials/_form.erb @@ -9,9 +9,9 @@ <%= @referential.slug %> <% end %> - <%= form.input :prefix%> - <%= form.input :projection_type%> - <%= form.input :time_zone%> + <%= form.input :prefix %> + <%= form.input :projection_type, :as => :select, :collection => Referential.available_srids %> + <%= form.input :time_zone %> <% if @referential.new_record? %> <%= form.input :resources, :as => :file %> diff --git a/config/locales/referentials.yml b/config/locales/referentials.yml index da0eda2d1..c5f4cdbd9 100644 --- a/config/locales/referentials.yml +++ b/config/locales/referentials.yml @@ -45,7 +45,6 @@ en: referential: slug: only lowercase alphanumerical or underscore characters prefix: only alphanumerical or underscore characters - projection_type: "see SRID codes on http://spatialreference.org" fr: referentials: @@ -94,4 +93,3 @@ fr: referential: slug: "caractères autorisés : alphanumériques minuscules et 'souligné'" prefix: "caractères autorisés : alphanumériques et 'souligné'" - projection_type: "voir http://spatialreference.org pour les codes SRID" -- cgit v1.2.3