diff --git a/Gemfile.lock b/Gemfile.lock index fd905dc..37f7d8a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -60,7 +60,7 @@ GEM mime-types (~> 1.16) treetop (~> 1.4.8) mime-types (1.18) - multi_json (1.3.1) + multi_json (1.3.2) orm_adapter (0.0.7) paperclip (3.0.2) activemodel (>= 3.0.0) @@ -104,7 +104,7 @@ GEM hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sqlite3 (1.3.5) + sqlite3 (1.3.6) thor (0.14.6) tilt (1.3.3) treetop (1.4.10) diff --git a/app/assets/images/almudena.jpg b/app/assets/images/almudena.jpg new file mode 100644 index 0000000..d2e04ec Binary files /dev/null and b/app/assets/images/almudena.jpg differ diff --git a/app/assets/images/carlos.jpg b/app/assets/images/carlos.jpg new file mode 100644 index 0000000..a2a154f Binary files /dev/null and b/app/assets/images/carlos.jpg differ diff --git a/app/assets/images/debod.jpg b/app/assets/images/debod.jpg new file mode 100644 index 0000000..2ab9aa6 Binary files /dev/null and b/app/assets/images/debod.jpg differ diff --git a/app/assets/images/quique.jpg b/app/assets/images/quique.jpg new file mode 100644 index 0000000..e4292d6 Binary files /dev/null and b/app/assets/images/quique.jpg differ diff --git a/app/assets/images/retiro.jpg b/app/assets/images/retiro.jpg new file mode 100644 index 0000000..c02ee70 Binary files /dev/null and b/app/assets/images/retiro.jpg differ diff --git a/app/assets/javascripts/comments.js.coffee b/app/assets/javascripts/comments.js.coffee new file mode 100644 index 0000000..7615679 --- /dev/null +++ b/app/assets/javascripts/comments.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/stylesheets/comments.css.scss b/app/assets/stylesheets/comments.css.scss new file mode 100644 index 0000000..e730912 --- /dev/null +++ b/app/assets/stylesheets/comments.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Comments controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/planet.css b/app/assets/stylesheets/planet.css index ead053a..da31419 100644 --- a/app/assets/stylesheets/planet.css +++ b/app/assets/stylesheets/planet.css @@ -163,7 +163,31 @@ } + #main .visitas { text-indent: 70%; } - +#shortcuts a{ + color: #2c556e; + font-size: 1.3em; +} +#shortcuts a:visited{ + color: #306e2c; + font-size: 1.3em; +} +.user a:visited{ + color: black; +} +.user a{ + color: black; +} +#search{ + position:absolute; + right:0px; + width:300px; + color: black; + font-size: small; +} +#shortcuts{ + +} \ No newline at end of file diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e8065d9..462dac2 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,3 +1,7 @@ +# == Controlador de la aplicación +# Incluye la lógica de la aplicación +# +# Clase vacía class ApplicationController < ActionController::Base protect_from_forgery end diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb new file mode 100644 index 0000000..64c9382 --- /dev/null +++ b/app/controllers/comments_controller.rb @@ -0,0 +1,101 @@ +# == Controlador de Comments +# +# Incluye la lógica de la clase Comments + +class CommentsController < ApplicationController + + # authenticate_user! ejecuta acción solo si sesión existe + before_filter :authenticate_user!, :except => [ :index, :show ] + + # GET /coments + # GET /coments.json + def index + if params[:site_id].nil? or params[:site_id].empty? + @comments = Comment.all # path: /sites + else + @comments = Site.find(params[:site_id]).comments # path: /sites/id/comentarios + end + respond_to do |format| + format.html # index.html.erb + format.json { render json: @comments } + end + end + # POST /coments + # POST /coments.json + def create + @site = Site.find(params[:site_id]) + @comment = @site.comments.create(params[:comment]) + @comment.user_id = current_user.id + + respond_to do |format| + if @comment.save + format.html { redirect_to @site, notice: 'Comentario creado' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @comment.errors, status: :unprocessable_entity } + end + end + end + + # Nos permite crear un nuevo comentario + # GET /coments/new + # GET /coments/new.json + def new + @comment = Comment.new + + if !params[:site_id].nil? + @site = Site.find(params[:site_id]) + end + respond_to do |format| + format.html # new.html.erb + format.json { render json: @comment } + end + end + + + # DELETE /coments/1 + # DELETE /coments/1.json + def destroy + @site = Site.find(params[:site_id]) + @comment = @site.comments.find(params[:id]) + @comment.destroy + respond_to do |format| + format.html { redirect_to site_path(@site) } + format.json { head :no_content } + end + end + + # PUT /comments/1 + # PUT /comments/1.json + def update + @site = Site.find(params[:site_id]) + @comment = @site.comments.find(params[:id]) + + respond_to do |format| + if @comment.update_attributes(params[:comment]) + format.html { redirect_to @site, notice: 'Comentario actualizado' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @comment.errors, status: :unprocessable_entity } + end + end + end + # GET /coments/1/edit + def edit + @site = Site.find(params[:site_id]) + @comment = @site.comments.find(params[:id]) + end + + # GET /comentarios/1 + # GET /comentarios/1.json + def show + @comentario = Comment.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @comment } + end + end +end diff --git a/app/controllers/planet_controller.rb b/app/controllers/planet_controller.rb index a8636bd..625b352 100644 --- a/app/controllers/planet_controller.rb +++ b/app/controllers/planet_controller.rb @@ -1,33 +1,31 @@ -# PlanetController ilustra el uso de *RDoc*. La documentación de un proyecto en -# genera en el directorio *proy/doc* en formato Web con -# $proy> rake doc:app -# -# == Algunos comandos de formateo -# -# Tal y como muestra el subitulo anterior, este se define empezando la -# línea con ==. En los títulos debe empezar por =. -# -# Un [ ... ] seguido de texto define una lista titulada, como aquí -# [Clases, Módulos o Métodos] Se documentan con comentarios justo encima de sus definición, como aquí. -# -# Un * o - definen las entradas de una lista itemizada -# * Un URL se define así email[mailto:pepe@ejemplo.com] -# * o así {Pepe Rubio}[mailto:pepe@ejemplo.com] -# -# Un número o letra seguido de punto genera una lista númerada -# 1. + permite generar *negrita*, igual que con HTML -# 2. _ permite generar _cursiva_, igual que con HTML -# 3. * permite generar letra de +teletipo+, igual que con HTML +# == Controlador de Planet # +# Incluye la lógica de la clase Planet class PlanetController < ApplicationController - # Método que define una acción vacía del controlador + # Método para mostrar la página inicial def index end - # Método que define una acción vacía del controlador + # Método para contactar def contact end - # Método que define una acción vacía del controlador + # Método ejemplo def ejemplo end - + + def author + end + + def doc + #render 'doc.html', :layout =>false + redirect_to "/doc/app/index.html" + end + def search + if params[:q].length >= 3 + @search= params[:q] + @sites = Site.where("name like ? or description like ?", "%"+@search+"%", "%"+@search+"%") + @trips = Trip.where("name like ? or description like ?", "%"+@search+"%", "%"+@search+"%") + else + render action: "incorrectsearch" + end + end end diff --git a/app/controllers/sites_controller.rb b/app/controllers/sites_controller.rb index 57e0611..ff2da63 100644 --- a/app/controllers/sites_controller.rb +++ b/app/controllers/sites_controller.rb @@ -1,9 +1,13 @@ +# == Controlador de Sites +# +# Incluye la lógica de la clase Sites + class SitesController < ApplicationController # authenticate_user! ejecuta acción solo si sesión existe before_filter :authenticate_user!, :except => [ :index, :show ] - after_filter :count_visita, :only => :show - + after_filter :count_visita, :only => :show + # GET /sites # GET /sites.json def index @@ -22,6 +26,7 @@ def index # GET /sites/1.json def show @site = Site.find(params[:id]) + respond_to do |format| format.html # show.html.erb diff --git a/app/controllers/trips_controller.rb b/app/controllers/trips_controller.rb index 321f6e3..ea9d305 100644 --- a/app/controllers/trips_controller.rb +++ b/app/controllers/trips_controller.rb @@ -1,3 +1,7 @@ +# == Controlador de Trips +# +# Incluye la lógica de la clase Trips + class TripsController < ApplicationController # authenticate_user! ejecuta acción solo si sesión existe diff --git a/app/controllers/types_controller.rb b/app/controllers/types_controller.rb index da826f4..846bc57 100644 --- a/app/controllers/types_controller.rb +++ b/app/controllers/types_controller.rb @@ -1,3 +1,7 @@ +# == Controlador de Types +# +# Incluye la lógica de la clase Types + class TypesController < ApplicationController # GET /types # GET /types.json @@ -9,7 +13,16 @@ def index format.json { render json: @types } end end + # GET /types/ordered_index + # GET /types/ordered_index.json + def ordered_index + @types = Type.find(:all, :order => :name) + respond_to do |format| + format.html # index.html.erb + format.json { render json: @types } + end + end # GET /types/1 # GET /types/1.json def show @@ -80,4 +93,6 @@ def destroy format.json { head :no_content } end end + + end diff --git a/app/controllers/visits_controller.rb b/app/controllers/visits_controller.rb index 5bd5366..ecd76ca 100644 --- a/app/controllers/visits_controller.rb +++ b/app/controllers/visits_controller.rb @@ -1,3 +1,7 @@ +# == Controlador de Visits +# +# Incluye la lógica de la clase Visits + class VisitsController < ApplicationController # GET /visits # GET /visits.json diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be79..42e8f0d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,4 @@ +# == Helper de Application +# Se encarga de apoyar a la clase Application module ApplicationHelper end diff --git a/app/helpers/comments_helper.rb b/app/helpers/comments_helper.rb new file mode 100644 index 0000000..65de912 --- /dev/null +++ b/app/helpers/comments_helper.rb @@ -0,0 +1,4 @@ +# == Helper de Comments +# Se encarga de apoyar a la clase Comments +module CommentsHelper +end diff --git a/app/helpers/planet_helper.rb b/app/helpers/planet_helper.rb index 5bbc197..a4437c4 100644 --- a/app/helpers/planet_helper.rb +++ b/app/helpers/planet_helper.rb @@ -1,2 +1,4 @@ +# == Helper de Planet +# Se encarga de apoyar a la clase Planet module PlanetHelper end diff --git a/app/helpers/sites_helper.rb b/app/helpers/sites_helper.rb index 621069d..1b8a208 100644 --- a/app/helpers/sites_helper.rb +++ b/app/helpers/sites_helper.rb @@ -1,2 +1,5 @@ +# == Helper de Sites +# Se encarga de apoyar a la clase Sites + module SitesHelper end diff --git a/app/helpers/trips_helper.rb b/app/helpers/trips_helper.rb index 04f333d..a7be91f 100644 --- a/app/helpers/trips_helper.rb +++ b/app/helpers/trips_helper.rb @@ -1,2 +1,4 @@ +# == Helper de Trips +# Se encarga de apoyar a la clase Trips module TripsHelper end diff --git a/app/helpers/types_helper.rb b/app/helpers/types_helper.rb index 40a2b9e..775c75e 100644 --- a/app/helpers/types_helper.rb +++ b/app/helpers/types_helper.rb @@ -1,2 +1,5 @@ +# == Helper de Types +# Se encarga de apoyar a la clase Types + module TypesHelper end diff --git a/app/helpers/visits_helper.rb b/app/helpers/visits_helper.rb index 8ce5f83..fc4b3b4 100644 --- a/app/helpers/visits_helper.rb +++ b/app/helpers/visits_helper.rb @@ -1,2 +1,4 @@ +# == Helper de Visits +# Se encarga de apoyar a la clase Visits module VisitsHelper end diff --git a/app/models/comment.rb b/app/models/comment.rb new file mode 100644 index 0000000..070eaeb --- /dev/null +++ b/app/models/comment.rb @@ -0,0 +1,8 @@ +class Comment < ActiveRecord::Base + #Los comentarios son de los usuarios + belongs_to :user + #Y de los sitios + belongs_to :site + + validates :coment, :presence => true, :length => {:maximum => 240} +end diff --git a/app/models/site.rb b/app/models/site.rb index 2b2f99a..ba540a7 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -4,7 +4,9 @@ class Site < ActiveRecord::Base has_many :visits has_many :trips, :through => :visits has_attached_file :image - + #Tiene varios comentarios + has_many :comments,:dependent => :destroy + has_attached_file :image # Debe estar protegido para evitar accesos indeseados attr_protected :user_id diff --git a/app/models/user.rb b/app/models/user.rb index 35b8159..9890bc6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,6 +2,7 @@ class User < ActiveRecord::Base has_many :sites has_many :trips + has_many :comments, :dependent => :destroy # Include default devise modules. Others available are: # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb new file mode 100644 index 0000000..07b5f21 --- /dev/null +++ b/app/views/comments/_comment.html.erb @@ -0,0 +1,14 @@ +

