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
---
app/controllers/stop_areas_controller.rb | 6 ++++++
app/views/stop_areas/index.html.erb | 3 ++-
2 files changed, 8 insertions(+), 1 deletion(-)
(limited to 'app')
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 %>
- - <%= link_to t('stop_areas.actions.new'), new_referential_stop_area_path(@referential), :class => "add" %>
+ - <%= link_to t('stop_areas.actions.new'), new_referential_stop_area_path(@referential), :class => "add" %>
+ - <%= link_to t('stop_areas.actions.default_geometry'), default_geometry_referential_stop_areas_path(@referential), :method => :put %>
<%= t(".selection") %>
--
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 +++++++
1 file changed, 7 insertions(+)
(limited to 'app')
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)
--
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 +++---
2 files changed, 15 insertions(+), 3 deletions(-)
(limited to 'app')
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 %>
--
cgit v1.2.3