diff --git a/Gemfile b/Gemfile
index 7764763..b30a0c5 100644
--- a/Gemfile
+++ b/Gemfile
@@ -7,6 +7,7 @@ gem 'rails', '3.2.2'
gem 'sqlite3'
+gem 'devise'
# Gems used only for assets and not required
# in production environments by default.
diff --git a/Gemfile.lock b/Gemfile.lock
index 81a3ba7..5730fc3 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -29,6 +29,8 @@ GEM
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.2)
+ bcrypt-ruby (3.0.1)
+ bcrypt-ruby (3.0.1-x86-mingw32)
builder (3.0.0)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
@@ -37,6 +39,11 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.2.0)
+ devise (2.0.4)
+ bcrypt-ruby (~> 3.0)
+ orm_adapter (~> 0.0.3)
+ railties (~> 3.1)
+ warden (~> 1.1.1)
erubis (2.7.0)
execjs (1.3.0)
multi_json (~> 1.0)
@@ -53,6 +60,7 @@ GEM
treetop (~> 1.4.8)
mime-types (1.17.2)
multi_json (1.1.0)
+ orm_adapter (0.0.7)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
@@ -89,6 +97,7 @@ GEM
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.5)
+ sqlite3 (1.3.5-x86-mingw32)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
@@ -98,12 +107,16 @@ GEM
uglifier (1.2.3)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
+ warden (1.1.1)
+ rack (>= 1.0)
PLATFORMS
ruby
+ x86-mingw32
DEPENDENCIES
coffee-rails (~> 3.2.1)
+ devise
jquery-rails
rails (= 3.2.2)
sass-rails (~> 3.2.3)
diff --git a/app/assets/images/alberto.jpg b/app/assets/images/alberto.jpg
new file mode 100644
index 0000000..58923a4
Binary files /dev/null and b/app/assets/images/alberto.jpg differ
diff --git a/app/assets/images/arbol1.png b/app/assets/images/arbol1.png
new file mode 100644
index 0000000..6affc09
Binary files /dev/null and b/app/assets/images/arbol1.png differ
diff --git a/app/assets/images/florencia.png b/app/assets/images/florencia.png
new file mode 100644
index 0000000..6398a2e
Binary files /dev/null and b/app/assets/images/florencia.png differ
diff --git a/app/assets/images/francisco.jpg b/app/assets/images/francisco.jpg
new file mode 100644
index 0000000..a1be5bc
Binary files /dev/null and b/app/assets/images/francisco.jpg differ
diff --git a/app/assets/images/logo3.png b/app/assets/images/logo3.png
new file mode 100644
index 0000000..bfa4c13
Binary files /dev/null and b/app/assets/images/logo3.png differ
diff --git a/app/assets/images/pedriza.png b/app/assets/images/pedriza.png
new file mode 100644
index 0000000..8d300fb
Binary files /dev/null and b/app/assets/images/pedriza.png differ
diff --git a/app/assets/images/pergamo.png b/app/assets/images/pergamo.png
new file mode 100644
index 0000000..7e462c2
Binary files /dev/null and b/app/assets/images/pergamo.png differ
diff --git a/app/assets/images/reichstag.png b/app/assets/images/reichstag.png
new file mode 100644
index 0000000..8b95380
Binary files /dev/null and b/app/assets/images/reichstag.png 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/javascripts/sites.js.coffee b/app/assets/javascripts/sites.js.coffee
new file mode 100644
index 0000000..7615679
--- /dev/null
+++ b/app/assets/javascripts/sites.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..3722c12
--- /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
new file mode 100644
index 0000000..429bb43
--- /dev/null
+++ b/app/assets/stylesheets/planet.css
@@ -0,0 +1,163 @@
+/* Global styles (no utilizados de momento) */
+
+#planet #notice {
+ color: #000;
+ border: 2px solid red;
+ padding: 1em;
+ margin-bottom: 2em;
+ background-color: #f0f0f0;
+ font: bold smaller sans-serif;
+}
+
+
+#planet h1 {
+ font: 150% sans-serif;
+ color: #226;
+ border-bottom: 3px dotted #77d;
+}
+
+/* Styles for products/index */
+
+#site_list table {
+ border-collapse: collapse;
+}
+
+#site_list table tr td {
+ padding: 5px;
+ vertical-align: top;
+}
+
+#site_list .list_image {
+ width: 60px;
+ height: 70px;
+}
+
+#site_list .list_description {
+ width: 60%;
+}
+
+#site_list .list_description dl {
+ margin: 0;
+}
+
+#site_list .list_description dt {
+ color: #244;
+ font-weight: bold;
+ font-size: larger;
+}
+
+#site_list .list_description dd {
+ margin: 0;
+}
+
+#site_list .list_actions {
+ font-size: x-small;
+ text-align: right;
+ padding-left: 1em;
+}
+
+#site_list .list_line_even {
+ background: #a8b8f8;
+}
+
+#site_list .list_line_odd {
+ background: #88b0f8;
+}
+
+
+/* START:mainlayout */
+/* Styles for main page */
+
+#banner {
+ background: #668;
+ padding-top: 10px;
+ padding-bottom: 10px;
+ border-bottom: 2px solid;
+ font: small-caps 40px/40px "Times New Roman", serif;
+ color: #bfb;
+ text-align: center;
+}
+
+#banner img {
+ float: left;
+ padding-left: 10px;
+}
+
+#planet .user {
+ float: right;
+ color: #bfb;
+ font-size: small;
+}
+
+#columns {
+ background: #446;
+}
+
+#main {
+ margin-left: 14em; /* Ajuste de borde izquierdo */
+ padding-top: 4ex;
+ padding-left: 2em;
+ background: white;
+}
+
+#side {
+ float: left;
+ padding-top: 1em;
+ padding-left: 1em;
+ padding-bottom: 1em;
+ background: #446;
+ width: 13em;
+}
+
+#side a {
+ color: #bfb;
+ font-size: small;
+}
+/* END:mainlayout */
+
+/* An entry in the store catalog (no utilizados de momento) */
+
+#planet .entry {
+ overflow: auto;
+ margin-top: 1em;
+ border-bottom: 1px dotted #77d;
+}
+
+#planet .name {
+ font-size: 120%;
+ font-family: sans-serif;
+}
+
+#store .entry img {
+ width: 80px;
+ margin-right: 5px;
+ margin-bottom: 5px;
+ float: left;
+}
+
+
+#store .entry h3 {
+ margin-top: 0;
+ margin-bottom: 2px;
+ color: #227;
+}
+
+#store .entry p {
+ margin-top: 0.5em;
+ margin-bottom: 0.8em;
+}
+
+#store .entry .price_line {
+ clear: both;
+ margin-bottom: 0.5em;
+}
+
+#store .entry .add_to_cart {
+ position: relative;
+}
+
+#store .entry .price {
+ color: #44a;
+ font-weight: bold;
+ margin-right: 2em;
+}
diff --git a/app/assets/stylesheets/sites.css.scss b/app/assets/stylesheets/sites.css.scss
new file mode 100644
index 0000000..682e55c
--- /dev/null
+++ b/app/assets/stylesheets/sites.css.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the sites controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb
new file mode 100644
index 0000000..378f4f1
--- /dev/null
+++ b/app/controllers/comments_controller.rb
@@ -0,0 +1,92 @@
+class CommentsController < ApplicationController
+
+ # authenticate_user! ejecuta acción solo si sesión existe
+ before_filter :authenticate_user!, :except => [ :index, :show ]
+
+ # GET /comments
+ # GET /comments.json
+ def index
+ @site = Site.find(params[:site_id])
+ @comments = @site.comments
+ @comment = current_user.comments.build
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @comments }
+ end
+ end
+
+ # GET /comments/1
+ # GET /comments/1.json
+ def show
+ @comment = Comment.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render json: @comment }
+ end
+ end
+
+ # GET /comments/new
+ # GET /comments/new.json
+ def new
+ @comment = current_user.comments.build
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.json { render json: @comment }
+ end
+ end
+
+ # GET /comments/1/edit
+ def edit
+ @comment = current_user.comments.find(params[:id])
+ @site = @comment.site
+ end
+
+ # POST /comments
+ # POST /comments.json
+ def create
+ @comment = current_user.comments.build(params[:comment])
+ @site = @comment.site
+
+ respond_to do |format|
+ if @comment.save
+ format.html { redirect_to site_path(@site), notice: 'Comment was successfully created.' }
+ format.json { render json: @comment, status: :created, location: @comment }
+ else
+ format.html { render action: "new" }
+ format.json { render json: @comment.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /comments/1
+ # PUT /comments/1.json
+ def update
+ @comment = current_user.comments.find(params[:id])
+
+ respond_to do |format|
+ if @comment.update_attributes(params[:comment])
+ format.html { redirect_to site_path(@comment.site), notice: 'Comment was successfully updated.' }
+ format.json { head :no_content }
+ else
+ format.html { render action: "edit" }
+ format.json { render json: @comment.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /comments/1
+ # DELETE /comments/1.json
+ def destroy
+ @comment = current_user.comments.find(params[:id])
+ site = @comment.site
+ @comment.destroy
+
+ respond_to do |format|
+ format.html { redirect_to site_path(site) }
+ format.json { head :no_content }
+ end
+ end
+end
diff --git a/app/controllers/planet_controller.rb b/app/controllers/planet_controller.rb
index be7ac0a..0421a76 100644
--- a/app/controllers/planet_controller.rb
+++ b/app/controllers/planet_controller.rb
@@ -7,5 +7,8 @@ def contact
def ejemplo
end
+
+ def author
+ end
end
diff --git a/app/controllers/sites_controller.rb b/app/controllers/sites_controller.rb
new file mode 100644
index 0000000..2386568
--- /dev/null
+++ b/app/controllers/sites_controller.rb
@@ -0,0 +1,91 @@
+class SitesController < ApplicationController
+
+ # authenticate_user! ejecuta acción solo si sesión existe
+ before_filter :authenticate_user!, :except => [ :index, :show ]
+
+ # GET /sites
+ # GET /sites.json
+ def index
+ if params[:type_id].nil? or params[:type_id].empty?
+ @sites = Site.all # path: /types
+ else
+ @sites = Type.find(params[:type_id]).sites # path: /types/id/sites
+ end
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @sites }
+ end
+ end
+
+ # GET /sites/1
+ # GET /sites/1.json
+ def show
+ @site = Site.find(params[:id])
+ @comment = current_user.comments.build
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render json: @site }
+ end
+ end
+
+ # GET /sites/new
+ # GET /sites/new.json
+ def new
+ @site = current_user.sites.build # crea sitio vacio asociado a current_user
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.json { render json: @site }
+ end
+ end
+
+ # GET /sites/1/edit
+ def edit
+ @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user
+ end
+
+ # POST /sites
+ # POST /sites.json
+ def create
+ @site = current_user.sites.build(params[:site]) # Asigna solo si sitio asociado a current_user
+
+ respond_to do |format|
+ if @site.save
+ format.html { redirect_to @site, notice: 'Site was successfully created.' }
+ format.json { render json: @site, status: :created, location: @site }
+ else
+ format.html { render action: "new" }
+ format.json { render json: @site.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /sites/1
+ # PUT /sites/1.json
+ def update
+ @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user
+
+ respond_to do |format|
+ if @site.update_attributes(params[:site])
+ format.html { redirect_to @site, notice: 'Site was successfully updated.' }
+ format.json { head :no_content }
+ else
+ format.html { render action: "edit" }
+ format.json { render json: @site.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /sites/1
+ # DELETE /sites/1.json
+ def destroy
+ @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user
+ @site.destroy
+
+ respond_to do |format|
+ format.html { redirect_to sites_url }
+ format.json { head :no_content }
+ end
+ end
+end
diff --git a/app/controllers/types_controller.rb b/app/controllers/types_controller.rb
index da826f4..4604946 100644
--- a/app/controllers/types_controller.rb
+++ b/app/controllers/types_controller.rb
@@ -21,6 +21,17 @@ def show
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 # ordered_index.html.erb
+ format.json { render json: @types }
+ end
+ end
+
# GET /types/new
# GET /types/new.json
def new
diff --git a/app/helpers/comments_helper.rb b/app/helpers/comments_helper.rb
new file mode 100644
index 0000000..0ec9ca5
--- /dev/null
+++ b/app/helpers/comments_helper.rb
@@ -0,0 +1,2 @@
+module CommentsHelper
+end
diff --git a/app/helpers/sites_helper.rb b/app/helpers/sites_helper.rb
new file mode 100644
index 0000000..621069d
--- /dev/null
+++ b/app/helpers/sites_helper.rb
@@ -0,0 +1,2 @@
+module SitesHelper
+end
diff --git a/app/models/comment.rb b/app/models/comment.rb
new file mode 100644
index 0000000..8b7c248
--- /dev/null
+++ b/app/models/comment.rb
@@ -0,0 +1,12 @@
+class Comment < ActiveRecord::Base
+ belongs_to :site
+ belongs_to :user
+
+ # Debe estar protegido para evitar accesos indeseados
+ #attr_protected :user_id
+
+ # Se añaden estas definiciones
+ validates :comment, :user_id, :site_id, :presence => true # campo obligatorio
+ validates :comment, :length => { :maximum => 240 }
+
+end
diff --git a/app/models/site.rb b/app/models/site.rb
new file mode 100644
index 0000000..042a290
--- /dev/null
+++ b/app/models/site.rb
@@ -0,0 +1,12 @@
+class Site < ActiveRecord::Base
+ belongs_to :type
+ belongs_to :user
+
+ has_many :comments
+
+ # Debe estar protegido para evitar accesos indeseados
+ attr_protected :user_id
+
+ # Se añaden estas definiciones
+ validates :name, :type_id, :image_url, :presence => true # campo obligatorio
+end
diff --git a/app/models/type.rb b/app/models/type.rb
index e89da76..2284d1f 100644
--- a/app/models/type.rb
+++ b/app/models/type.rb
@@ -1,2 +1,8 @@
class Type < ActiveRecord::Base
+ has_many :sites
+
+
+ # Se añade esta definición de recurso
+ validates :name, :description, :presence => true # campo obligatorio
+ validates :name, :uniqueness => true # Campo único (no repetido)
end
diff --git a/app/models/user.rb b/app/models/user.rb
new file mode 100644
index 0000000..e57882c
--- /dev/null
+++ b/app/models/user.rb
@@ -0,0 +1,15 @@
+class User < ActiveRecord::Base
+
+ has_many :sites
+ has_many :comments
+
+ # Include default devise modules. Others available are:
+ # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
+ devise :database_authenticatable, :registerable,
+ :recoverable, :rememberable, :trackable, :validatable
+
+ validates_presence_of :name
+
+ # Setup accessible (or protected) attributes for your model
+ attr_accessible :name, :email, :password, :password_confirmation, :remember_me
+end
diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb
new file mode 100644
index 0000000..a59f972
--- /dev/null
+++ b/app/views/comments/_comment.html.erb
@@ -0,0 +1,28 @@
+
+
+ <% @comments.each do |comment| %>
+
+
+
+
+ <% if comment.user == current_user %>
+ - <%= link_to comment.user.name + ":", edit_user_registration_path %>
+ <% else %>
+ - <%= comment.user.name + ":" %>
+ <% end %>
+ - <%= strip_tags(comment.comment) %>
+
+ |
+
+
+ <% if comment.user == current_user %>
+ <%= link_to 'Edit', edit_comment_path(comment) %>
+ <%= link_to 'Destroy', comment,
+ :confirm => 'Are you sure?',
+ :method => :delete if comment.user == current_user %>
+ <% end %>
+ |
+
+ <% 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..8701bb3
--- /dev/null
+++ b/app/views/comments/_form.html.erb
@@ -0,0 +1,23 @@
+<%= form_for(@comment) do |f| %>
+ <% if @comment.errors.any? %>
+
+
<%= pluralize(@comment.errors.count, "error") %> prohibited this comment from being saved:
+
+
+ <% @comment.errors.full_messages.each do |msg| %>
+ - <%= msg %>
+ <% end %>
+
+
+ <% end %>
+
+ Añada su comentario
+
+ <%= f.text_area :comment, :maxlength => 240, :rows => 6 %>
+
+ <%= f.number_field :user_id, :value => current_user.id, :hidden => true %>
+ <%= f.number_field :site_id, :value => @site.id, :hidden => true %>
+
+ <%= f.submit %>
+
+<% end %>
diff --git a/app/views/comments/edit.html.erb b/app/views/comments/edit.html.erb
new file mode 100644
index 0000000..09acee5
--- /dev/null
+++ b/app/views/comments/edit.html.erb
@@ -0,0 +1,6 @@
+Editing comment
+
+<%= render 'form' %>
+
+<%= link_to 'Back', site_path(@comment.site) %>
+
diff --git a/app/views/comments/index.html.erb b/app/views/comments/index.html.erb
new file mode 100644
index 0000000..4958dd3
--- /dev/null
+++ b/app/views/comments/index.html.erb
@@ -0,0 +1,7 @@
+Comentarios de <%= @site.name %>
+
+<%= render(@comment) %>
+
+<%= render 'form' %>
+
+<%= link_to 'Back', sites_path %>
diff --git a/app/views/comments/new.html.erb b/app/views/comments/new.html.erb
new file mode 100644
index 0000000..3e75944
--- /dev/null
+++ b/app/views/comments/new.html.erb
@@ -0,0 +1,5 @@
+New comment
+
+<%= render 'form' %>
+
+<%= link_to 'Back', site_path(@comment.site) %>
diff --git a/app/views/comments/show.html.erb b/app/views/comments/show.html.erb
new file mode 100644
index 0000000..ba05818
--- /dev/null
+++ b/app/views/comments/show.html.erb
@@ -0,0 +1,21 @@
+<%= notice %>
+
+
+ Comment:
+ <%= @comment.comment %>
+
+
+
+ User:
+ <%= @comment.user.name %>
+
+
+
+ Site:
+ <%= @comment.site.name %>
+
+
+<% if @comment.user == current_user %>
+ <%= link_to 'Edit', edit_comment_path(@comment) %> |
+<% end %>
+<%= link_to 'Back', site_path(@comment.site) %>
diff --git a/app/views/devise/_links.erb b/app/views/devise/_links.erb
new file mode 100644
index 0000000..eab783a
--- /dev/null
+++ b/app/views/devise/_links.erb
@@ -0,0 +1,25 @@
+<%- if controller_name != 'sessions' %>
+ <%= link_to "Sign in", new_session_path(resource_name) %>
+<% end -%>
+
+<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
+ <%= link_to "Sign up", new_registration_path(resource_name) %>
+<% end -%>
+
+<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
+ <%= link_to "Forgot your password?", new_password_path(resource_name) %>
+<% end -%>
+
+<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
+ <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %>
+<% end -%>
+
+<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
+ <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %>
+<% end -%>
+
+<%- if devise_mapping.omniauthable? %>
+ <%- resource_class.omniauth_providers.each do |provider| %>
+ <%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %>
+ <% end -%>
+<% end -%>
\ No newline at end of file
diff --git a/app/views/devise/confirmations/new.html.erb b/app/views/devise/confirmations/new.html.erb
new file mode 100644
index 0000000..18d81b1
--- /dev/null
+++ b/app/views/devise/confirmations/new.html.erb
@@ -0,0 +1,12 @@
+Resend confirmation instructions
+
+<%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %>
+ <%= devise_error_messages! %>
+
+ <%= f.label :email %>
+ <%= f.email_field :email %>
+
+ <%= f.submit "Resend confirmation instructions" %>
+<% end %>
+
+<%= render "links" %>
\ No newline at end of file
diff --git a/app/views/devise/mailer/confirmation_instructions.html.erb b/app/views/devise/mailer/confirmation_instructions.html.erb
new file mode 100644
index 0000000..a5c4585
--- /dev/null
+++ b/app/views/devise/mailer/confirmation_instructions.html.erb
@@ -0,0 +1,5 @@
+Welcome <%= @resource.email %>!
+
+You can confirm your account email through the link below:
+
+<%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %>
diff --git a/app/views/devise/mailer/reset_password_instructions.html.erb b/app/views/devise/mailer/reset_password_instructions.html.erb
new file mode 100644
index 0000000..ae9e888
--- /dev/null
+++ b/app/views/devise/mailer/reset_password_instructions.html.erb
@@ -0,0 +1,8 @@
+Hello <%= @resource.email %>!
+
+Someone has requested a link to change your password, and you can do this through the link below.
+
+<%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %>
+
+If you didn't request this, please ignore this email.
+Your password won't change until you access the link above and create a new one.
diff --git a/app/views/devise/mailer/unlock_instructions.html.erb b/app/views/devise/mailer/unlock_instructions.html.erb
new file mode 100644
index 0000000..2263c21
--- /dev/null
+++ b/app/views/devise/mailer/unlock_instructions.html.erb
@@ -0,0 +1,7 @@
+Hello <%= @resource.email %>!
+
+Your account has been locked due to an excessive amount of unsuccessful sign in attempts.
+
+Click the link below to unlock your account:
+
+<%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) %>
diff --git a/app/views/devise/passwords/edit.html.erb b/app/views/devise/passwords/edit.html.erb
new file mode 100644
index 0000000..5f7bcf8
--- /dev/null
+++ b/app/views/devise/passwords/edit.html.erb
@@ -0,0 +1,16 @@
+Change your password
+
+<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %>
+ <%= devise_error_messages! %>
+ <%= f.hidden_field :reset_password_token %>
+
+ <%= f.label :password, "New password" %>
+ <%= f.password_field :password %>
+
+ <%= f.label :password_confirmation, "Confirm new password" %>
+ <%= f.password_field :password_confirmation %>
+
+ <%= f.submit "Change my password" %>
+<% end %>
+
+<%= render "links" %>
\ No newline at end of file
diff --git a/app/views/devise/passwords/new.html.erb b/app/views/devise/passwords/new.html.erb
new file mode 100644
index 0000000..b0b5690
--- /dev/null
+++ b/app/views/devise/passwords/new.html.erb
@@ -0,0 +1,12 @@
+Forgot your password?
+
+<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %>
+ <%= devise_error_messages! %>
+
+ <%= f.label :email %>
+ <%= f.email_field :email %>
+
+ <%= f.submit "Send me reset password instructions" %>
+<% end %>
+
+<%= render "links" %>
\ No newline at end of file
diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb
new file mode 100644
index 0000000..3d2a882
--- /dev/null
+++ b/app/views/devise/registrations/edit.html.erb
@@ -0,0 +1,25 @@
+Edit <%= resource_name.to_s.humanize %>
+
+<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
+ <%= devise_error_messages! %>
+
+ <%= f.label :name %>
<%= f.text_field :name %>
<%= f.label :email %>
+ <%= f.email_field :email %>
+
+ <%= f.label :password %> (leave blank if you don't want to change it)
+ <%= f.password_field :password, :autocomplete => "off" %>
+
+ <%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation %>
+
+ <%= f.label :current_password %> (we need your current password to confirm your changes)
+ <%= f.password_field :current_password %>
+
+ <%= f.submit "Update" %>
+<% end %>
+
+Cancel my account
+
+Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.
+
+<%= link_to "Back", :back %>
diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb
new file mode 100644
index 0000000..79a8c31
--- /dev/null
+++ b/app/views/devise/registrations/new.html.erb
@@ -0,0 +1,19 @@
+Sign up
+
+<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
+ <%= devise_error_messages! %>
+
+ <%= f.label :name %>
<%= f.text_field :name %>
+ <%= f.label :email %>
+ <%= f.email_field :email %>
+
+ <%= f.label :password %>
+ <%= f.password_field :password %>
+
+ <%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation %>
+
+ <%= f.submit "Sign up" %>
+<% end %>
+
+<%= render "links" %>
diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb
new file mode 100644
index 0000000..f12116b
--- /dev/null
+++ b/app/views/devise/sessions/new.html.erb
@@ -0,0 +1,17 @@
+Sign in
+
+<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
+ <%= f.label :email %>
+ <%= f.email_field :email %>
+
+ <%= f.label :password %>
+ <%= f.password_field :password %>
+
+ <% if devise_mapping.rememberable? -%>
+ <%= f.check_box :remember_me %> <%= f.label :remember_me %>
+ <% end -%>
+
+ <%= f.submit "Sign in" %>
+<% end %>
+
+<%= render "links" %>
\ No newline at end of file
diff --git a/app/views/devise/unlocks/new.html.erb b/app/views/devise/unlocks/new.html.erb
new file mode 100644
index 0000000..0dc79ac
--- /dev/null
+++ b/app/views/devise/unlocks/new.html.erb
@@ -0,0 +1,12 @@
+Resend unlock instructions
+
+<%= form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| %>
+ <%= devise_error_messages! %>
+
+ <%= f.label :email %>
+ <%= f.email_field :email %>
+
+ <%= f.submit "Resend unlock instructions" %>
+<% end %>
+
+<%= render "links" %>
\ No newline at end of file
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 062c0a4..700577b 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -1,14 +1,55 @@
-
-
-
+
+
+
Planet
- <%= stylesheet_link_tag "application", :media => "all" %>
+ <%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
-
-
-<%= yield %>
+
+
+
+
+
+ <%= image_tag("logo3.png") %>
+ <%= @page_title || "Planet Travel Site" %>
+
-
-
+
+ <% if current_user %>
+ <%= link_to current_user.name,
+ edit_user_registration_path %> |
+ <%= link_to "Sign out", destroy_user_session_path, :method => :delete %>
+ <% else %>
+ <%= link_to "Sign in", new_user_session_path %>
+ <% end %>
+
+
+
+
+ <%= link_to "Home", planet_index_path %>
+ <%= link_to "Tipos", types_path %>
+ <%= link_to "Sitios", sites_path %>
+
+ <% Type.all.each do |type| %>
+ - <%= link_to type.name, type_sites_path(type) %>
+ <% end %>
+
+ <%= link_to "Contact", planet_contact_path %>
+ <%= link_to "Sign up", new_user_registration_path if !current_user %>
+
+
+
<%= notice %>
<%= alert %>
+ <%= link_to('Index', planet_index_path) + "|" + link_to('Contact', planet_contact_path) + "|" + link_to('Ejemplo', planet_ejemplo_path)+ "|" + link_to('Autores', planet_author_path)+ "|" + link_to('Tipos', types_path) + "|" + link_to('Tipos_ordenados', ordered_index_types_path) %>
+ <%= yield %>
+
+ <%= link_to('Index', planet_index_path) + "|" + link_to('Contact', planet_contact_path) + "|" + link_to('Ejemplo', planet_ejemplo_path)+ "|" + link_to('Autores', planet_author_path)+ "|" + link_to('Tipos', types_path) + "|" + link_to('Tipos_ordenados', ordered_index_types_path) %>
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/planet/author.html.erb b/app/views/planet/author.html.erb
new file mode 100644
index 0000000..47884bb
--- /dev/null
+++ b/app/views/planet/author.html.erb
@@ -0,0 +1,32 @@
+
+
+ Autores
+
+
+
+
+ Información sobre los creadores
+
+
+ En esta página podrá encontrar varios datos sobre los creadores
+
+
+ Alberto Moreno Díaz
+ <%= image_tag('alberto.jpg') %>
+
+ - Dirección de correo: alberto.moreno.diaz@alumnos.upm.es
+ - Dirección física: C/Sin nombre 7, 9ºB, Madrid
+ - Breve currículum: estudiante de 4º curso de Ingeniería de Telecomunicación en la ETSIT.
+
+
+ Francisco José Gil García
+ <%= image_tag('francisco.jpg') %>
+
+ - Dirección de correo: fj.gil@alumnos.upm.es
+ - Dirección física: C/Con nombre 2, Bajo Derecha, Villatempujo de arriba
+ - Breve currículum: a rellenar
+
+
+ Para cualquier duda o problema no dude en contactarnos.
+
+
\ No newline at end of file
diff --git a/app/views/sites/_form.html.erb b/app/views/sites/_form.html.erb
new file mode 100644
index 0000000..abc9fec
--- /dev/null
+++ b/app/views/sites/_form.html.erb
@@ -0,0 +1,33 @@
+<%= form_for(@site) do |f| %>
+ <% if @site.errors.any? %>
+
+
<%= pluralize(@site.errors.count, "error") %> prohibited this site from being saved:
+
+
+ <% @site.errors.full_messages.each do |msg| %>
+ - <%= msg %>
+ <% end %>
+
+
+ <% end %>
+
+
+ <%= f.label :name %>
+ <%= f.text_field :name %>
+
+
+ <%= f.label :description %>
+ <%= f.text_area :description , :rows => 4 %>
+
+
+ <%= f.label :type_id %>
+ <%= f.collection_select(:type_id, Type.find(:all, :order => :name), :id, :name) %>
+
+
+ <%= f.label :image_url %>
+ <%= f.text_field :image_url %>
+
+
+ <%= f.submit %>
+
+<% end %>
diff --git a/app/views/sites/edit.html.erb b/app/views/sites/edit.html.erb
new file mode 100644
index 0000000..d46384f
--- /dev/null
+++ b/app/views/sites/edit.html.erb
@@ -0,0 +1,6 @@
+Editing site
+
+<%= render 'form' %>
+
+<%= link_to 'Show', @site %> |
+<%= link_to 'Back', sites_path %>
diff --git a/app/views/sites/index.html.erb b/app/views/sites/index.html.erb
new file mode 100644
index 0000000..ab3fb65
--- /dev/null
+++ b/app/views/sites/index.html.erb
@@ -0,0 +1,39 @@
+
+
<%= @sites == Site.all ? "Todos los sitios" : Type.find(params[:type_id]).name %>
+
+
+ <% @sites.each do |site| %>
+
+
+ |
+ <%= link_to image_tag(site.image_url, :class => 'list_image'), site %>
+ |
+
+
+
+ - <%= link_to site.name, site %>
+ - <%= truncate(strip_tags(site.description),
+ :length => 80) %>
+ <% unless site.comments.empty? %>
+ - <%= link_to 'Comentarios', site_comments_path(site) %>
+ <% end %>
+
+ |
+
+
+ <%= link_to 'Show', site %>
+ <% if site.user == current_user %>
+ <%= link_to 'Edit', edit_site_path(site) %>
+ <%= link_to 'Destroy', site,
+ :confirm => 'Are you sure?',
+ :method => :delete %>
+ <% end %>
+ |
+
+ <% end %>
+
+
+
+
+
+<%= link_to 'New site', new_site_path %>
\ No newline at end of file
diff --git a/app/views/sites/new.html.erb b/app/views/sites/new.html.erb
new file mode 100644
index 0000000..2988bdc
--- /dev/null
+++ b/app/views/sites/new.html.erb
@@ -0,0 +1,5 @@
+New site
+
+<%= render 'form' %>
+
+<%= link_to 'Back', sites_path %>
diff --git a/app/views/sites/show.html.erb b/app/views/sites/show.html.erb
new file mode 100644
index 0000000..290b1e3
--- /dev/null
+++ b/app/views/sites/show.html.erb
@@ -0,0 +1,29 @@
+
+
+
<%= @site.type.name if @site.type %>
+
+ <%= image_tag(@site.image_url, :class => 'site_image') %>
+
+
<%= @site.name %>
+
+
<%=sanitize @site.description %>
+
+
Autor:
+ <%= @site.user.name if @site.user %>
+
+ <% unless @site.comments.empty? %>
+
Comentarios:
+ <% @comments = @site.comments %>
+ <%= render(@comment) %>
+ <% end %>
+
+ <%= render 'comments/form' %>
+
+
+
+
+
+<% if @site.user == current_user %>
+ <%= link_to 'Edit', edit_site_path(@site) %> |
+<% end %>
+<%= link_to 'Back', sites_path %>
diff --git a/app/views/types/_form.html.erb b/app/views/types/_form.html.erb
index 03447aa..80284dd 100644
--- a/app/views/types/_form.html.erb
+++ b/app/views/types/_form.html.erb
@@ -17,7 +17,7 @@
<%= f.label :description %>
- <%= f.text_area :description %>
+ <%= f.text_area :description, :rows => 4 %>
<%= f.submit %>
diff --git a/app/views/types/index.html.erb b/app/views/types/index.html.erb
index 50bda49..e761359 100644
--- a/app/views/types/index.html.erb
+++ b/app/views/types/index.html.erb
@@ -1,24 +1,29 @@
-
Listing types
-
-
-
- | Name |
- Description |
- |
- |
- |
-
-
-<% @types.each do |type| %>
-
- | <%= type.name %> |
- <%= type.description %> |
- <%= link_to 'Show', type %> |
- <%= link_to 'Edit', edit_type_path(type) %> |
- <%= link_to 'Destroy', type, confirm: 'Are you sure?', method: :delete %> |
-
-<% end %>
-
+
+
Listing Types
+
+
+ <% @types.each do |type| %>
+
+
+
+
+ - <%= link_to type.name, type_sites_path(type) %>
+ - <%= truncate(strip_tags(type.description),
+ :length => 80) %>
+
+ |
+
+
+ <%= link_to 'Show', type %>
+ <%= link_to 'Edit', edit_type_path(type) %>
+ <%= link_to 'Destroy', type,
+ :confirm => 'Are you sure?',
+ :method => :delete %>
+ |
+
+ <% end %>
+
+
diff --git a/app/views/types/ordered_index.html.erb b/app/views/types/ordered_index.html.erb
new file mode 100644
index 0000000..e761359
--- /dev/null
+++ b/app/views/types/ordered_index.html.erb
@@ -0,0 +1,30 @@
+
+
Listing Types
+
+
+ <% @types.each do |type| %>
+
+
+
+
+ - <%= link_to type.name, type_sites_path(type) %>
+ - <%= truncate(strip_tags(type.description),
+ :length => 80) %>
+
+ |
+
+
+ <%= link_to 'Show', type %>
+ <%= link_to 'Edit', edit_type_path(type) %>
+ <%= link_to 'Destroy', type,
+ :confirm => 'Are you sure?',
+ :method => :delete %>
+ |
+
+ <% end %>
+
+
+
+
+
+<%= link_to 'New Type', new_type_path %>
diff --git a/config/environments/development.rb b/config/environments/development.rb
index 90121c9..4008234 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -16,6 +16,9 @@
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false
+ # introducido para devise!!!!
+ config.action_mailer.default_url_options = { :host => 'localhost:3000' }
+
# Print deprecation notices to the Rails logger
config.active_support.deprecation = :log
diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb
new file mode 100644
index 0000000..a78d7ea
--- /dev/null
+++ b/config/initializers/devise.rb
@@ -0,0 +1,223 @@
+# Use this hook to configure devise mailer, warden hooks and so forth.
+# Many of these configuration options can be set straight in your model.
+Devise.setup do |config|
+ # ==> Mailer Configuration
+ # Configure the e-mail address which will be shown in Devise::Mailer,
+ # note that it will be overwritten if you use your own mailer class with default "from" parameter.
+ config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com"
+
+ # Configure the class responsible to send e-mails.
+ # config.mailer = "Devise::Mailer"
+
+ # Automatically apply schema changes in tableless databases
+ config.apply_schema = false
+
+ # ==> ORM configuration
+ # Load and configure the ORM. Supports :active_record (default) and
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
+ # available as additional gems.
+ require 'devise/orm/active_record'
+
+ # ==> Configuration for any authentication mechanism
+ # Configure which keys are used when authenticating a user. The default is
+ # just :email. You can configure it to use [:username, :subdomain], so for
+ # authenticating a user, both parameters are required. Remember that those
+ # parameters are used only when authenticating and not when retrieving from
+ # session. If you need permissions, you should implement that in a before filter.
+ # You can also supply a hash where the value is a boolean determining whether
+ # or not authentication should be aborted when the value is not present.
+ # config.authentication_keys = [ :email ]
+
+ # Configure parameters from the request object used for authentication. Each entry
+ # given should be a request method and it will automatically be passed to the
+ # find_for_authentication method and considered in your model lookup. For instance,
+ # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
+ # The same considerations mentioned for authentication_keys also apply to request_keys.
+ # config.request_keys = []
+
+ # Configure which authentication keys should be case-insensitive.
+ # These keys will be downcased upon creating or modifying a user and when used
+ # to authenticate or find a user. Default is :email.
+ config.case_insensitive_keys = [ :email ]
+
+ # Configure which authentication keys should have whitespace stripped.
+ # These keys will have whitespace before and after removed upon creating or
+ # modifying a user and when used to authenticate or find a user. Default is :email.
+ config.strip_whitespace_keys = [ :email ]
+
+ # Tell if authentication through request.params is enabled. True by default.
+ # It can be set to an array that will enable params authentication only for the
+ # given strategies, for example, `config.params_authenticatable = [:database]` will
+ # enable it only for database (email + password) authentication.
+ # config.params_authenticatable = true
+
+ # Tell if authentication through HTTP Basic Auth is enabled. False by default.
+ # It can be set to an array that will enable http authentication only for the
+ # given strategies, for example, `config.http_authenticatable = [:token]` will
+ # enable it only for token authentication.
+ # config.http_authenticatable = false
+
+ # If http headers should be returned for AJAX requests. True by default.
+ # config.http_authenticatable_on_xhr = true
+
+ # The realm used in Http Basic Authentication. "Application" by default.
+ # config.http_authentication_realm = "Application"
+
+ # It will change confirmation, password recovery and other workflows
+ # to behave the same regardless if the e-mail provided was right or wrong.
+ # Does not affect registerable.
+ # config.paranoid = true
+
+ # By default Devise will store the user in session. You can skip storage for
+ # :http_auth and :token_auth by adding those symbols to the array below.
+ # Notice that if you are skipping storage for all authentication paths, you
+ # may want to disable generating routes to Devise's sessions controller by
+ # passing :skip => :sessions to `devise_for` in your config/routes.rb
+ config.skip_session_storage = [:http_auth]
+
+ # ==> Configuration for :database_authenticatable
+ # For bcrypt, this is the cost for hashing the password and defaults to 10. If
+ # using other encryptors, it sets how many times you want the password re-encrypted.
+ #
+ # Limiting the stretches to just one in testing will increase the performance of
+ # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
+ # a value less than 10 in other environments.
+ config.stretches = Rails.env.test? ? 1 : 10
+
+ # Setup a pepper to generate the encrypted password.
+ # config.pepper = "f807173825cac6c9c837bda6b02a30347a55bf933bb79161023a13d6827452aca8150a7940b27a4abf741e0159050a7b80787f789373c4a8b4475e1b2b3a47f6"
+
+ # ==> Configuration for :confirmable
+ # A period that the user is allowed to access the website even without
+ # confirming his account. For instance, if set to 2.days, the user will be
+ # able to access the website for two days without confirming his account,
+ # access will be blocked just in the third day. Default is 0.days, meaning
+ # the user cannot access the website without confirming his account.
+ # config.allow_unconfirmed_access_for = 2.days
+
+ # If true, requires any email changes to be confirmed (exctly the same way as
+ # initial account confirmation) to be applied. Requires additional unconfirmed_email
+ # db field (see migrations). Until confirmed new email is stored in
+ # unconfirmed email column, and copied to email column on successful confirmation.
+ config.reconfirmable = true
+
+ # Defines which key will be used when confirming an account
+ # config.confirmation_keys = [ :email ]
+
+ # ==> Configuration for :rememberable
+ # The time the user will be remembered without asking for credentials again.
+ # config.remember_for = 2.weeks
+
+ # If true, extends the user's remember period when remembered via cookie.
+ # config.extend_remember_period = false
+
+ # If true, uses the password salt as remember token. This should be turned
+ # to false if you are not using database authenticatable.
+ config.use_salt_as_remember_token = true
+
+ # Options to be passed to the created cookie. For instance, you can set
+ # :secure => true in order to force SSL only cookies.
+ # config.cookie_options = {}
+
+ # ==> Configuration for :validatable
+ # Range for password length. Default is 6..128.
+ # config.password_length = 6..128
+
+ # Email regex used to validate email formats. It simply asserts that
+ # an one (and only one) @ exists in the given string. This is mainly
+ # to give user feedback and not to assert the e-mail validity.
+ # config.email_regexp = /\A[^@]+@[^@]+\z/
+
+ # ==> Configuration for :timeoutable
+ # The time you want to timeout the user session without activity. After this
+ # time the user will be asked for credentials again. Default is 30 minutes.
+ # config.timeout_in = 30.minutes
+
+ # ==> Configuration for :lockable
+ # Defines which strategy will be used to lock an account.
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
+ # :none = No lock strategy. You should handle locking by yourself.
+ # config.lock_strategy = :failed_attempts
+
+ # Defines which key will be used when locking and unlocking an account
+ # config.unlock_keys = [ :email ]
+
+ # Defines which strategy will be used to unlock an account.
+ # :email = Sends an unlock link to the user email
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
+ # :both = Enables both strategies
+ # :none = No unlock strategy. You should handle unlocking by yourself.
+ # config.unlock_strategy = :both
+
+ # Number of authentication tries before locking an account if lock_strategy
+ # is failed attempts.
+ # config.maximum_attempts = 20
+
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
+ # config.unlock_in = 1.hour
+
+ # ==> Configuration for :recoverable
+ #
+ # Defines which key will be used when recovering the password for an account
+ # config.reset_password_keys = [ :email ]
+
+ # Time interval you can reset your password with a reset password key.
+ # Don't put a too small interval or your users won't have the time to
+ # change their passwords.
+ config.reset_password_within = 6.hours
+
+ # ==> Configuration for :encryptable
+ # Allow you to use another encryption algorithm besides bcrypt (default). You can use
+ # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
+ # :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
+ # and :restful_authentication_sha1 (then you should set stretches to 10, and copy
+ # REST_AUTH_SITE_KEY to pepper)
+ # config.encryptor = :sha512
+
+ # ==> Configuration for :token_authenticatable
+ # Defines name of the authentication token params key
+ # config.token_authentication_key = :auth_token
+
+ # ==> Scopes configuration
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
+ # "users/sessions/new". It's turned off by default because it's slower if you
+ # are using only default views.
+ # config.scoped_views = false
+
+ # Configure the default scope given to Warden. By default it's the first
+ # devise role declared in your routes (usually :user).
+ # config.default_scope = :user
+
+ # Configure sign_out behavior.
+ # Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope).
+ # The default is true, which means any logout action will sign out all active scopes.
+ # config.sign_out_all_scopes = true
+
+ # ==> Navigation configuration
+ # Lists the formats that should be treated as navigational. Formats like
+ # :html, should redirect to the sign in page when the user does not have
+ # access, but formats like :xml or :json, should return 401.
+ #
+ # If you have any extra navigational formats, like :iphone or :mobile, you
+ # should add them to the navigational formats lists.
+ #
+ # The "*/*" below is required to match Internet Explorer requests.
+ # config.navigational_formats = ["*/*", :html]
+
+ # The default HTTP method used to sign out a resource. Default is :delete.
+ config.sign_out_via = :delete
+
+ # ==> OmniAuth
+ # Add a new OmniAuth provider. Check the wiki for more information on setting
+ # up on your models and hooks.
+ # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
+
+ # ==> Warden configuration
+ # If you want to use other strategies, that are not supported by Devise, or
+ # change the failure app, you can configure them inside the config.warden block.
+ #
+ # config.warden do |manager|
+ # manager.intercept_401 = false
+ # manager.default_strategies(:scope => :user).unshift :some_external_strategy
+ # end
+end
diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml
new file mode 100644
index 0000000..73df488
--- /dev/null
+++ b/config/locales/devise.en.yml
@@ -0,0 +1,57 @@
+# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
+
+en:
+ errors:
+ messages:
+ expired: "has expired, please request a new one"
+ not_found: "not found"
+ already_confirmed: "was already confirmed, please try signing in"
+ not_locked: "was not locked"
+ not_saved:
+ one: "1 error prohibited this %{resource} from being saved:"
+ other: "%{count} errors prohibited this %{resource} from being saved:"
+
+ devise:
+ failure:
+ already_authenticated: 'You are already signed in.'
+ unauthenticated: 'You need to sign in or sign up before continuing.'
+ unconfirmed: 'You have to confirm your account before continuing.'
+ locked: 'Your account is locked.'
+ invalid: 'Invalid email or password.'
+ invalid_token: 'Invalid authentication token.'
+ timeout: 'Your session expired, please sign in again to continue.'
+ inactive: 'Your account was not activated yet.'
+ sessions:
+ signed_in: 'Signed in successfully.'
+ signed_out: 'Signed out successfully.'
+ passwords:
+ send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.'
+ updated: 'Your password was changed successfully. You are now signed in.'
+ updated_not_active: 'Your password was changed successfully.'
+ send_paranoid_instructions: "If your e-mail exists on our database, you will receive a password recovery link on your e-mail"
+ confirmations:
+ send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
+ send_paranoid_instructions: 'If your e-mail exists on our database, you will receive an email with instructions about how to confirm your account in a few minutes.'
+ confirmed: 'Your account was successfully confirmed. You are now signed in.'
+ registrations:
+ signed_up: 'Welcome! You have signed up successfully.'
+ signed_up_but_unconfirmed: 'A message with a confirmation link has been sent to your email address. Please open the link to activate your account.'
+ signed_up_but_inactive: 'You have signed up successfully. However, we could not sign you in because your account is not yet activated.'
+ signed_up_but_locked: 'You have signed up successfully. However, we could not sign you in because your account is locked.'
+ updated: 'You updated your account successfully.'
+ update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and click on the confirm link to finalize confirming your new email address."
+ destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
+ unlocks:
+ send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
+ unlocked: 'Your account has been unlocked successfully. Please sign in to continue.'
+ send_paranoid_instructions: 'If your account exists, you will receive an email with instructions about how to unlock it in a few minutes.'
+ omniauth_callbacks:
+ success: 'Successfully authorized from %{kind} account.'
+ failure: 'Could not authorize you from %{kind} because "%{reason}".'
+ mailer:
+ confirmation_instructions:
+ subject: 'Confirmation instructions'
+ reset_password_instructions:
+ subject: 'Reset password instructions'
+ unlock_instructions:
+ subject: 'Unlock Instructions'
diff --git a/config/routes.rb b/config/routes.rb
index 4cd1976..cb16cfd 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,12 +1,26 @@
Planet::Application.routes.draw do
- resources :types
+ resources :comments, :except => [ :new, :index, :show ]
+
+ devise_for :users
+
+ resources :sites do
+ resources :comments, :only => [ :index ]
+ end
+
+ resources :types do
+ get 'ordered_index', :on => :collection
+ resources :sites, :only => [ :index ] # Rutas anidadas /types/id/sites. Restringe a acción “index”
+ end
+
get "planet/index"
get "planet/contact"
get "planet/ejemplo"
+ get "planet/author"
+
# The priority is based upon order of creation:
# first created -> highest priority.
diff --git a/db/migrate/20120320100145_create_sites.rb b/db/migrate/20120320100145_create_sites.rb
new file mode 100644
index 0000000..823209a
--- /dev/null
+++ b/db/migrate/20120320100145_create_sites.rb
@@ -0,0 +1,12 @@
+class CreateSites < ActiveRecord::Migration
+ def change
+ create_table :sites do |t|
+ t.string :name
+ t.text :description
+ t.integer :type_id
+ t.string :image_url
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20120328230302_devise_create_users.rb b/db/migrate/20120328230302_devise_create_users.rb
new file mode 100644
index 0000000..540333c
--- /dev/null
+++ b/db/migrate/20120328230302_devise_create_users.rb
@@ -0,0 +1,49 @@
+class DeviseCreateUsers < ActiveRecord::Migration
+ def change
+ create_table(:users) do |t|
+ ## Database authenticatable
+ t.string :email, :null => false, :default => ""
+ t.string :encrypted_password, :null => false, :default => ""
+
+ ## Recoverable
+ t.string :reset_password_token
+ t.datetime :reset_password_sent_at
+
+ ## Rememberable
+ t.datetime :remember_created_at
+
+ ## Trackable
+ t.integer :sign_in_count, :default => 0
+ t.datetime :current_sign_in_at
+ t.datetime :last_sign_in_at
+ t.string :current_sign_in_ip
+ t.string :last_sign_in_ip
+
+ ## Encryptable
+ # t.string :password_salt
+
+ ## Confirmable
+ # t.string :confirmation_token
+ # t.datetime :confirmed_at
+ # t.datetime :confirmation_sent_at
+ # t.string :unconfirmed_email # Only if using reconfirmable
+
+ ## Lockable
+ # t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
+ # t.string :unlock_token # Only if unlock strategy is :email or :both
+ # t.datetime :locked_at
+
+ ## Token authenticatable
+ # t.string :authentication_token
+
+
+ t.timestamps
+ end
+
+ add_index :users, :email, :unique => true
+ add_index :users, :reset_password_token, :unique => true
+ # add_index :users, :confirmation_token, :unique => true
+ # add_index :users, :unlock_token, :unique => true
+ # add_index :users, :authentication_token, :unique => true
+ end
+end
diff --git a/db/migrate/20120329060322_user_name.rb b/db/migrate/20120329060322_user_name.rb
new file mode 100644
index 0000000..14ba63a
--- /dev/null
+++ b/db/migrate/20120329060322_user_name.rb
@@ -0,0 +1,13 @@
+class UserName < ActiveRecord::Migration
+ def up
+ change_table :users do |t| # añade la columna name a la tabla sites
+ t.column :name, :string
+ end
+ end
+
+ def down
+ change_table :users do |t|
+ t.remove :name
+ end
+ end
+end
diff --git a/db/migrate/20120329080433_user_sites.rb b/db/migrate/20120329080433_user_sites.rb
new file mode 100644
index 0000000..37bbc3b
--- /dev/null
+++ b/db/migrate/20120329080433_user_sites.rb
@@ -0,0 +1,13 @@
+class UserSites < ActiveRecord::Migration
+ def up
+ change_table :sites do |t| # añade la columna user_id a la tabla sites
+ t.column :user_id, :integer
+ end
+ end
+
+ def down
+ change_table :sites do |t|
+ t.remove :user_id
+ end
+ end
+end
diff --git a/db/migrate/20120410171102_create_comments.rb b/db/migrate/20120410171102_create_comments.rb
new file mode 100644
index 0000000..36d0b14
--- /dev/null
+++ b/db/migrate/20120410171102_create_comments.rb
@@ -0,0 +1,11 @@
+class CreateComments < ActiveRecord::Migration
+ def change
+ create_table :comments do |t|
+ t.string :comment
+ t.integer :user_id
+ t.integer :site_id
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 8084ffc..f971d40 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,25 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120317231537) do
+ActiveRecord::Schema.define(:version => 20120410171102) 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"
+ t.text "description"
+ t.integer "type_id"
+ t.string "image_url"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ t.integer "user_id"
+ end
create_table "types", :force => true do |t|
t.string "name"
@@ -20,4 +38,23 @@
t.datetime "updated_at", :null => false
end
+ create_table "users", :force => true do |t|
+ t.string "email", :default => "", :null => false
+ t.string "encrypted_password", :default => "", :null => false
+ t.string "reset_password_token"
+ t.datetime "reset_password_sent_at"
+ t.datetime "remember_created_at"
+ t.integer "sign_in_count", :default => 0
+ t.datetime "current_sign_in_at"
+ t.datetime "last_sign_in_at"
+ t.string "current_sign_in_ip"
+ t.string "last_sign_in_ip"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ t.string "name"
+ end
+
+ add_index "users", ["email"], :name => "index_users_on_email", :unique => true
+ add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
+
end
diff --git a/db/seeds.rb b/db/seeds.rb
index ca6a311..2aadd13 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -1,20 +1,64 @@
-# This file should contain all the record creation needed to seed the database with its default values.
-# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
+# This file should contain all the record creation needed to seed the
+# database with its default values. The data can then be loaded with
+# the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
-Type.create(
+Type.delete_all
+
+tm = Type.create(
name: 'Monumento',
description: 'Edificio de interes turistico o artistico')
-Type.create(
+tn = Type.create(
name: 'Naturaleza',
description: 'Lugar al aire libre de interes natural o de recreo')
-Type.create(
+tr = Type.create(
name: 'Ruina',
description: 'Lugar o resto de interes arquelogico')
+
+Site.delete_all
+
+
+Site.create(
+ name: 'Pedriza',
+ description: 'Magnifico valle al norte de Madrid en el Macizo Central',
+ type_id: tn.id,
+ image_url: 'pedriza.png')
+
+Site.create(
+ name: 'Catedral de Florencia',
+ description: 'Catedral de la ciudad de Florencia con la que se inicia el Renacimiento',
+ type_id: tm.id,
+ image_url: 'florencia.png')
+
+Site.create(
+ name: 'Jardin de Lineo',
+ description: 'Jardin de la ciudad sueca de Uppsala donde el famoso naturalista enia su coleccion de plantas',
+ type_id: tn.id,
+ image_url: 'arbol1.png')
+
+Site.create(
+ name: 'Reichstag',
+ description: 'Parlamento aleman en la ciudad de Berlin',
+ type_id: tm.id,
+ image_url: 'reichstag.png')
+
+Site.create(
+ name: 'Pergamo',
+ description: 'Puerta del mercado de la antigua ciudad griega de Pergamo del museo arquelogico de Berlin',
+ type_id: tr.id,
+ image_url: 'pergamo.png')
+
+# user_id esta protegido con "attr_protected" y debe inicializarse asi,
+# Site.create(....) levantaria una excepcipón al intentar inicializarlo
+Site.all.each { |obj| obj.user_id = 1 ; obj.save }
+
+
+
+
diff --git a/test/fixtures/comments.yml b/test/fixtures/comments.yml
new file mode 100644
index 0000000..29c9999
--- /dev/null
+++ b/test/fixtures/comments.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+one:
+ comment: MyString
+ user_id: 1
+ site_id: 1
+
+two:
+ comment: MyString
+ user_id: 1
+ site_id: 1
diff --git a/test/fixtures/sites.yml b/test/fixtures/sites.yml
new file mode 100644
index 0000000..0b20b0a
--- /dev/null
+++ b/test/fixtures/sites.yml
@@ -0,0 +1,13 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+one:
+ name: MyString
+ description: MyText
+ type_id: 1
+ image_url: MyString
+
+two:
+ name: MyString
+ description: MyText
+ type_id: 1
+ image_url: MyString
diff --git a/test/fixtures/types.yml b/test/fixtures/types.yml
index 53b2c6a..8683ea9 100644
--- a/test/fixtures/types.yml
+++ b/test/fixtures/types.yml
@@ -7,3 +7,6 @@ one:
two:
name: MyString
description: MyText
+
+
+# Podriamos añadir nuevos datos de inicialización, que se referencian como
# -> types(:monumento) types(:naturaleza)
monumento:
name: Monumento
description: “Edificio o construcción de valor historico”
naturaleza:
name: Naturaleza
description: “Lugar al aire libre de interés natural”
\ No newline at end of file
diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml
new file mode 100644
index 0000000..c63aac0
--- /dev/null
+++ b/test/fixtures/users.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+# This model initially had no columns defined. If you add columns to the
+# model remove the '{}' from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one: {}
+# column: value
+#
+two: {}
+# column: value
diff --git a/test/functional/comments_controller_test.rb b/test/functional/comments_controller_test.rb
new file mode 100644
index 0000000..b2b500c
--- /dev/null
+++ b/test/functional/comments_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class CommentsControllerTest < ActionController::TestCase
+ setup do
+ @comment = comments(:one)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:comments)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create comment" do
+ assert_difference('Comment.count') do
+ post :create, comment: @comment.attributes
+ end
+
+ assert_redirected_to comment_path(assigns(:comment))
+ end
+
+ test "should show comment" do
+ get :show, id: @comment
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @comment
+ assert_response :success
+ end
+
+ test "should update comment" do
+ put :update, id: @comment, comment: @comment.attributes
+ assert_redirected_to comment_path(assigns(:comment))
+ end
+
+ test "should destroy comment" do
+ assert_difference('Comment.count', -1) do
+ delete :destroy, id: @comment
+ end
+
+ assert_redirected_to comments_path
+ end
+end
diff --git a/test/functional/planet_controller_test.rb b/test/functional/planet_controller_test.rb
index 88229e0..da96118 100644
--- a/test/functional/planet_controller_test.rb
+++ b/test/functional/planet_controller_test.rb
@@ -11,4 +11,16 @@ class PlanetControllerTest < ActionController::TestCase
assert_response :success
end
+ test "should get author" do
+ get :author
+ # Invoca “get” en acción “author”
+ assert_response :success # código HTTP: “200 OK”
+ end
+
+ test "should get ejemplo" do
+ get :ejemplo
+ # Invoca “get” en acción “ejemplo”
+ assert_response :success # código HTTP: “200 OK”
+ end
+
end
diff --git a/test/functional/sites_controller_test.rb b/test/functional/sites_controller_test.rb
new file mode 100644
index 0000000..beac6d1
--- /dev/null
+++ b/test/functional/sites_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class SitesControllerTest < ActionController::TestCase
+ setup do
+ @site = sites(:one)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:sites)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create site" do
+ assert_difference('Site.count') do
+ post :create, site: @site.attributes
+ end
+
+ assert_redirected_to site_path(assigns(:site))
+ end
+
+ test "should show site" do
+ get :show, id: @site
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @site
+ assert_response :success
+ end
+
+ test "should update site" do
+ put :update, id: @site, site: @site.attributes
+ assert_redirected_to site_path(assigns(:site))
+ end
+
+ test "should destroy site" do
+ assert_difference('Site.count', -1) do
+ delete :destroy, id: @site
+ end
+
+ assert_redirected_to sites_path
+ end
+end
diff --git a/test/functional/types_controller_test.rb b/test/functional/types_controller_test.rb
index 2e1931b..d8b0dc1 100644
--- a/test/functional/types_controller_test.rb
+++ b/test/functional/types_controller_test.rb
@@ -3,6 +3,10 @@
class TypesControllerTest < ActionController::TestCase
setup do
@type = types(:one)
+ @update = { # @update: parametros diferentes
+ :name => 'AnotherType',
+ :description => 'AnotherText',
+ }
end
test "should get index" do
@@ -18,7 +22,7 @@ class TypesControllerTest < ActionController::TestCase
test "should create type" do
assert_difference('Type.count') do
- post :create, type: @type.attributes
+ post :create, type: @update
end
assert_redirected_to type_path(assigns(:type))
@@ -35,7 +39,7 @@ class TypesControllerTest < ActionController::TestCase
end
test "should update type" do
- put :update, id: @type, type: @type.attributes
+ put :update, id: @type, type: @update
assert_redirected_to type_path(assigns(:type))
end
diff --git a/test/unit/comment_test.rb b/test/unit/comment_test.rb
new file mode 100644
index 0000000..b6d6131
--- /dev/null
+++ b/test/unit/comment_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class CommentTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/unit/helpers/comments_helper_test.rb b/test/unit/helpers/comments_helper_test.rb
new file mode 100644
index 0000000..2518c16
--- /dev/null
+++ b/test/unit/helpers/comments_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class CommentsHelperTest < ActionView::TestCase
+end
diff --git a/test/unit/helpers/sites_helper_test.rb b/test/unit/helpers/sites_helper_test.rb
new file mode 100644
index 0000000..0e92edf
--- /dev/null
+++ b/test/unit/helpers/sites_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class SitesHelperTest < ActionView::TestCase
+end
diff --git a/test/unit/site_test.rb b/test/unit/site_test.rb
new file mode 100644
index 0000000..34931c1
--- /dev/null
+++ b/test/unit/site_test.rb
@@ -0,0 +1,17 @@
+require 'test_helper'
+
+class SiteTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+
+ # site creado sin atributos es invalido y genera errores
+ test "Site attributes must not be empty" do
+ site = Site.new
+ assert site.invalid? # Test pasa si validación no pasa
+ assert site.errors[:name].any?
+ assert not(site.errors[:description].any?)
+ assert site.errors[:type_id].any?
+ assert site.errors[:image_url].any?
+ end
+end
diff --git a/test/unit/type_test.rb b/test/unit/type_test.rb
index 0ce1172..7c92595 100644
--- a/test/unit/type_test.rb
+++ b/test/unit/type_test.rb
@@ -4,4 +4,12 @@ class TypeTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
+
+ # type creado sin atributos es invalido y genera errores
+ test "Type attributes must not be empty" do
+ type = Type.new
+ assert type.invalid? # Test pasa si validación no pasa
+ assert type.errors[:name].any?
+ assert type.errors[:description].any?
+ end
end
diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb
new file mode 100644
index 0000000..82f61e0
--- /dev/null
+++ b/test/unit/user_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class UserTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end