+ + <%= comment.user.name if comment.user %> + <%= comment.coment %> +

+ +

+ <% if (comment.user == current_user) %> + <%= link_to 'Edit', edit_site_comment_path(@site, comment) %> + <%= link_to 'Destroy', [comment.site, comment], + :confirm => 'Are you sure?', + :method => :delete %> + <% end %> +

\ No newline at end of file diff --git a/app/views/comments/_edit.html.erb b/app/views/comments/_edit.html.erb new file mode 100644 index 0000000..10b677c --- /dev/null +++ b/app/views/comments/_edit.html.erb @@ -0,0 +1,8 @@ +<%= form_for([@site, @comment]) do |f| %> +
+ <%= f.text_area :coment %> +
+
+ <%= f.submit %> +
+<% end %> \ No newline at end of file diff --git a/app/views/comments/_form.html.erb b/app/views/comments/_form.html.erb new file mode 100644 index 0000000..ad00418 --- /dev/null +++ b/app/views/comments/_form.html.erb @@ -0,0 +1,9 @@ +<%= form_for([@site, @site.comments.build]) do |f| %> +
+ <%= f.text_area :coment %> +
+ +
+ <%= f.submit %> +
+<% end %> \ No newline at end of file diff --git a/app/views/comments/edit.html.erb b/app/views/comments/edit.html.erb new file mode 100644 index 0000000..10b677c --- /dev/null +++ b/app/views/comments/edit.html.erb @@ -0,0 +1,8 @@ +<%= form_for([@site, @comment]) do |f| %> +
+ <%= f.text_area :coment %> +
+
+ <%= f.submit %> +
+<% end %> \ No newline at end of file diff --git a/app/views/comments/index.html.erb b/app/views/comments/index.html.erb new file mode 100644 index 0000000..af3e8b5 --- /dev/null +++ b/app/views/comments/index.html.erb @@ -0,0 +1,37 @@ +
+

Listing comments

+ + + + + + + + + + +<% @comments.each do |comment| %> + + + + + + + + <% end %> + + + +<% end %> +
CommentUser
+
<%= truncate(strip_tags(comment.coment), + :length => 240) %>
+
+ + <% if comment.user ==current_user %> + <%= link_to 'Edit', site_comment_path(@site) %><%= link_to 'Destroy', @site.comment, confirm: 'Are you sure?', method: :delete %>
+
+ +
+ +<%= link_to 'Nuevo comment', new_site_comment_path %> \ No newline at end of file diff --git a/app/views/comments/new.html.erb b/app/views/comments/new.html.erb new file mode 100644 index 0000000..7d0faca --- /dev/null +++ b/app/views/comments/new.html.erb @@ -0,0 +1,5 @@ +

New comentario

