diff --git a/Gemfile.lock b/Gemfile.lock index 3b96e7c..aebe3a0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -62,12 +62,15 @@ GEM mime-types (1.17.2) multi_json (1.1.0) orm_adapter (0.0.7) +<<<<<<< HEAD +======= paperclip (2.4.5) activerecord (>= 2.3.0) activesupport (>= 2.3.2) cocaine (>= 0.0.2) mime-types pg (0.13.2) +>>>>>>> Entrega6/master polyglot (0.3.3) rack (1.4.1) rack-cache (1.2) diff --git a/app/assets/images/Javi.jpg b/app/assets/images/Javi.jpg new file mode 100644 index 0000000..ebf050c Binary files /dev/null and b/app/assets/images/Javi.jpg differ diff --git a/app/assets/images/Lara.JPG b/app/assets/images/Lara.JPG new file mode 100644 index 0000000..d48d025 Binary files /dev/null and b/app/assets/images/Lara.JPG differ diff --git a/app/assets/images/Lara.jpg b/app/assets/images/Lara.jpg new file mode 100644 index 0000000..d48d025 Binary files /dev/null and b/app/assets/images/Lara.jpg differ diff --git a/app/assets/images/foto.jpg b/app/assets/images/foto.jpg new file mode 100644 index 0000000..263b4bc Binary files /dev/null and b/app/assets/images/foto.jpg differ diff --git a/app/assets/stylesheets/planet.css b/app/assets/stylesheets/planet.css index ead053a..d538df4 100644 --- a/app/assets/stylesheets/planet.css +++ b/app/assets/stylesheets/planet.css @@ -16,6 +16,11 @@ border-bottom: 3px dotted #77d; } +#planet h3 { + font: 120% sans-serif; + color: #226; +} + /* Styles for products/index */ #site_list table { @@ -90,29 +95,46 @@ } #columns { - background: #446; + } + #main { - margin-left: 9em; /* Ajuste de borde izquierdo */ + margin-left: 2em; /* Ajuste de borde izquierdo */ + margin-right: 2em; /* Ajuste de borde izquierdo */ padding-top: 4ex; - padding-left: 2em; background: white; } -#side { - float: left; - padding-top: 1em; - padding-left: 1em; - padding-bottom: 1em; - width: 8em; /* Ajuste de borde izquierdo */ + +#footer { background: #446; } -#side a { +#footer a { + background: #446; + padding-left: 2em; color: #bfb; font-size: small; } +#footer a:hover { + background: #446; + color: #fff; + font-size: small; +} + +#leftauthor{ + width: 49%; + float: left; + margin-right: 5px; +} +#rightauthor{ + width: 49%; + float: right; +margin-right: 5px; +} + + /* END:mainlayout */ /* An entry in the store catalog (no utilizados de momento) */ diff --git a/app/controllers/planet_controller.rb b/app/controllers/planet_controller.rb index be7ac0a..007f9e4 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 index 57e0611..835f2db 100644 --- a/app/controllers/sites_controller.rb +++ b/app/controllers/sites_controller.rb @@ -1,9 +1,13 @@ class SitesController < ApplicationController +<<<<<<< HEAD + before_filter :authenticate_user!, :except => [ :index, :show ] +======= # authenticate_user! ejecuta acción solo si sesión existe before_filter :authenticate_user!, :except => [ :index, :show ] after_filter :count_visita, :only => :show +>>>>>>> Entrega6/master # GET /sites # GET /sites.json def index @@ -33,7 +37,11 @@ def show # GET /sites/new.json def new @site = current_user.sites.build # crea sitio vacio asociado a current_user +<<<<<<< HEAD + +======= +>>>>>>> Entrega6/master respond_to do |format| format.html # new.html.erb format.json { render json: @site } @@ -42,14 +50,22 @@ def new # GET /sites/1/edit def edit +<<<<<<< HEAD + @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user +======= @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user +>>>>>>> Entrega6/master end # POST /sites # POST /sites.json def create @site = current_user.sites.build(params[:site]) # Asigna solo si sitio asociado a current_user +<<<<<<< HEAD + +======= +>>>>>>> Entrega6/master respond_to do |format| if @site.save format.html { redirect_to @site, notice: 'Site was successfully created.' } @@ -64,8 +80,13 @@ def create # PUT /sites/1 # PUT /sites/1.json def update +<<<<<<< HEAD + @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user + +======= @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user +>>>>>>> Entrega6/master respond_to do |format| if @site.update_attributes(params[:site]) format.html { redirect_to @site, notice: 'Site was successfully updated.' } @@ -80,7 +101,11 @@ def update # DELETE /sites/1 # DELETE /sites/1.json def destroy +<<<<<<< HEAD + @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user +======= @site = current_user.sites.find(params[:id]) # busca solo en sitios asociados a current_user +>>>>>>> Entrega6/master @site.destroy respond_to do |format| diff --git a/app/controllers/types_controller.rb b/app/controllers/types_controller.rb index da826f4..5551db6 100644 --- a/app/controllers/types_controller.rb +++ b/app/controllers/types_controller.rb @@ -80,4 +80,15 @@ def destroy format.json { head :no_content } 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 end diff --git a/app/models/site.rb b/app/models/site.rb index 2b2f99a..3ee8e05 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -1,6 +1,10 @@ class Site < ActiveRecord::Base belongs_to :type belongs_to :user +<<<<<<< HEAD + + attr_protected :user_id +======= has_many :visits has_many :trips, :through => :visits has_attached_file :image @@ -11,4 +15,5 @@ class Site < ActiveRecord::Base # Se añaden estas definiciones validates :name, :type_id, :presence => true # campo obligatorio +>>>>>>> Entrega6/master end diff --git a/app/models/user.rb b/app/models/user.rb index 35b8159..fe9a231 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,15 +1,25 @@ class User < ActiveRecord::Base +<<<<<<< HEAD +======= has_many :sites has_many :trips +>>>>>>> Entrega6/master # Include default devise modules. Others available are: # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable +<<<<<<< HEAD + # Setup accessible (or protected) attributes for your model + attr_accessible :name, :email, :password, :password_confirmation, :remember_me + + has_many :sites +======= validates_presence_of :name # Setup accessible (or protected) attributes for your model attr_accessible :name, :email, :password, :password_confirmation, :remember_me +>>>>>>> Entrega6/master end diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 3d2a882..935f5df 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -3,7 +3,14 @@ <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %> <%= devise_error_messages! %> +<<<<<<< HEAD +
<%= f.label :name %>
+ <%= f.text_field :name %>
+ +
<%= f.label :email %>
+=======

