Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Binary file added app/assets/images/almudena.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/carlos.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/debod.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/quique.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/retiro.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/assets/javascripts/comments.js.coffee
Original file line number Diff line number Diff line change
@@ -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/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/comments.css.scss
Original file line number Diff line number Diff line change
@@ -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/
26 changes: 25 additions & 1 deletion app/assets/stylesheets/planet.css
Original file line number Diff line number Diff line change
Expand Up @@ -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{

}
4 changes: 4 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -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
101 changes: 101 additions & 0 deletions app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
@@ -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
46 changes: 22 additions & 24 deletions app/controllers/planet_controller.rb
Original file line number Diff line number Diff line change
@@ -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:[email protected]]
# * o así {Pepe Rubio}[mailto:[email protected]]
#
# Un número o letra seguido de punto genera una lista númerada
# 1. + permite generar *negrita*, igual que <b>con HTML</b>
# 2. _ permite generar _cursiva_, igual que <em>con HTML</em>
# 3. * permite generar letra de +teletipo+, igual que <tt> con HTML</tt>
# == 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
9 changes: 7 additions & 2 deletions app/controllers/sites_controller.rb
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/trips_controller.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
15 changes: 15 additions & 0 deletions app/controllers/types_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# == Controlador de Types
#
# Incluye la lógica de la clase Types

class TypesController < ApplicationController
# GET /types
# GET /types.json
Expand All @@ -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
Expand Down Expand Up @@ -80,4 +93,6 @@ def destroy
format.json { head :no_content }
end
end


end
4 changes: 4 additions & 0 deletions app/controllers/visits_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# == Controlador de Visits
#
# Incluye la lógica de la clase Visits

class VisitsController < ApplicationController
# GET /visits
# GET /visits.json
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# == Helper de Application
# Se encarga de apoyar a la clase Application
module ApplicationHelper
end
4 changes: 4 additions & 0 deletions app/helpers/comments_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# == Helper de Comments
# Se encarga de apoyar a la clase Comments
module CommentsHelper
end
2 changes: 2 additions & 0 deletions app/helpers/planet_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# == Helper de Planet
# Se encarga de apoyar a la clase Planet
module PlanetHelper
end
3 changes: 3 additions & 0 deletions app/helpers/sites_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# == Helper de Sites
# Se encarga de apoyar a la clase Sites

module SitesHelper
end
2 changes: 2 additions & 0 deletions app/helpers/trips_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# == Helper de Trips
# Se encarga de apoyar a la clase Trips
module TripsHelper
end
3 changes: 3 additions & 0 deletions app/helpers/types_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# == Helper de Types
# Se encarga de apoyar a la clase Types

module TypesHelper
end
2 changes: 2 additions & 0 deletions app/helpers/visits_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# == Helper de Visits
# Se encarga de apoyar a la clase Visits
module VisitsHelper
end
8 changes: 8 additions & 0 deletions app/models/comment.rb
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion app/models/site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions app/views/comments/_comment.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<p>

<b><%= comment.user.name if comment.user %></b>
<%= comment.coment %>
</p>

<p>
<% 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 %>
</p>
8 changes: 8 additions & 0 deletions app/views/comments/_edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<%= form_for([@site, @comment]) do |f| %>
<div class="field">
<%= f.text_area :coment %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
9 changes: 9 additions & 0 deletions app/views/comments/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<%= form_for([@site, @site.comments.build]) do |f| %>
<div class="field">
<%= f.text_area :coment %>
</div>

<div class="actions">
<%= f.submit %>
</div>
<% end %>
Loading