+ +<%= render 'form' %> + +<%= link_to 'Back', comments_path %> \ No newline at end of file diff --git a/app/views/comments/show.html.erb b/app/views/comments/show.html.erb new file mode 100644 index 0000000..8ce6543 --- /dev/null +++ b/app/views/comments/show.html.erb @@ -0,0 +1,14 @@ +

+ + <%= comment.user.name if comment.user %> + <%= comment.coment %> +

+ +

+ <% if (comment.user == current_user) %> + <%= link_to 'Edit', edit_site_comment_path(@site, comment) %> + <%= link_to 'Destroy', [comment.site, comment], + :confirm => 'Are you sure?', + :method => :delete %> + <% end %> +

\ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index e4c9e36..248e3e7 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -6,7 +6,11 @@ <%= javascript_include_tag "application" %> <%= csrf_meta_tags %> - + @@ -14,21 +18,67 @@
Visitas: <%= @site.visitas %>
+
+ Veces incluido en un viaje: <%= @site.visits.length %> +
+ + +<% if @site.user == current_user %> + <%= link_to 'Edit', edit_site_path(@site) %> | +<% end %> +<%= link_to 'Back', sites_path %> +
+ <%= render "geolocalizacion"%> +
+ +

Commentarios:

+<%= render @site.comments %> -

-<% if @site.user == current_user %> <%= link_to 'Edit', edit_site_path(@site) %> | <% end %> <%= link_to 'Back', sites_path %> +

Añadir comentario:

+<%= render "comments/form" %> diff --git a/app/views/trips/_geoTrips.html.erb b/app/views/trips/_geoTrips.html.erb new file mode 100644 index 0000000..dd2636e --- /dev/null +++ b/app/views/trips/_geoTrips.html.erb @@ -0,0 +1,50 @@ + + + + + + + +
\ No newline at end of file diff --git a/app/views/trips/_triplist.html.erb b/app/views/trips/_triplist.html.erb new file mode 100644 index 0000000..451e6fe --- /dev/null +++ b/app/views/trips/_triplist.html.erb @@ -0,0 +1,29 @@ + +
+

Viajes

+ + + <% @trips.each do |trip| %> + + + + + + + <% end %> +
+
+
<%= link_to trip.name, trip_path(trip) %>
+
<%= truncate(strip_tags(trip.description), + :length => 80) + ', ' + trip.date.to_s %>
+
+
+ <%= link_to 'Show', trip %>
+ <% if trip.user == current_user %> + <%= link_to 'Edit', edit_trip_path(trip) %>
+ <%= link_to 'Destroy', trip, + :confirm => 'Are you sure?', + :method => :delete %> + <% end %> +
+

\ No newline at end of file diff --git a/app/views/trips/index.html.erb b/app/views/trips/index.html.erb index ec66e06..4e8d4b1 100644 --- a/app/views/trips/index.html.erb +++ b/app/views/trips/index.html.erb @@ -1 +1 @@ -

Viajes

<% @trips.each do |trip| %> <% end %>
<%= link_to trip.name, trip_path(trip) %>
<%= truncate(strip_tags(trip.description), :length => 80) + ', ' + trip.date.to_s %>
<%= link_to 'Show', trip %>
<% if trip.user == current_user %> <%= link_to 'Edit', edit_trip_path(trip) %>
<%= link_to 'Destroy', trip, :confirm => 'Are you sure?', :method => :delete %> <% end %>

<%= link_to 'New Trip', new_trip_path %> \ No newline at end of file +<%=render 'triplist' %> <%= link_to 'New Trip', new_trip_path %> \ No newline at end of file diff --git a/app/views/trips/show.html.erb b/app/views/trips/show.html.erb index 8bced6a..e2abc1d 100644 --- a/app/views/trips/show.html.erb +++ b/app/views/trips/show.html.erb @@ -1,14 +1,38 @@ -

Name: <%= @trip.name %>

Date: <%= @trip.date %>

- Autor: <%= @trip.user.name if @trip.user %> -

-

Description: <%= simple_format @trip.description %>

+

+ Name: + <%= @trip.name %> +

+ +

+ Date: + <%= @trip.date %> +

+ +

+ Autor: + <%= @trip.user.name if @trip.user %> +

+ +

+ Description: + <%= simple_format @trip.description %> +

+

Sitios a visitar

<%= render(@trip) %> - <% if @trip.user == current_user %> +
+ <%=render "geoTrips" %> +
+ + +
+ + + <% if @trip.user == current_user %> <%= form_for(@visit, :remote => true) do |f| %> <%= f.number_field :trip_id, :value => @trip.id, :hidden => true %> @@ -24,5 +48,7 @@
- <% if @trip.user == current_user %> <%= link_to 'Edit', edit_trip_path(@trip) %> | <% end %> <%= link_to 'Back', trips_path %> - \ No newline at end of file +<% if @trip.user == current_user %> + <%= link_to 'Edit', edit_trip_path(@trip) %> | +<% end %> +<%= link_to 'Back', trips_path %> diff --git a/app/views/types/index.html.erb b/app/views/types/index.html.erb index e761359..10293ec 100644 --- a/app/views/types/index.html.erb +++ b/app/views/types/index.html.erb @@ -3,6 +3,7 @@ <% @types.each do |type| %> + @@ -28,3 +30,4 @@
<%= link_to 'New Type', new_type_path %> + diff --git a/app/views/types/ordered_index.html.erb b/app/views/types/ordered_index.html.erb new file mode 100644 index 0000000..7fbb37d --- /dev/null +++ b/app/views/types/ordered_index.html.erb @@ -0,0 +1,41 @@ +
+ +

Listing Types

+ +
@@ -10,6 +11,7 @@
<%= link_to type.name, type_sites_path(type) %>
<%= truncate(strip_tags(type.description), :length => 80) %>
+
Última modificación: <%=type.updated_at%>
+ + <% @types.each do |type| %> + + + + + + + + + + <% end %> + +
+
+ +
<%= link_to type.name, type_sites_path(type) %>
+
<%= truncate(strip_tags(type.description), + :length => 80) %> +
Última modificación: <%= type.updated_at %>
+ +
+
+ <%= link_to 'Show', type %>
+ <%= link_to 'Edit', edit_type_path(type) %>
+ <%= link_to 'Destroy', type, + :confirm => 'Are you sure?', + :method => :delete %>
+ +
+ +
+ +
+ +<%= link_to 'New Type', new_type_path %> \ No newline at end of file diff --git a/app/views/types/show.html.erb b/app/views/types/show.html.erb index 98b32e7..811d453 100644 --- a/app/views/types/show.html.erb +++ b/app/views/types/show.html.erb @@ -10,6 +10,10 @@ <%= @type.description %>

+

+ Última modificación: + <%= @type.updated_at %> +