<%= f.label :name %>
<%= f.text_field :name %>

<%= f.label :email %>
+>>>>>>> Entrega6/master <%= f.email_field :email %>
<%= f.label :password %> (leave blank if you don't want to change it)
diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index 79a8c31..f40abff 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -3,7 +3,13 @@ <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %> <%= devise_error_messages! %> +<<<<<<< HEAD +
<%= f.label :name %>
+ <%= f.text_field :name %>
+ +=======

<%= f.label :name %>
<%= f.text_field :name %>

+>>>>>>> Entrega6/master
<%= f.label :email %>
<%= f.email_field :email %>
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 82edd70..8a38d0d 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -13,6 +13,37 @@ + +
+ +
+

<%= notice %>

+

<%= alert %>

+ <%= yield %> +======= <%= @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 %>
@@ -29,7 +60,19 @@

<%= notice %>

<%= alert %>

<%= yield %> +>>>>>>> Entrega6/master
+ - \ 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..5ac8db1 --- /dev/null +++ b/app/views/planet/author.html.erb @@ -0,0 +1 @@ +

Authors:

This site was created by:

Lara Lorna Jimenez Jimenez

Dirección: Calle Paradisia nº38 Las Rozas 28230 Madrid

E-mail: lara.jjimenez@alumnos.upm.es

<%= image_tag('Lara.jpg') %>

Becaria del Grupo de Sistemas Inteligentes (GSI)
Estudiante de 4º curso de Ingeniería Superior de Telecomunicaciones (ETSIT)

Javier Espinosa

Dirección: Calle Arturo Soria nº134 Madrid

E-mail: javierespinosagar@gmail.com

<%= image_tag('Javi.jpg') %>

Estudiante de Ingeniería Superior de Telecomunicaciones (2007-Ahora)
Becario del Grupo de Sistemas Inteligentes (GSI) desde 2011


Feel free to contact us at any time.

\ No newline at end of file diff --git a/app/views/planet/index.html.erb b/app/views/planet/index.html.erb index bbee722..9b8ec21 100644 --- a/app/views/planet/index.html.erb +++ b/app/views/planet/index.html.erb @@ -1 +1 @@ -

Wecome to the Planet Travel Site

This site gathers information of touristic sites from all over the world and should help you to organize your trips and your holidays.

<%= image_tag('pedriza2-m.png') %>

Feel free to use it for your convenience and pleasure.

\ No newline at end of file +

Wecome to the Planet Travel Site

This site gathers information of touristic sites from all over the world and should help you to organize your trips and your holidays.

<%= image_tag('foto.jpg') %>

Feel free to use it for your convenience and pleasure.

\ No newline at end of file diff --git a/app/views/sites/index.html.erb b/app/views/sites/index.html.erb index b8e4cae..5c76b51 100644 --- a/app/views/sites/index.html.erb +++ b/app/views/sites/index.html.erb @@ -19,11 +19,21 @@ <%= link_to 'Show', site %>
+<<<<<<< HEAD + <% if site.user == current_user %> + <%= link_to 'Edit', edit_site_path(site) %>
+ <%= link_to 'Destroy', site, + :confirm => 'Are you sure?', + :method => :delete %> + <% end %> + +======= <% if site.user == current_user %> <%= link_to 'Edit', edit_site_path(site) %>
<%= link_to 'Destroy', site, :confirm => 'Are you sure?', :method => :delete %> <% end %> +>>>>>>> Entrega6/master <% end %> @@ -31,4 +41,4 @@
-<%= link_to 'New site', new_site_path %> \ No newline at end of file +<%= link_to 'New site', new_site_path %> diff --git a/app/views/sites/show.html.erb b/app/views/sites/show.html.erb index 01a5417..e46bf99 100644 --- a/app/views/sites/show.html.erb +++ b/app/views/sites/show.html.erb @@ -1,5 +1,5 @@ -
- +
+

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

<%= image_tag(@site.image.url, :class => 'site_image') %> @@ -7,13 +7,28 @@

<%= @site.name %>

<%=sanitize @site.description %>

+ +

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

+<<<<<<< HEAD + <% if @site.user == current_user %> +=======

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

+>>>>>>> Entrega6/master
Visitas: <%= @site.visitas %>

+<<<<<<< HEAD +<%= link_to 'Edit', edit_site_path(@site) %> | +<% end %> +<%= link_to 'Back', sites_path %> + +

+======= <% if @site.user == current_user %> <%= link_to 'Edit', edit_site_path(@site) %> | <% end %> <%= link_to 'Back', sites_path %> +>>>>>>> Entrega6/master diff --git a/app/views/types/index.html.erb b/app/views/types/index.html.erb index e761359..91f71b3 100644 --- a/app/views/types/index.html.erb +++ b/app/views/types/index.html.erb @@ -10,6 +10,7 @@
<%= link_to type.name, type_sites_path(type) %>
<%= truncate(strip_tags(type.description), :length => 80) %>
+
Modified: <%= type.updated_at %>
diff --git a/app/views/types/ordered_index.html.erb b/app/views/types/ordered_index.html.erb new file mode 100644 index 0000000..18218d7 --- /dev/null +++ b/app/views/types/ordered_index.html.erb @@ -0,0 +1,31 @@ +
+

Listing Types ordered by Name:

+ + + <% @types.each do |type| %> + + + + + + + <% end %> +
+
+
<%= link_to type.name, type_sites_path(type) %>
+
<%= truncate(strip_tags(type.description), + :length => 80) %>
+
Modified: <%= 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 %> diff --git a/app/views/types/show.html.erb b/app/views/types/show.html.erb index 98b32e7..167cc74 100644 --- a/app/views/types/show.html.erb +++ b/app/views/types/show.html.erb @@ -10,6 +10,10 @@ <%= @type.description %>

+

+ Last Modified: + <%= @type.updated_at %> +

<%= link_to 'Edit', edit_type_path(@type) %> | <%= link_to 'Back', types_path %> diff --git a/config/environments/development.rb b/config/environments/development.rb index 4008234..2d21b75 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -37,4 +37,6 @@ # Expands the lines which load the assets config.assets.debug = true + + config.action_mailer.default_url_options = { :host => 'localhost:3000' } end diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index a78d7ea..3613d76 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -85,7 +85,11 @@ config.stretches = Rails.env.test? ? 1 : 10 # Setup a pepper to generate the encrypted password. +<<<<<<< HEAD + # config.pepper = "29992e857c0cd6eac4641a3f092979da6286d956672f22e83385ddcc7dc8d71a2af6ae93dad7db07554834ea8b54f46a61eef2f98d31c9ef3e4cc8f969682648" +======= # config.pepper = "f807173825cac6c9c837bda6b02a30347a55bf933bb79161023a13d6827452aca8150a7940b27a4abf741e0159050a7b80787f789373c4a8b4475e1b2b3a47f6" +>>>>>>> Entrega6/master # ==> Configuration for :confirmable # A period that the user is allowed to access the website even without diff --git a/config/routes.rb b/config/routes.rb index 29d3c86..461495e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,12 +1,17 @@ Planet::Application.routes.draw do +<<<<<<< HEAD +======= resources :visits resources :trips +>>>>>>> Entrega6/master devise_for :users resources :sites + + get "types/ordered_index" resources :types do # Rutas anidadas /types/id/sites..., resources :sites, :only => [ :index ] # Restringe a acción “index” @@ -18,6 +23,12 @@ get "planet/ejemplo" + get "planet/author" + + delete "/users/sign_out" + + + # The priority is based upon order of creation: # first created -> highest priority. diff --git a/db/migrate/20120413135634_devise_create_users.rb b/db/migrate/20120413135634_devise_create_users.rb new file mode 100644 index 0000000..540333c --- /dev/null +++ b/db/migrate/20120413135634_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/20120413140418_user_name.rb b/db/migrate/20120413140418_user_name.rb new file mode 100644 index 0000000..92d357c --- /dev/null +++ b/db/migrate/20120413140418_user_name.rb @@ -0,0 +1,14 @@ +class UserName < ActiveRecord::Migration + def up + change_table :users do |t| + t.column :name,:string + end + end + + def down + change_table :users do |t| + t.remove :name + end + end + +end diff --git a/db/migrate/20120413142521_user_sites.rb b/db/migrate/20120413142521_user_sites.rb new file mode 100644 index 0000000..1a8b07e --- /dev/null +++ b/db/migrate/20120413142521_user_sites.rb @@ -0,0 +1,13 @@ +class UserSites < ActiveRecord::Migration + def up + change_table :sites do |t| + t.column :user_id,:integer + end + end + + def down + change_table :sites do |t| + t.column :user_id + end + end +end diff --git a/db/schema.rb b/db/schema.rb index e6aa66f..b89522d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,11 @@ # # It's strongly recommended to check this file into your version control system. +<<<<<<< HEAD +ActiveRecord::Schema.define(:version => 20120413142521) do +======= ActiveRecord::Schema.define(:version => 20120411160519) do +>>>>>>> Entrega6/master create_table "sites", :force => true do |t| t.string "name" @@ -35,6 +39,7 @@ t.integer "user_id" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false + t.integer "user_id" end create_table "types", :force => true do |t| @@ -63,6 +68,8 @@ 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 +<<<<<<< HEAD +======= create_table "visits", :force => true do |t| t.integer "trip_id" t.integer "site_id" @@ -71,4 +78,5 @@ t.datetime "updated_at", :null => false end +>>>>>>> Entrega6/master end diff --git a/localhost:3000 b/localhost:3000 new file mode 100644 index 0000000..e69de29 diff --git a/script/rails b/script/rails old mode 100755 new mode 100644 diff --git a/test/functional/planet_controller_test.rb b/test/functional/planet_controller_test.rb index 88229e0..d4ceedf 100644 --- a/test/functional/planet_controller_test.rb +++ b/test/functional/planet_controller_test.rb @@ -11,4 +11,13 @@ class PlanetControllerTest < ActionController::TestCase assert_response :success end + test "should get ejemplo" do + get :ejemplo + assert_response :success + end + + test "should get author" do + get :author + assert_response :success + end end