From cb0b8c487c1530f3fe090fc89aedd0bbc8ef21d2 Mon Sep 17 00:00:00 2001 From: Juan Antonio Zea Herranz Date: Sat, 21 Apr 2012 15:57:03 +0200 Subject: [PATCH 1/5] Localizacion: migracion y formularios --- app/views/sites/_form.html.erb | 37 +++++++++++++++++++ .../20120421132559_localizacion_sitios.rb | 17 +++++++++ db/schema.rb | 13 ++++++- 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20120421132559_localizacion_sitios.rb diff --git a/app/views/sites/_form.html.erb b/app/views/sites/_form.html.erb index f1fd754..379502d 100644 --- a/app/views/sites/_form.html.erb +++ b/app/views/sites/_form.html.erb @@ -11,6 +11,31 @@ <% end %> + + + +
<%= f.label :name %>
<%= f.text_field :name %> @@ -27,6 +52,18 @@ <%= f.label :image %>
<%= f.file_field :image %>
+
+ <%= f.label :lat %>
+ <%= f.text_area :lat , :rows => 1 %> +
+
+ <%= f.label :long %>
+ <%= f.text_area :long , :rows => 1 %> +
+
+ <%= f.label :zoom %>
+ <%= f.text_area :zoom , :rows => 1 %> +
<%= f.submit %>
diff --git a/db/migrate/20120421132559_localizacion_sitios.rb b/db/migrate/20120421132559_localizacion_sitios.rb new file mode 100644 index 0000000..0e14235 --- /dev/null +++ b/db/migrate/20120421132559_localizacion_sitios.rb @@ -0,0 +1,17 @@ +class LocalizacionSitios < ActiveRecord::Migration + def up + change_table :sites do |t| + t.column :lat, :integer + t.column :long, :integer + t.column :zoom, :integer + end + end + + def down + change_table :sites do |t| + t.column :lat, :integer + t.column :long, :integer + t.column :zoom, :integer + end + end +end diff --git a/db/schema.rb b/db/schema.rb index e6aa66f..12dcc44 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,15 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20120411160519) do +ActiveRecord::Schema.define(:version => 20120421132559) do + + create_table "comments", :force => true do |t| + t.string "comment" + t.integer "user_id" + t.integer "site_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end create_table "sites", :force => true do |t| t.string "name" @@ -26,6 +34,9 @@ t.string "image_file_size" t.datetime "image_updated_at" t.integer "visitas", :default => 0 + t.integer "lat" + t.integer "long" + t.integer "zoom" end create_table "trips", :force => true do |t| From 5d747c9977a05e88b11d59227098a0747a588f53 Mon Sep 17 00:00:00 2001 From: Juan Antonio Zea Herranz Date: Sat, 21 Apr 2012 19:12:59 +0200 Subject: [PATCH 2/5] Correccion integer-float y mapa en show --- app/views/sites/show.html.erb | 32 +++++++++++++++++++ db/migrate/20120421170806_sitios_lat_float.rb | 10 ++++++ db/schema.rb | 8 ++--- 3 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 db/migrate/20120421170806_sitios_lat_float.rb diff --git a/app/views/sites/show.html.erb b/app/views/sites/show.html.erb index 01a5417..bc81edb 100644 --- a/app/views/sites/show.html.erb +++ b/app/views/sites/show.html.erb @@ -1,3 +1,7 @@ + +

<%= @site.type.name if @site.type %>

@@ -15,5 +19,33 @@ Visitas: <%= @site.visitas %>
+
+ + + + +

<% if @site.user == current_user %> <%= link_to 'Edit', edit_site_path(@site) %> | <% end %> <%= link_to 'Back', sites_path %> diff --git a/db/migrate/20120421170806_sitios_lat_float.rb b/db/migrate/20120421170806_sitios_lat_float.rb new file mode 100644 index 0000000..0f18f75 --- /dev/null +++ b/db/migrate/20120421170806_sitios_lat_float.rb @@ -0,0 +1,10 @@ +class SitiosLatFloat < ActiveRecord::Migration + def up + change_column :sites, :lat, :float + change_column :sites, :long, :float + change_column :sites, :zoom, :float + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 12dcc44..de42b4b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20120421132559) do +ActiveRecord::Schema.define(:version => 20120421170806) do create_table "comments", :force => true do |t| t.string "comment" @@ -34,9 +34,9 @@ t.string "image_file_size" t.datetime "image_updated_at" t.integer "visitas", :default => 0 - t.integer "lat" - t.integer "long" - t.integer "zoom" + t.float "lat" + t.float "long" + t.float "zoom" end create_table "trips", :force => true do |t| From 83be45678b534c19683597fc1d9007b928e1299c Mon Sep 17 00:00:00 2001 From: Juan Antonio Zea Herranz Date: Sat, 21 Apr 2012 19:12:59 +0200 Subject: [PATCH 3/5] Correccion integer-float y mapa en show --- app/views/sites/show.html.erb | 32 +++++++++++++++++++ db/migrate/20120421170806_sitios_lat_float.rb | 10 ++++++ db/schema.rb | 8 ++--- 3 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 db/migrate/20120421170806_sitios_lat_float.rb diff --git a/app/views/sites/show.html.erb b/app/views/sites/show.html.erb index 01a5417..bc81edb 100644 --- a/app/views/sites/show.html.erb +++ b/app/views/sites/show.html.erb @@ -1,3 +1,7 @@ + +