<%= link_to 'Edit', edit_type_path(@type) %> | <%= link_to 'Back', types_path %> diff --git a/config/routes.rb b/config/routes.rb index 29d3c86..a3e0389 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,14 +1,23 @@ Planet::Application.routes.draw do + resources :comments + resources :visits resources :trips + + devise_for :users - resources :sites + resources :sites do + resources :comments + end + + get "types/ordered_index" resources :types do # Rutas anidadas /types/id/sites..., + resources :sites, :only => [ :index ] # Restringe a acción “index” end @@ -18,6 +27,17 @@ get "planet/ejemplo" + get "planet/author" + + get "planet/doc" + #match "planet/doc" => redirect("/app/views/planet/doc") + + + get "planet/search" + + post "planet/search" + + # The priority is based upon order of creation: # first created -> highest priority. diff --git a/db/migrate/20120415210334_create_comments.rb b/db/migrate/20120415210334_create_comments.rb new file mode 100644 index 0000000..b2c7aee --- /dev/null +++ b/db/migrate/20120415210334_create_comments.rb @@ -0,0 +1,11 @@ +class CreateComments < ActiveRecord::Migration + def change + create_table :comments do |t| + t.string :coment + t.integer :user_id + t.integer :site_id + + t.timestamps + end + end +end diff --git a/db/migrate/20120422032309_geo.rb b/db/migrate/20120422032309_geo.rb new file mode 100644 index 0000000..63fc417 --- /dev/null +++ b/db/migrate/20120422032309_geo.rb @@ -0,0 +1,10 @@ +class Geo < ActiveRecord::Migration + def up + add_column :sites, :latitud, :float + add_column :sites, :longitud, :float + add_column :sites, :zoom, :integer + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index e6aa66f..b10b793 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 => 20120422032309) do + + create_table "comments", :force => true do |t| + t.string "coment" + 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.float "latitud" + t.float "longitud" + t.integer "zoom" end create_table "trips", :force => true do |t| diff --git a/db/structure.sql b/db/structure.sql new file mode 100644 index 0000000..4e42ae2 --- /dev/null +++ b/db/structure.sql @@ -0,0 +1,31 @@ +CREATE TABLE "comments" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "coment" varchar(255), "user_id" integer, "site_id" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); +CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL); +CREATE TABLE "sites" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "description" text, "type_id" integer, "image_url" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "user_id" integer, "image_file_name" varchar(255), "image_content_type" varchar(255), "image_file_size" varchar(255), "image_updated_at" datetime, "visitas" integer DEFAULT 0, "latitud" float, "longitud" float, "zoom" integer); +CREATE TABLE "trips" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "description" text, "date" date, "user_id" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); +CREATE TABLE "types" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "description" text, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); +CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "email" varchar(255) DEFAULT '' NOT NULL, "encrypted_password" varchar(255) DEFAULT '' NOT NULL, "reset_password_token" varchar(255), "reset_password_sent_at" datetime, "remember_created_at" datetime, "sign_in_count" integer DEFAULT 0, "current_sign_in_at" datetime, "last_sign_in_at" datetime, "current_sign_in_ip" varchar(255), "last_sign_in_ip" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "name" varchar(255)); +CREATE TABLE "visits" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "trip_id" integer, "site_id" integer, "hour" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); +CREATE UNIQUE INDEX "index_users_on_email" ON "users" ("email"); +CREATE UNIQUE INDEX "index_users_on_reset_password_token" ON "users" ("reset_password_token"); +CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version"); +INSERT INTO schema_migrations (version) VALUES ('20120317231537'); + +INSERT INTO schema_migrations (version) VALUES ('20120320100145'); + +INSERT INTO schema_migrations (version) VALUES ('20120328230302'); + +INSERT INTO schema_migrations (version) VALUES ('20120329060322'); + +INSERT INTO schema_migrations (version) VALUES ('20120329080433'); + +INSERT INTO schema_migrations (version) VALUES ('20120409085740'); + +INSERT INTO schema_migrations (version) VALUES ('20120409143117'); + +INSERT INTO schema_migrations (version) VALUES ('20120411095828'); + +INSERT INTO schema_migrations (version) VALUES ('20120411160519'); + +INSERT INTO schema_migrations (version) VALUES ('20120415210334'); + +INSERT INTO schema_migrations (version) VALUES ('20120422032309'); \ No newline at end of file diff --git a/doc.html b/doc.html new file mode 120000 index 0000000..930501a --- /dev/null +++ b/doc.html @@ -0,0 +1 @@ +/Users/carloscrespog/Documents/SWCM/planet2012/doc/app/index.html \ No newline at end of file diff --git a/doc/app/ApplicationController.html b/doc/app/ApplicationController.html index 65ef712..ca1ace0 100644 --- a/doc/app/ApplicationController.html +++ b/doc/app/ApplicationController.html @@ -87,6 +87,12 @@

