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 /app | |
| parent | 150b79cff9c24cbaab8cfd87f3c640b4f5fdf51b (diff) | |
| parent | b26ece76b66cca7d773d2a906dba67907398a329 (diff) | |
| download | chouette-core-5d5b68ca584111f37b5843cd69cfbbbd3dbda356.tar.bz2 | |
Merge branch 'master' of chouette.dryade.priv:/srv/git/chouette2
Diffstat (limited to 'app')
| -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 |
4 files changed, 30 insertions, 4 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> |