<%= @site.type.name if @site.type %>

@@ -15,5 +19,33 @@ Visitas: <%= @site.visitas %>
+
+ + + + +

<% if @site.user == current_user %> <%= link_to 'Edit', edit_site_path(@site) %> | <% end %> <%= link_to 'Back', sites_path %> diff --git a/db/migrate/20120421170806_sitios_lat_float.rb b/db/migrate/20120421170806_sitios_lat_float.rb new file mode 100644 index 0000000..0f18f75 --- /dev/null +++ b/db/migrate/20120421170806_sitios_lat_float.rb @@ -0,0 +1,10 @@ +class SitiosLatFloat < ActiveRecord::Migration + def up + change_column :sites, :lat, :float + change_column :sites, :long, :float + change_column :sites, :zoom, :float + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 12dcc44..de42b4b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20120421132559) do +ActiveRecord::Schema.define(:version => 20120421170806) do create_table "comments", :force => true do |t| t.string "comment" @@ -34,9 +34,9 @@ t.string "image_file_size" t.datetime "image_updated_at" t.integer "visitas", :default => 0 - t.integer "lat" - t.integer "long" - t.integer "zoom" + t.float "lat" + t.float "long" + t.float "zoom" end create_table "trips", :force => true do |t| From 945e76c8afb657cf467660e2a5abd0fdb086d871 Mon Sep 17 00:00:00 2001 From: Juan Antonio Zea Herranz Date: Sun, 22 Apr 2012 14:16:53 +0200 Subject: [PATCH 4/5] Visitas en el mapa --- app/views/sites/show.html.erb | 8 +++---- app/views/trips/_trip.html.erb | 42 ++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/app/views/sites/show.html.erb b/app/views/sites/show.html.erb index bc81edb..570991c 100644 --- a/app/views/sites/show.html.erb +++ b/app/views/sites/show.html.erb @@ -1,5 +1,5 @@

@@ -8,6 +8,8 @@ <%= image_tag(@site.image.url, :class => 'site_image') %> +
+

<%= @site.name %>

<%=sanitize @site.description %>

@@ -19,8 +21,6 @@ Visitas: <%= @site.visitas %>
-
- diff --git a/app/views/trips/_trip.html.erb b/app/views/trips/_trip.html.erb index 2d69c99..ca6cd9d 100644 --- a/app/views/trips/_trip.html.erb +++ b/app/views/trips/_trip.html.erb @@ -1,4 +1,9 @@ + +
+
<% trip.visits.order(:hour).each do |visit| %> @@ -25,5 +30,42 @@ <% end %>
+
+ + + + From eb43505fdec7e72667c51ee1f59501d18b02a6c6 Mon Sep 17 00:00:00 2001 From: Juan Antonio Zea Herranz Date: Sun, 22 Apr 2012 15:15:32 +0200 Subject: [PATCH 5/5] Numero visitas:index y show --- app/views/sites/index.html.erb | 3 ++- app/views/sites/show.html.erb | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/views/sites/index.html.erb b/app/views/sites/index.html.erb index b8e4cae..e45b2e7 100644 --- a/app/views/sites/index.html.erb +++ b/app/views/sites/index.html.erb @@ -14,6 +14,7 @@
<%= link_to site.name, site %>
<%= truncate(strip_tags(site.description), :length => 80) %>
+

Incluido en <%= site.visits.count %> visitas

@@ -31,4 +32,4 @@
-<%= link_to 'New site', new_site_path %> \ No newline at end of file +<%= link_to 'New site', new_site_path %> diff --git a/app/views/sites/show.html.erb b/app/views/sites/show.html.erb index 570991c..6e27fde 100644 --- a/app/views/sites/show.html.erb +++ b/app/views/sites/show.html.erb @@ -15,6 +15,8 @@

<%=sanitize @site.description %>

Autor: <%= @site.user.name if @site.user %>

+ +

Incluido en <%= @site.visits.count %> visitas