Class and Module Index

  • ApplicationHelper +
  • Comment + +
  • CommentsController + +
  • CommentsHelper +
  • PlanetController
  • PlanetHelper @@ -128,6 +134,12 @@

    class ApplicationController

    +

    Controlador de la aplicación

    + +

    Incluye la lógica de la aplicación

    + +

    Clase vacía

    +
    diff --git a/doc/app/ApplicationHelper.html b/doc/app/ApplicationHelper.html index efcf78f..33016c7 100644 --- a/doc/app/ApplicationHelper.html +++ b/doc/app/ApplicationHelper.html @@ -81,6 +81,12 @@

    Class and Module Index

  • ApplicationHelper +
  • Comment + +
  • CommentsController + +
  • CommentsHelper +
  • PlanetController
  • PlanetHelper @@ -122,6 +128,10 @@

    module ApplicationHelper

    +

    Helper de Application

    + +

    Se encarga de apoyar a la clase Application

    +
    diff --git a/doc/app/Comment.html b/doc/app/Comment.html new file mode 100644 index 0000000..f2d1e40 --- /dev/null +++ b/doc/app/Comment.html @@ -0,0 +1,163 @@ + + + + + + +class Comment - Rails Application Documentation + + + + + + + + + + + + + + + + +
    +

    class Comment

    + +
    + +
    + + + + +
    + + + + + + + + + + +
    + +
    + + + + diff --git a/doc/app/CommentsController.html b/doc/app/CommentsController.html new file mode 100644 index 0000000..cc7a430 --- /dev/null +++ b/doc/app/CommentsController.html @@ -0,0 +1,457 @@ + + + + + + +class CommentsController - Rails Application Documentation + + + + + + + + + + + + + + + + +
    +

    class CommentsController

    + +
    + +

    Controlador de Comments

    + +

    Incluye la lógica de la clase Comments

    + +
    + + + + +
    + + + + + + + + + + +
    +

    Public Instance Methods

    + + +
    + +
    + create() + click to toggle source +
    + + +
    + +

    POST /coments POST /coments.json

    + + + +
    +
    # File app/controllers/comments_controller.rb, line 25
    +def create
    +              @site = Site.find(params[:site_id])
    +              @comment = @site.comments.create(params[:comment])
    +              @comment.user_id = current_user.id
    +              
    +              respond_to do |format|
    +              if @comment.save
    +              format.html { redirect_to @site, notice: 'Comentario creado' }
    +              format.json { head :no_content }
    +      else
    +              format.html { render action: "edit" }
    +              format.json { render json: @comment.errors, status: :unprocessable_entity }
    +      end
    +      end
    +end
    +
    + +
    + + + + +
    + + +
    + +
    + destroy() + click to toggle source +
    + + +
    + +

    DELETE /coments/1 DELETE /coments/1.json

    + + + +
    +
    # File app/controllers/comments_controller.rb, line 59
    +def destroy
    +  @site = Site.find(params[:site_id])
    +  @comment = @site.comments.find(params[:id])
    +  @comment.destroy
    +  respond_to do |format|
    +    format.html { redirect_to site_path(@site) }
    +    format.json { head :no_content }
    +  end
    +end
    +
    + +
    + + + + +
    + + +
    + +
    + edit() + click to toggle source +
    + + +
    + +

    GET /coments/1/edit

    + + + +
    +
    # File app/controllers/comments_controller.rb, line 86
    +def edit
    +      @site = Site.find(params[:site_id])
    +      @comment = @site.comments.find(params[:id])
    +end
    +
    + +
    + + + + +
    + + +
    + +
    + index() + click to toggle source +
    + + +
    + +

    GET /coments GET /coments.json

    + + + +
    +
    # File app/controllers/comments_controller.rb, line 12
    +def index
    +      if params[:site_id].nil? or params[:site_id].empty?
    +    @comments = Comment.all            # path: /sites
    +    else
    +    @comments = Site.find(params[:site_id]).comments  # path: /sites/id/comentarios
    +  end
    +  respond_to do |format|
    +    format.html # index.html.erb
    +    format.json { render json: @comments }
    +  end
    +end
    +
    + +
    + + + + +
    + + +
    + +
    + new() + click to toggle source +
    + + +
    + +

    Nos permite crear un nuevo comentario GET /coments/new GET +/coments/new.json

    + + + +
    +
    # File app/controllers/comments_controller.rb, line 44
    +def new
    +  @comment = Comment.new
    +  
    +  if !params[:site_id].nil? 
    +@site = Site.find(params[:site_id])       
    +  end
    +  respond_to do |format|
    +    format.html # new.html.erb
    +    format.json { render json: @comment }
    +  end
    +end
    +
    + +
    + + + + +
    + + +
    + +
    + show() + click to toggle source +
    + + +
    + +

    GET /comentarios/1 GET /comentarios/1.json

    + + + +
    +
    # File app/controllers/comments_controller.rb, line 93
    +def show
    +  @comentario = Comment.find(params[:id])
    +
    +  respond_to do |format|
    +    format.html # show.html.erb
    +    format.json { render json: @comment }
    +  end
    +end
    +
    + +
    + + + + +
    + + +
    + +
    + update() + click to toggle source +
    + + +
    + +

    PUT /comments/1 PUT /comments/1.json

    + + + +
    +
    # File app/controllers/comments_controller.rb, line 71
    +def update
    +       @site = Site.find(params[:site_id])
    +       @comment = @site.comments.find(params[:id])
    +
    +       respond_to do |format|
    +                if @comment.update_attributes(params[:comment])
    +                    format.html { redirect_to @site, notice: 'Comentario actualizado' }
    +                    format.json { head :no_content }
    +                else
    +                       format.html { render action: "edit" }
    +                    format.json { render json: @comment.errors, status: :unprocessable_entity }
    +                end
    +        end
    +end
    +
    + +
    + + + + +
    + + +
    + +
    + +
    + + + + diff --git a/doc/app/CommentsHelper.html b/doc/app/CommentsHelper.html new file mode 100644 index 0000000..b0b97c2 --- /dev/null +++ b/doc/app/CommentsHelper.html @@ -0,0 +1,161 @@ + + + + + + +module CommentsHelper - Rails Application Documentation + + + + + + + + + + + + + + + + +
    +

    module CommentsHelper

    + +
    + +

    Helper de Comments

    + +

    Se encarga de apoyar a la clase Comments

    + +
    + + + + +
    + + + + + + + + + + +
    + +
    + + + + diff --git a/doc/app/PlanetController.html b/doc/app/PlanetController.html index e3bde99..6dcb869 100644 --- a/doc/app/PlanetController.html +++ b/doc/app/PlanetController.html @@ -70,12 +70,16 @@

    Methods

    @@ -101,6 +105,12 @@

    Class and Module Index

  • ApplicationHelper +
  • Comment + +
  • CommentsController + +
  • CommentsHelper +
  • PlanetController
  • PlanetHelper @@ -142,41 +152,9 @@

    class PlanetController

    -

    PlanetController ilustra el uso de -RDoc. La documentación de un proyecto en genera en el -directorio proy/doc en formato Web con

    - -
    $proy> rake doc:app
    - -

    Algunos comandos de formateo

    - -

    Tal y como muestra el subitulo anterior, este se define empezando la línea -con ==. En los títulos debe empezar por =.

    - -

    Un [ … ] seguido de texto define una lista titulada, como aquí

    -
    Clases, Módulos o Métodos -
    -

    Se documentan con comentarios justo encima de sus definición, como aquí.

    -
    - -

    Un * o - definen las entradas de una lista itemizada

    - - -

    Un número o letra seguido de punto genera una lista númerada

    -
    1. -

      + permite generar negrita, igual que con -HTML

      -
    2. -

      _ permite generar cursiva, igual que con HTML

      -
      • -

        permite generar letra de teletipo, igual que con -HTML

        -
      -
    +

    Controlador de Planet

    + +

    Incluye la lógica de la clase Planet

    @@ -198,6 +176,35 @@

    Algunos comandos de formateo

    Public Instance Methods

    +
    + +
    + author() + click to toggle source +
    + + +
    + + + + + +
    +
    # File app/controllers/planet_controller.rb, line 15
    +def author
    +end
    +
    + +
    + + + + +
    + +
    @@ -209,12 +216,12 @@

    Public Instance Methods

    -

    Método que define una acción vacía del controlador

    +

    Método para contactar

    -
    # File app/controllers/planet_controller.rb, line 28
    +            
    # File app/controllers/planet_controller.rb, line 9
     def contact
     end
    @@ -238,12 +245,12 @@

    Public Instance Methods

    -

    Método que define una acción vacía del controlador

    +

    Método ejemplo

    -
    # File app/controllers/planet_controller.rb, line 31
    +            
    # File app/controllers/planet_controller.rb, line 12
     def ejemplo
     end
    @@ -267,12 +274,12 @@

    Public Instance Methods

    -

    Método que define una acción vacía del controlador

    +

    Método para mostrar la página inicial

    -
    # File app/controllers/planet_controller.rb, line 25
    +            
    # File app/controllers/planet_controller.rb, line 6
     def index
     end
    @@ -285,6 +292,42 @@

    Public Instance Methods

    + + + diff --git a/doc/app/PlanetHelper.html b/doc/app/PlanetHelper.html index 578d307..c8f7ab2 100644 --- a/doc/app/PlanetHelper.html +++ b/doc/app/PlanetHelper.html @@ -81,6 +81,12 @@

    Class and Module Index

  • ApplicationHelper +
  • Comment + +
  • CommentsController + +
  • CommentsHelper +
  • PlanetController
  • PlanetHelper @@ -122,6 +128,10 @@

    module PlanetHelper

    +

    Helper de Planet

    + +

    Se encarga de apoyar a la clase Planet

    +
    diff --git a/doc/app/Site.html b/doc/app/Site.html index 3c8b96c..263a976 100644 --- a/doc/app/Site.html +++ b/doc/app/Site.html @@ -87,6 +87,12 @@

    Class and Module Index

  • ApplicationHelper +
  • Comment + +
  • CommentsController + +
  • CommentsHelper +
  • PlanetController
  • PlanetHelper diff --git a/doc/app/SitesController.html b/doc/app/SitesController.html index c02b5c6..448c79b 100644 --- a/doc/app/SitesController.html +++ b/doc/app/SitesController.html @@ -109,6 +109,12 @@

    Class and Module Index

  • ApplicationHelper +
  • Comment + +
  • CommentsController + +
  • CommentsHelper +
  • PlanetController
  • PlanetHelper @@ -150,6 +156,10 @@

    class SitesController

    +

    Controlador de Sites

    + +

    Incluye la lógica de la clase Sites

    +
    @@ -186,7 +196,7 @@

    Public Instance Methods

    -
    # File app/controllers/sites_controller.rb, line 50
    +            
    # File app/controllers/sites_controller.rb, line 55
     def create
       @site = current_user.sites.build(params[:site]) # Asigna solo si sitio asociado a current_user
       
    @@ -226,7 +236,7 @@ 

    Public Instance Methods

    -
    # File app/controllers/sites_controller.rb, line 82
    +            
    # File app/controllers/sites_controller.rb, line 87
     def destroy
       @site = current_user.sites.find(params[:id])  # busca solo en sitios asociados a current_user
       @site.destroy
    @@ -262,7 +272,7 @@ 

    Public Instance Methods

    -
    # File app/controllers/sites_controller.rb, line 44
    +            
    # File app/controllers/sites_controller.rb, line 49
     def edit
       @site = current_user.sites.find(params[:id])  # busca solo en sitios asociados a current_user
     end
    @@ -292,7 +302,7 @@

    Public Instance Methods

    -
    # File app/controllers/sites_controller.rb, line 9
    +            
    # File app/controllers/sites_controller.rb, line 13
     def index
       if params[:type_id].nil? or params[:type_id].empty?
         @sites = Site.all            # path: /types
    @@ -330,7 +340,7 @@ 

    Public Instance Methods

    -
    # File app/controllers/sites_controller.rb, line 34
    +            
    # File app/controllers/sites_controller.rb, line 39
     def new
       @site = current_user.sites.build # crea sitio vacio asociado a current_user
       
    @@ -365,9 +375,10 @@ 

    Public Instance Methods

    -
    # File app/controllers/sites_controller.rb, line 23
    +            
    # File app/controllers/sites_controller.rb, line 27
     def show
       @site = Site.find(params[:id])
    +  
     
       respond_to do |format|
         format.html # show.html.erb
    @@ -400,7 +411,7 @@ 

    Public Instance Methods

    -
    # File app/controllers/sites_controller.rb, line 66
    +            
    # File app/controllers/sites_controller.rb, line 71
     def update
       @site = current_user.sites.find(params[:id])  # busca solo en sitios asociados a current_user 
       
    diff --git a/doc/app/SitesHelper.html b/doc/app/SitesHelper.html
    index aa932c6..e0820e7 100644
    --- a/doc/app/SitesHelper.html
    +++ b/doc/app/SitesHelper.html
    @@ -81,6 +81,12 @@ 

    Class and Module Index

  • ApplicationHelper +
  • Comment + +
  • CommentsController + +
  • CommentsHelper +
  • PlanetController
  • PlanetHelper @@ -122,6 +128,10 @@

    module SitesHelper

    +

    Helper de Sites

    + +

    Se encarga de apoyar a la clase Sites

    +
    diff --git a/doc/app/Trip.html b/doc/app/Trip.html index 9a51e94..f83874c 100644 --- a/doc/app/Trip.html +++ b/doc/app/Trip.html @@ -87,6 +87,12 @@

    Class and Module Index

  • ApplicationHelper +
  • Comment + +
  • CommentsController + +
  • CommentsHelper +
  • PlanetController
  • PlanetHelper diff --git a/doc/app/TripsController.html b/doc/app/TripsController.html index abfde19..5f00999 100644 --- a/doc/app/TripsController.html +++ b/doc/app/TripsController.html @@ -109,6 +109,12 @@

    Class and Module Index

  • ApplicationHelper +
  • Comment + +
  • CommentsController + +
  • CommentsHelper +
  • PlanetController
  • PlanetHelper @@ -150,6 +156,10 @@

    class TripsController

    +

    Controlador de Trips

    + +

    Incluye la lógica de la clase Trips

    +
    @@ -186,7 +196,7 @@

    Public Instance Methods

    -
    # File app/controllers/trips_controller.rb, line 47
    +            
    # File app/controllers/trips_controller.rb, line 51
     def create
       @trip = current_user.trips.build(params[:trip])
     
    @@ -226,7 +236,7 @@ 

    Public Instance Methods

    -
    # File app/controllers/trips_controller.rb, line 79
    +            
    # File app/controllers/trips_controller.rb, line 83
     def destroy
       @trip = current_user.trips.find(params[:id])
       @trip.destroy
    @@ -262,7 +272,7 @@ 

    Public Instance Methods

    -
    # File app/controllers/trips_controller.rb, line 41
    +            
    # File app/controllers/trips_controller.rb, line 45
     def edit
       @trip = current_user.trips.find(params[:id])
     end
    @@ -292,7 +302,7 @@

    Public Instance Methods

    -
    # File app/controllers/trips_controller.rb, line 8
    +            
    # File app/controllers/trips_controller.rb, line 12
     def index
       @trips = Trip.all
     
    @@ -327,7 +337,7 @@ 

    Public Instance Methods

    -
    # File app/controllers/trips_controller.rb, line 31
    +            
    # File app/controllers/trips_controller.rb, line 35
     def new
       @trip = current_user.trips.build
       
    @@ -362,7 +372,7 @@ 

    Public Instance Methods

    -
    # File app/controllers/trips_controller.rb, line 19
    +            
    # File app/controllers/trips_controller.rb, line 23
     def show
       @trip = Trip.find(params[:id])
       @visit = @trip.visits.build
    @@ -398,7 +408,7 @@ 

    Public Instance Methods

    -
    # File app/controllers/trips_controller.rb, line 63
    +            
    # File app/controllers/trips_controller.rb, line 67
     def update
       @trip = current_user.trips.find(params[:id])
       
    diff --git a/doc/app/TripsHelper.html b/doc/app/TripsHelper.html
    index 7d08398..b9593fc 100644
    --- a/doc/app/TripsHelper.html
    +++ b/doc/app/TripsHelper.html
    @@ -81,6 +81,12 @@ 

    Class and Module Index

  • ApplicationHelper +
  • Comment + +
  • CommentsController + +
  • CommentsHelper +
  • PlanetController
  • PlanetHelper @@ -122,6 +128,10 @@

    module TripsHelper

    +

    Helper de Trips

    + +

    Se encarga de apoyar a la clase Trips

    +
    diff --git a/doc/app/Type.html b/doc/app/Type.html index c9f3a24..0dd1429 100644 --- a/doc/app/Type.html +++ b/doc/app/Type.html @@ -87,6 +87,12 @@

    Class and Module Index

  • ApplicationHelper +
  • Comment + +
  • CommentsController + +
  • CommentsHelper +
  • PlanetController
  • PlanetHelper diff --git a/doc/app/TypesController.html b/doc/app/TypesController.html index e69e052..9a71e5c 100644 --- a/doc/app/TypesController.html +++ b/doc/app/TypesController.html @@ -80,6 +80,8 @@

    Methods

  • #new +
  • #ordered_index +
  • #show
  • #update @@ -109,6 +111,12 @@

    Class and Module Index

  • ApplicationHelper +
  • Comment + +
  • CommentsController + +
  • CommentsHelper +
  • PlanetController
  • PlanetHelper @@ -150,6 +158,10 @@

    class TypesController

    +

    Controlador de Types

    + +

    Incluye la lógica de la clase Types

    +
    @@ -186,7 +198,7 @@

    Public Instance Methods

    -
    # File app/controllers/types_controller.rb, line 42
    +            
    # File app/controllers/types_controller.rb, line 55
     def create
       @type = Type.new(params[:type])
     
    @@ -226,7 +238,7 @@ 

    Public Instance Methods

    -
    # File app/controllers/types_controller.rb, line 74
    +            
    # File app/controllers/types_controller.rb, line 87
     def destroy
       @type = Type.find(params[:id])
       @type.destroy
    @@ -262,7 +274,7 @@ 

    Public Instance Methods

    -
    # File app/controllers/types_controller.rb, line 36
    +            
    # File app/controllers/types_controller.rb, line 49
     def edit
       @type = Type.find(params[:id])
     end
    @@ -292,7 +304,7 @@

    Public Instance Methods

    -
    # File app/controllers/types_controller.rb, line 4
    +            
    # File app/controllers/types_controller.rb, line 8
     def index
       @types = Type.all
     
    @@ -327,7 +339,7 @@ 

    Public Instance Methods

    -
    # File app/controllers/types_controller.rb, line 26
    +            
    # File app/controllers/types_controller.rb, line 39
     def new
       @type = Type.new
     
    @@ -346,6 +358,41 @@ 

    Public Instance Methods

    +
    + +
    + ordered_index() + click to toggle source +
    + + +
    + +

    GET /types/ordered_index GET /types/ordered_index.json

    + + + +
    +
    # File app/controllers/types_controller.rb, line 18
    +def ordered_index
    +  @types = Type.find(:all, :order => :name) 
    +
    +  respond_to do |format|
    +    format.html # index.html.erb
    +    format.json { render json: @types }
    +  end
    +end
    +
    + +
    + + + + +
    + +
    @@ -362,7 +409,7 @@

    Public Instance Methods

    -
    # File app/controllers/types_controller.rb, line 15
    +            
    # File app/controllers/types_controller.rb, line 28
     def show
       @type = Type.find(params[:id])
     
    @@ -397,7 +444,7 @@ 

    Public Instance Methods

    -
    # File app/controllers/types_controller.rb, line 58
    +            
    # File app/controllers/types_controller.rb, line 71
     def update
       @type = Type.find(params[:id])
     
    diff --git a/doc/app/TypesHelper.html b/doc/app/TypesHelper.html
    index d7e732d..a825f58 100644
    --- a/doc/app/TypesHelper.html
    +++ b/doc/app/TypesHelper.html
    @@ -81,6 +81,12 @@ 

    Class and Module Index

  • ApplicationHelper +
  • Comment + +
  • CommentsController + +
  • CommentsHelper +
  • PlanetController
  • PlanetHelper @@ -122,6 +128,10 @@

    module TypesHelper

    +

    Helper de Types

    + +

    Se encarga de apoyar a la clase Types

    +
    diff --git a/doc/app/User.html b/doc/app/User.html index 5fa3862..19f3ed7 100644 --- a/doc/app/User.html +++ b/doc/app/User.html @@ -87,6 +87,12 @@

    Class and Module Index

  • ApplicationHelper +
  • Comment + +
  • CommentsController + +
  • CommentsHelper +
  • PlanetController
  • PlanetHelper diff --git a/doc/app/Visit.html b/doc/app/Visit.html index ad56b8f..67d89ed 100644 --- a/doc/app/Visit.html +++ b/doc/app/Visit.html @@ -87,6 +87,12 @@

    Class and Module Index

  • ApplicationHelper +
  • Comment + +
  • CommentsController + +
  • CommentsHelper +
  • PlanetController
  • PlanetHelper diff --git a/doc/app/VisitsController.html b/doc/app/VisitsController.html index 00709aa..66f5b1d 100644 --- a/doc/app/VisitsController.html +++ b/doc/app/VisitsController.html @@ -109,6 +109,12 @@

    Class and Module Index

  • ApplicationHelper +
  • Comment + +
  • CommentsController + +
  • CommentsHelper +
  • PlanetController
  • PlanetHelper @@ -150,6 +156,10 @@

    class VisitsController

    +

    Controlador de Visits

    + +

    Incluye la lógica de la clase Visits

    +
    @@ -186,7 +196,7 @@

    Public Instance Methods

    -
    # File app/controllers/visits_controller.rb, line 42
    +            
    # File app/controllers/visits_controller.rb, line 46
     def create
       @visit = Visit.new(params[:visit])
     
    @@ -227,7 +237,7 @@ 

    Public Instance Methods

    -
    # File app/controllers/visits_controller.rb, line 75
    +            
    # File app/controllers/visits_controller.rb, line 79
     def destroy
       @visit = Visit.find(params[:id])
       @visit.destroy
    @@ -263,7 +273,7 @@ 

    Public Instance Methods

    -
    # File app/controllers/visits_controller.rb, line 36
    +            
    # File app/controllers/visits_controller.rb, line 40
     def edit
       @visit = Visit.find(params[:id])
     end
    @@ -293,7 +303,7 @@

    Public Instance Methods

    -
    # File app/controllers/visits_controller.rb, line 4
    +            
    # File app/controllers/visits_controller.rb, line 8
     def index
       @visits = Visit.all
     
    @@ -328,7 +338,7 @@ 

    Public Instance Methods

    -
    # File app/controllers/visits_controller.rb, line 26
    +            
    # File app/controllers/visits_controller.rb, line 30
     def new
       @visit = Visit.new
     
    @@ -363,7 +373,7 @@ 

    Public Instance Methods

    -
    # File app/controllers/visits_controller.rb, line 15
    +            
    # File app/controllers/visits_controller.rb, line 19
     def show
       @visit = Visit.find(params[:id])
     
    @@ -398,7 +408,7 @@ 

    Public Instance Methods

    -
    # File app/controllers/visits_controller.rb, line 59
    +            
    # File app/controllers/visits_controller.rb, line 63
     def update
       @visit = Visit.find(params[:id])
     
    diff --git a/doc/app/VisitsHelper.html b/doc/app/VisitsHelper.html
    index 4ff2034..a01f19a 100644
    --- a/doc/app/VisitsHelper.html
    +++ b/doc/app/VisitsHelper.html
    @@ -81,6 +81,12 @@ 

    Class and Module Index

  • ApplicationHelper +
  • Comment + +
  • CommentsController + +
  • CommentsHelper +
  • PlanetController
  • PlanetHelper @@ -122,6 +128,10 @@

    module VisitsHelper

    +

    Helper de Visits

    + +

    Se encarga de apoyar a la clase Visits

    +
    diff --git a/doc/app/created.rid b/doc/app/created.rid index 2aaa3ea..4fff6c1 100644 --- a/doc/app/created.rid +++ b/doc/app/created.rid @@ -1,19 +1,22 @@ -Mon, 16 Apr 2012 08:53:15 +0200 -doc/README_FOR_APP Sat, 17 Mar 2012 23:42:41 +0100 -app/controllers/application_controller.rb Sat, 17 Mar 2012 23:42:41 +0100 -app/controllers/planet_controller.rb Mon, 16 Apr 2012 08:53:07 +0200 -app/controllers/sites_controller.rb Thu, 12 Apr 2012 11:23:00 +0200 -app/controllers/trips_controller.rb Mon, 09 Apr 2012 17:09:15 +0200 -app/controllers/types_controller.rb Sun, 18 Mar 2012 00:15:37 +0100 -app/controllers/visits_controller.rb Tue, 10 Apr 2012 18:45:27 +0200 -app/helpers/application_helper.rb Sat, 17 Mar 2012 23:42:41 +0100 -app/helpers/planet_helper.rb Sat, 17 Mar 2012 23:48:05 +0100 -app/helpers/sites_helper.rb Tue, 20 Mar 2012 11:01:45 +0100 -app/helpers/trips_helper.rb Mon, 09 Apr 2012 10:57:40 +0200 -app/helpers/types_helper.rb Sun, 18 Mar 2012 00:15:37 +0100 -app/helpers/visits_helper.rb Mon, 09 Apr 2012 17:09:15 +0200 -app/models/site.rb Wed, 11 Apr 2012 13:04:49 +0200 -app/models/trip.rb Mon, 09 Apr 2012 17:09:15 +0200 -app/models/type.rb Wed, 28 Mar 2012 18:02:57 +0200 -app/models/user.rb Mon, 09 Apr 2012 17:09:15 +0200 -app/models/visit.rb Mon, 09 Apr 2012 17:09:15 +0200 +Fri, 27 Apr 2012 06:49:29 +0200 +doc/README_FOR_APP Wed, 28 Mar 2012 04:15:46 +0200 +app/controllers/application_controller.rb Fri, 27 Apr 2012 06:40:03 +0200 +app/controllers/comments_controller.rb Fri, 27 Apr 2012 06:47:05 +0200 +app/controllers/planet_controller.rb Fri, 27 Apr 2012 06:49:12 +0200 +app/controllers/sites_controller.rb Fri, 27 Apr 2012 06:47:34 +0200 +app/controllers/trips_controller.rb Fri, 27 Apr 2012 06:47:48 +0200 +app/controllers/types_controller.rb Fri, 27 Apr 2012 06:48:00 +0200 +app/controllers/visits_controller.rb Fri, 27 Apr 2012 06:48:15 +0200 +app/helpers/application_helper.rb Fri, 27 Apr 2012 06:41:31 +0200 +app/helpers/comments_helper.rb Fri, 27 Apr 2012 06:41:53 +0200 +app/helpers/planet_helper.rb Fri, 27 Apr 2012 06:42:15 +0200 +app/helpers/sites_helper.rb Fri, 27 Apr 2012 06:42:33 +0200 +app/helpers/trips_helper.rb Fri, 27 Apr 2012 06:42:48 +0200 +app/helpers/types_helper.rb Fri, 27 Apr 2012 06:43:09 +0200 +app/helpers/visits_helper.rb Fri, 27 Apr 2012 06:43:23 +0200 +app/models/comment.rb Fri, 27 Apr 2012 04:00:15 +0200 +app/models/site.rb Mon, 16 Apr 2012 04:38:40 +0200 +app/models/trip.rb Thu, 12 Apr 2012 16:27:52 +0200 +app/models/type.rb Thu, 12 Apr 2012 16:27:52 +0200 +app/models/user.rb Sun, 15 Apr 2012 23:43:15 +0200 +app/models/visit.rb Thu, 12 Apr 2012 16:27:52 +0200 diff --git a/doc/app/doc/README_FOR_APP.html b/doc/app/doc/README_FOR_APP.html index cfe337b..1255c65 100644 --- a/doc/app/doc/README_FOR_APP.html +++ b/doc/app/doc/README_FOR_APP.html @@ -63,6 +63,12 @@

    Class and Module Index

  • ApplicationHelper +
  • Comment + +
  • CommentsController + +
  • CommentsHelper +
  • PlanetController
  • PlanetHelper diff --git a/doc/app/index.html b/doc/app/index.html index a944adb..55a179b 100644 --- a/doc/app/index.html +++ b/doc/app/index.html @@ -63,6 +63,12 @@

    Class and Module Index

  • ApplicationHelper +
  • Comment + +
  • CommentsController + +
  • CommentsHelper +
  • PlanetController
  • PlanetHelper @@ -95,11 +101,103 @@

    Class and Module Index

    - +
  • This is the API documentation for Rails Application Documentation. +asaasa + +

    +

    Proyecto Planet

    + +
    + +

    Resumen del proyecto

    +

    El proyecto planet2012 pretende ser una red social de viajes, lugares y sitios. El usuario podrá crear sitios en los que ha estado o planea estar para así poder planificarse viajes.

    + +

    Conocimientos adquiridos

    +
    +
      +
    • Ruby on Rails
    • +
    • Gestionar proyectos mediante git
    • +
    • Tecnología sqlite
    • +
    • Tecnología html.erb
    • +
    • Modelo vista controlador
    • +
    • Desplegar servicios web online mediante la plataforma Heroku
    • +
    • HTML5 Canvas
    • +
    • API de google maps
    • +
    • Testing
    • +
    • Gema de autenticación Devise
    • +
    • Aplicación directa de conocimientos previos html, javascript, Ruby
    • + +
    +

    Resumen detallado de las prácticas

    +

    Práctica 1:

    +

    Añadir las siguientes mejoras al commit "df46232 se añade seeds.rb" proyecto planet:

    +

    1) Definir una nueva acción en el controlador planet, denominada “author”. La nueva acción debe dar acceso a una página Web con los datos de los autores de este portal Web, incluyendo

    +

    - nombre, direccion postal y electrónica, foto y breve curriculum

    +

    2) Definir tests de funcionalidad para ejemplo y author, y comprobar que los tests pasan correctamente

    +

    3) Añadir a las vistas index.html.erb y show.html.erb de”types” la fecha en la que fueron modificados por última vez

    +

    - Dicha fecha está accesible en el campo “updated_at” de los objetos de la BBDD (ver fichero schema.rb)

    +

    4) Añadir una nueva acción al controlador de “types” denominada “ordered_index”, que liste los monumentos ordenados alfabeticamente por nombre. Utilizar función Type.find(:all, :order => :name)

    +
      +
    • El nuevo controlador debe atender a comando HTTP: "GET /types/ordered_index" (o con otro URL)
    • +
        +
      • Se debe definir la nueva ruta
      • +
          +
        • La vista y controlador pueden definirse nuevos o también se pueden reutilizar los de index
        • +
        +
      +
    +

    5) Incluir 6 hiperenlaces en parte superior e inferior de todas las páginas, enlazados con:

    +
      +
    • planet/index
    • +
    • planet/contact
    • +
    • planet/ejemplo
    • +
    • planet/author
    • +
    • types/index
    • +
    • types/ordered_index
    • +
    +

    Se recomienda definir hiperenlaces utilizando path_helpers, por ejemplo: <%= link_to('Index', planet_index_path) + ... %> en “app/views/layouts/application.html.erb” antes y despues de <% yield %>

    +

    6) Integrar todas las modificaciones en un clón de ging/planet y hacer un pull request a ging/planet con las modificaciones

    + +

    Práctica 2:

    + +

    Crear una tabla de gestión de comentarios de los sitios que pueda contener comentarios de 240 caracteres como máximo.

    +

    Cada comentario pertenecerá a un usuario y a un sitio por lo que deberá crease una tabla con 3 campos ("coment:string", "user_id:integer" y site_id:integer") que relacione cada comentario con un sitio y un usuario.

    +

    Un usuario podrá tener muchos comentarios y un sitio tambien podra tener muchos comentarios, por lo que habra que definir una relación uno_a_muchos entre comentarios y sitio, y entre comentarios y usuario.

    +

    La vista de la lista de sitios ("index") deberán modificarse para que si existen comentarios a un sitio, aparezca al final de la descripción la palabra comentarios, resaltada en negrita con un hiperenlace a la lista de comentarios.

    +

    La vista de un sitio ("show") deberán modificarse para que si existen comentarios a un sitio, estos se adjunten al final de la descripción del sitio.

    +

    La lista de comentarios incluirá el nombre del autor al principio, seguido de “: ” y del comentario. Las acciones deberán estar filtradas para que reflejen correctamente los permisos, es decir, solo los autores de un comentario podrán editarlo o borrarlo.

    +

    Justo detras de los comentarios aparecerá el texto "Añada su comentario" con un campo de entrada de comentario y un boton de “nuevo comentario”.

    +

    Nota. http://guides.rubyonrails.org/getting_started.html añade comentarios a posts de un blog (similar). + +

    Práctica 3:

    +

    Añadir a la tabla de sitios la captura automatica de sus coordenadas, de forma que al crear un sitio y utilizando el API de geoposicionamiento de HTML5 se añadan las coordenadas obtenidas al sitio.

    +
      +
    • Las coordenadas obtenidas deberan poder ser editadas por el usuario en el formulario
    • +
    • Habra que enriquecer también la tabla de sitios con 3 nuevos campos: longitud, latitud y zoom, doinde guardar dichos valores.
    • +
    +

    Añadir ademas:

    +
      +
    1. A cada sitio de planet un mapa (de Google Maps), que muestre su posicion en el mapa.
    2. +
    3. A cada viaje de planet un mapa (de Google Maps), que muestre la foto de todas las visitas del viaje geoposicionados en sus coordenadas en el mapa
    4. +
    +

    Indicar ademas para cada sitio (lista de sites), el número de veces que ha sido incluido en algún viaje, tanto en la vista individual, como en la lista de sitios.

    + +

    Práctica 4

    +

    Añadir a planet un buscador de sitios y viajes que este en todas las páginas en el mismo lugar (en application.html.erb)

    +

    El buscador tendra un cajetín para introducir un string de 3 o mas caracteres. Tendrá además un botón para lanzar la busqueda de sitios y viajes que contengan el string en el nombre o en la descripción.

    +

    La lista de sitios y viajes se presentará en 2 apartados, el primero contendrá los sitios y el segundo los viajes encontrados.

    +

    Se recomienda asociar la acción de busqueda al controlador planet, debido a que integra vistas parciales de sites y trips.

    +

    Además hay que arreglar todos los tests generados por rails para que pasen correctamente al ejecutar “rake test”. Y añadir un test de funcionalidad para la nueva acción buscar.

    +

    Por último se deberá documentar las páginas de esta entrega en formato RDoc y ejecutar “rake doc:app” para generar doc del proyecto.

    +

    La documentación generada se deberá enlazar con una nueva entrada de la barra de navegación.

    +

    También se deberá desplegar el proyecto en Heroku.

    + + +