diff options
| author | Michel Etienne | 2012-07-12 08:05:29 +0200 |
|---|---|---|
| committer | Michel Etienne | 2012-07-12 08:05:29 +0200 |
| commit | 5d5b68ca584111f37b5843cd69cfbbbd3dbda356 (patch) | |
| tree | 3386eb88e33031bc3ea6588d60abe0a28fa8798f | |
| parent | 150b79cff9c24cbaab8cfd87f3c640b4f5fdf51b (diff) | |
| parent | b26ece76b66cca7d773d2a906dba67907398a329 (diff) | |
| download | chouette-core-5d5b68ca584111f37b5843cd69cfbbbd3dbda356.tar.bz2 | |
Merge branch 'master' of chouette.dryade.priv:/srv/git/chouette2
| -rw-r--r-- | app/controllers/stop_areas_controller.rb | 6 | ||||
| -rw-r--r-- | app/models/referential.rb | 19 | ||||
| -rw-r--r-- | app/views/referentials/_form.erb | 6 | ||||
| -rw-r--r-- | app/views/stop_areas/index.html.erb | 3 | ||||
| -rw-r--r-- | config/application.rb | 2 | ||||
| -rw-r--r-- | config/environments/production.rb | 3 | ||||
| -rw-r--r-- | config/locales/referentials.yml | 2 | ||||
| -rw-r--r-- | config/locales/stop_areas.yml | 4 | ||||
| -rw-r--r-- | config/routes.rb | 3 |
9 files changed, 40 insertions, 8 deletions
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/models/referential.rb b/app/models/referential.rb index 782275813..dbe6e87a1 100644 --- a/app/models/referential.rb +++ b/app/models/referential.rb @@ -1,4 +1,6 @@ +# -*- coding: utf-8 -*- class Referential < ActiveRecord::Base + validates_presence_of :name validates_presence_of :slug validates_presence_of :prefix @@ -47,12 +49,29 @@ 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) 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 %> </li> <% 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/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 %> <ul class="actions"> - <li><%= link_to t('stop_areas.actions.new'), new_referential_stop_area_path(@referential), :class => "add" %></li> + <li><%= link_to t('stop_areas.actions.new'), new_referential_stop_area_path(@referential), :class => "add" %></li> + <li><%= link_to t('stop_areas.actions.default_geometry'), default_geometry_referential_stop_areas_path(@referential), :method => :put %></li> </ul> <h3><%= t(".selection") %></h3> 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] 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) 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" 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 3b2dd80de..2d2b7ba81 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 |
