<%= notice %>
<%= alert %>
+<%= notice %>
<%= alert %>
<%= yield %>diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 index 28a4c21..e751592 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,7 @@ # ignore al .DS_store files of MAC OSX .DS_Store + +# ignore paperclip installation files +public/system +.project diff --git a/Gemfile b/Gemfile old mode 100644 new mode 100755 index ca448a6..e8051e0 --- a/Gemfile +++ b/Gemfile @@ -9,6 +9,8 @@ gem 'sqlite3' gem 'devise' +gem 'paperclip' + # Gems used only for assets and not required # in production environments by default. group :assets do diff --git a/Gemfile.lock b/Gemfile.lock old mode 100644 new mode 100755 index 36f623e..6247569 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -32,6 +32,7 @@ GEM bcrypt-ruby (3.0.1) builder (3.0.0) cleditor_rails (0.0.3) + cocaine (0.2.1) coffee-rails (3.2.2) coffee-script (>= 2.2.0) railties (~> 3.2.0) @@ -61,6 +62,12 @@ GEM mime-types (1.17.2) multi_json (1.1.0) orm_adapter (0.0.7) + paperclip (3.0.2) + activemodel (>= 3.0.0) + activerecord (>= 3.0.0) + activesupport (>= 3.0.0) + cocaine (>= 0.0.2) + mime-types polyglot (0.3.3) rack (1.4.1) rack-cache (1.2) @@ -117,6 +124,7 @@ DEPENDENCIES coffee-rails (~> 3.2.1) devise jquery-rails + paperclip rails (= 3.2.2) sass-rails (~> 3.2.3) sqlite3 diff --git a/README.rdoc b/README.rdoc old mode 100644 new mode 100755 diff --git a/Rakefile b/Rakefile old mode 100644 new mode 100755 diff --git a/app/assets/images/arbol1.png b/app/assets/images/arbol1.png old mode 100644 new mode 100755 diff --git a/app/assets/images/florencia.png b/app/assets/images/florencia.png old mode 100644 new mode 100755 diff --git a/app/assets/images/foto.png b/app/assets/images/foto.png new file mode 100755 index 0000000..b3d8db1 Binary files /dev/null and b/app/assets/images/foto.png differ diff --git a/app/assets/images/logo3.png b/app/assets/images/logo3.png old mode 100644 new mode 100755 diff --git a/app/assets/images/pedriza.png b/app/assets/images/pedriza.png old mode 100644 new mode 100755 diff --git a/app/assets/images/pedriza2-m.png b/app/assets/images/pedriza2-m.png old mode 100644 new mode 100755 diff --git a/app/assets/images/pergamo.png b/app/assets/images/pergamo.png old mode 100644 new mode 100755 diff --git a/app/assets/images/rails.png b/app/assets/images/rails.png old mode 100644 new mode 100755 diff --git a/app/assets/images/reichstag.png b/app/assets/images/reichstag.png old mode 100644 new mode 100755 diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js old mode 100644 new mode 100755 diff --git a/app/assets/javascripts/comentarios.js.coffee b/app/assets/javascripts/comentarios.js.coffee new file mode 100755 index 0000000..7615679 --- /dev/null +++ b/app/assets/javascripts/comentarios.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/planet.js.coffee b/app/assets/javascripts/planet.js.coffee old mode 100644 new mode 100755 diff --git a/app/assets/javascripts/sites.js.coffee b/app/assets/javascripts/sites.js.coffee old mode 100644 new mode 100755 diff --git a/app/assets/javascripts/trips.js.coffee b/app/assets/javascripts/trips.js.coffee old mode 100644 new mode 100755 diff --git a/app/assets/javascripts/types.js.coffee b/app/assets/javascripts/types.js.coffee old mode 100644 new mode 100755 diff --git a/app/assets/javascripts/visits.js.coffee b/app/assets/javascripts/visits.js.coffee old mode 100644 new mode 100755 diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css old mode 100644 new mode 100755 diff --git a/app/assets/stylesheets/comentarios.css.scss b/app/assets/stylesheets/comentarios.css.scss new file mode 100755 index 0000000..494c101 --- /dev/null +++ b/app/assets/stylesheets/comentarios.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the comentarios 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 old mode 100644 new mode 100755 index c6334b0..c0b7953 --- a/app/assets/stylesheets/planet.css +++ b/app/assets/stylesheets/planet.css @@ -97,6 +97,7 @@ margin-left: 9em; /* Ajuste de borde izquierdo */ padding-top: 4ex; padding-left: 2em; + padding-bottom: 1em; background: white; } @@ -113,6 +114,16 @@ color: #bfb; font-size: small; } + +#bottom { + padding: 1em; + text-align: center; +} + +#bottom a { + color: #bfb; + font-size: small; +} /* END:mainlayout */ /* An entry in the store catalog (no utilizados de momento) */ @@ -161,3 +172,15 @@ font-weight: bold; margin-right: 2em; } + +#map_canvas { + width: 300px; + height: 300px; + float: right; + margin-right: 100px; +} + +#author-photo { + float: right; + margin-right: 100px; +} diff --git a/app/assets/stylesheets/planet.css.scss b/app/assets/stylesheets/planet.css.scss old mode 100644 new mode 100755 diff --git a/app/assets/stylesheets/planet.css~ b/app/assets/stylesheets/planet.css~ new file mode 100755 index 0000000..464074a --- /dev/null +++ b/app/assets/stylesheets/planet.css~ @@ -0,0 +1,187 @@ +/* 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; +} + +#banner .user { + float: right; + color: #bfb; + font-size: small; +} + +#columns { + background: #446; +} + +#main { + margin-left: 9em; /* Ajuste de borde izquierdo */ + padding-top: 4ex; + padding-left: 2em; + padding-bottom: 1em; + background: white; +} + +#side { + float: left; + padding-top: 1em; + padding-left: 1em; + padding-bottom: 1em; + width: 8em; /* Ajuste de borde izquierdo */ + background: #446; +} + +#side a { + color: #bfb; + font-size: small; +} + +#bottom { + padding: 1em; + text-align: center; +} + +#bottom 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; +} + +#map_canvas { + width: 300px; + height: 300px; + float: right; + margin-right: 100px; +} + +#author-photo { + float: left; + position: absolute; + margin-left: 500px; +} diff --git a/app/assets/stylesheets/scaffolds.css.scss b/app/assets/stylesheets/scaffolds.css.scss old mode 100644 new mode 100755 diff --git a/app/assets/stylesheets/sites.css.scss b/app/assets/stylesheets/sites.css.scss old mode 100644 new mode 100755 diff --git a/app/assets/stylesheets/trips.css.scss b/app/assets/stylesheets/trips.css.scss old mode 100644 new mode 100755 diff --git a/app/assets/stylesheets/types.css.scss b/app/assets/stylesheets/types.css.scss old mode 100644 new mode 100755 diff --git a/app/assets/stylesheets/visits.css.scss b/app/assets/stylesheets/visits.css.scss old mode 100644 new mode 100755 diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb old mode 100644 new mode 100755 diff --git a/app/controllers/comentarios_controller.rb b/app/controllers/comentarios_controller.rb new file mode 100755 index 0000000..8282b9f --- /dev/null +++ b/app/controllers/comentarios_controller.rb @@ -0,0 +1,181 @@ +class ComentariosController < ApplicationController + + # authenticate_user! ejecuta acción solo si sesión existe + before_filter :authenticate_user!, :except => [ :index, :show ] + + # GET /comentarios + # GET /comentarios.json + def index + if params[:site_id].nil? or params[:site_id].empty? + @comentarios = Comentario.all # path: /sites + else + @comentarios = Site.find(params[:site_id]).comentarios # path: /sites/id/comentarios + end + respond_to do |format| + format.html # index.html.erb + format.json { render json: @comentarios } + end + end + + # GET /comentarios/1 + # GET /comentarios/1.json + def show + @comentario = Comentario.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @comentario } + end + end + + # GET /comentarios/new + # GET /comentarios/new.json + def new + @comentario = current_user.comentarios.build # crea sitio vacio asociado a current_user + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @comentario } + end + end + + # GET /comentarios/1/edit + def edit + @comentario = current_user.comentarios.find(params[:id]) # busca solo en sitios asociados a current_user + end + + # POST /comentarios + # POST /comentarios.json + def create + @comentario = current_user.comentarios.build(params[:comentario]) # Asigna solo si sitio asociado a current_user + + respond_to do |format| + if @comentario.save + format.html { redirect_to @comentario, notice: 'Comentario was successfully created.' } + format.json { render json: @comentario, status: :created, location: @comentario } + else + format.html { render action: "new" } + format.json { render json: @comentario.errors, status: :unprocessable_entity } + end + end + end + + # PUT /comentarios/1 + # PUT /comentarios/1.json + def update + @comentario = current_user.comentarios.find(params[:id]) # busca solo en sitios asociados a current_user + + respond_to do |format| + if @comentario.update_attributes(params[:comentario]) + format.html { redirect_to @comentario, notice: 'Comentario was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @comentario.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /comentarios/1 + # DELETE /comentarios/1.json + def destroy + @comentario = current_user.comentarios.find(params[:id]) # busca solo en sitios asociados a current_user + @comentario.destroy + + respond_to do |format| + format.html { redirect_to comentarios_url } + format.json { head :no_content } + end + end +end + + +#class ComentariosController < ApplicationController +# +# # authenticate_user! ejecuta acción solo si sesión existe +# before_filter :authenticate_user!, :except => [ :index, :show ] +# +# # GET /comentarios +# # GET /comentarios.json +# def index +# @comentarios = Comentario.all +# +# respond_to do |format| +# format.html # index.html.erb +# format.json { render json: @comentarios } +# end +# end +# +# # GET /comentarios/1 +# # GET /comentarios/1.json +# def show +# @comentario = Comentario.find(params[:id]) +# +# respond_to do |format| +# format.html # show.html.erb +# format.json { render json: @comentario } +# end +# end +# +# # GET /comentarios/new +# # GET /comentarios/new.json +# def new +# @comentario = Comentario.new +# +# respond_to do |format| +# format.html # new.html.erb +# format.json { render json: @comentario } +# end +# end +# +# # GET /comentarios/1/edit +# def edit +# @comentario = Comentario.find(params[:id]) +# end +# +# # POST /comentarios +# # POST /comentarios.json +# def create +# @comentario = Comentario.new(params[:comentario]) +# +# respond_to do |format| +# if @comentario.save +# format.html { redirect_to @comentario, notice: 'Comentario was successfully #created.' } +# format.json { render json: @comentario, status: :created, location: @comentario } +# else +# format.html { render action: "new" } +# format.json { render json: @comentario.errors, status: :unprocessable_entity } +# end +# end +# end +# +# # PUT /comentarios/1 +# # PUT /comentarios/1.json +# def update +# @comentario = Comentario.find(params[:id]) +# +# respond_to do |format| +# if @comentario.update_attributes(params[:comentario]) +# format.html { redirect_to @comentario, notice: 'Comentario was successfully #updated.' } +# format.json { head :no_content } +# else +# format.html { render action: "edit" } +# format.json { render json: @comentario.errors, status: :unprocessable_entity } +# end +# end +# end +# +# # DELETE /comentarios/1 +# # DELETE /comentarios/1.json +# def destroy +# @comentario = Comentario.find(params[:id]) +# @comentario.destroy +# +# respond_to do |format| +# format.html { redirect_to comentarios_url } +# format.json { head :no_content } +# end +# end +#end + + diff --git a/app/controllers/comentarios_controller.rb~ b/app/controllers/comentarios_controller.rb~ new file mode 100755 index 0000000..8282b9f --- /dev/null +++ b/app/controllers/comentarios_controller.rb~ @@ -0,0 +1,181 @@ +class ComentariosController < ApplicationController + + # authenticate_user! ejecuta acción solo si sesión existe + before_filter :authenticate_user!, :except => [ :index, :show ] + + # GET /comentarios + # GET /comentarios.json + def index + if params[:site_id].nil? or params[:site_id].empty? + @comentarios = Comentario.all # path: /sites + else + @comentarios = Site.find(params[:site_id]).comentarios # path: /sites/id/comentarios + end + respond_to do |format| + format.html # index.html.erb + format.json { render json: @comentarios } + end + end + + # GET /comentarios/1 + # GET /comentarios/1.json + def show + @comentario = Comentario.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @comentario } + end + end + + # GET /comentarios/new + # GET /comentarios/new.json + def new + @comentario = current_user.comentarios.build # crea sitio vacio asociado a current_user + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @comentario } + end + end + + # GET /comentarios/1/edit + def edit + @comentario = current_user.comentarios.find(params[:id]) # busca solo en sitios asociados a current_user + end + + # POST /comentarios + # POST /comentarios.json + def create + @comentario = current_user.comentarios.build(params[:comentario]) # Asigna solo si sitio asociado a current_user + + respond_to do |format| + if @comentario.save + format.html { redirect_to @comentario, notice: 'Comentario was successfully created.' } + format.json { render json: @comentario, status: :created, location: @comentario } + else + format.html { render action: "new" } + format.json { render json: @comentario.errors, status: :unprocessable_entity } + end + end + end + + # PUT /comentarios/1 + # PUT /comentarios/1.json + def update + @comentario = current_user.comentarios.find(params[:id]) # busca solo en sitios asociados a current_user + + respond_to do |format| + if @comentario.update_attributes(params[:comentario]) + format.html { redirect_to @comentario, notice: 'Comentario was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @comentario.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /comentarios/1 + # DELETE /comentarios/1.json + def destroy + @comentario = current_user.comentarios.find(params[:id]) # busca solo en sitios asociados a current_user + @comentario.destroy + + respond_to do |format| + format.html { redirect_to comentarios_url } + format.json { head :no_content } + end + end +end + + +#class ComentariosController < ApplicationController +# +# # authenticate_user! ejecuta acción solo si sesión existe +# before_filter :authenticate_user!, :except => [ :index, :show ] +# +# # GET /comentarios +# # GET /comentarios.json +# def index +# @comentarios = Comentario.all +# +# respond_to do |format| +# format.html # index.html.erb +# format.json { render json: @comentarios } +# end +# end +# +# # GET /comentarios/1 +# # GET /comentarios/1.json +# def show +# @comentario = Comentario.find(params[:id]) +# +# respond_to do |format| +# format.html # show.html.erb +# format.json { render json: @comentario } +# end +# end +# +# # GET /comentarios/new +# # GET /comentarios/new.json +# def new +# @comentario = Comentario.new +# +# respond_to do |format| +# format.html # new.html.erb +# format.json { render json: @comentario } +# end +# end +# +# # GET /comentarios/1/edit +# def edit +# @comentario = Comentario.find(params[:id]) +# end +# +# # POST /comentarios +# # POST /comentarios.json +# def create +# @comentario = Comentario.new(params[:comentario]) +# +# respond_to do |format| +# if @comentario.save +# format.html { redirect_to @comentario, notice: 'Comentario was successfully #created.' } +# format.json { render json: @comentario, status: :created, location: @comentario } +# else +# format.html { render action: "new" } +# format.json { render json: @comentario.errors, status: :unprocessable_entity } +# end +# end +# end +# +# # PUT /comentarios/1 +# # PUT /comentarios/1.json +# def update +# @comentario = Comentario.find(params[:id]) +# +# respond_to do |format| +# if @comentario.update_attributes(params[:comentario]) +# format.html { redirect_to @comentario, notice: 'Comentario was successfully #updated.' } +# format.json { head :no_content } +# else +# format.html { render action: "edit" } +# format.json { render json: @comentario.errors, status: :unprocessable_entity } +# end +# end +# end +# +# # DELETE /comentarios/1 +# # DELETE /comentarios/1.json +# def destroy +# @comentario = Comentario.find(params[:id]) +# @comentario.destroy +# +# respond_to do |format| +# format.html { redirect_to comentarios_url } +# format.json { head :no_content } +# end +# end +#end + + diff --git a/app/controllers/planet_controller.rb b/app/controllers/planet_controller.rb old mode 100644 new mode 100755 diff --git a/app/controllers/sites_controller.rb b/app/controllers/sites_controller.rb old mode 100644 new mode 100755 index ed3047d..886db23 --- a/app/controllers/sites_controller.rb +++ b/app/controllers/sites_controller.rb @@ -2,6 +2,8 @@ class SitesController < ApplicationController # authenticate_user! ejecuta acción solo si sesión existe before_filter :authenticate_user!, :except => [ :index, :show ] + # Definimos un filtro que activa “count_visit” al finalizar la acción show. + after_filter :count_visita, :only => :show # GET /sites # GET /sites.json @@ -87,4 +89,10 @@ def destroy format.json { head :no_content } end end + + private + def count_visita + @site.increment!(:visitas) + end + end diff --git a/app/controllers/sites_controller.rb~ b/app/controllers/sites_controller.rb~ new file mode 100755 index 0000000..886db23 --- /dev/null +++ b/app/controllers/sites_controller.rb~ @@ -0,0 +1,98 @@ +class SitesController < ApplicationController + + # authenticate_user! ejecuta acción solo si sesión existe + before_filter :authenticate_user!, :except => [ :index, :show ] + # Definimos un filtro que activa “count_visit” al finalizar la acción show. + after_filter :count_visita, :only => :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]) + + 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 + + private + def count_visita + @site.increment!(:visitas) + end + +end diff --git a/app/controllers/trips_controller.rb b/app/controllers/trips_controller.rb old mode 100644 new mode 100755 diff --git a/app/controllers/types_controller.rb b/app/controllers/types_controller.rb old mode 100644 new mode 100755 index da826f4..0b0457c --- a/app/controllers/types_controller.rb +++ b/app/controllers/types_controller.rb @@ -10,6 +10,18 @@ def index end end + # GET /types + # GET /types.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/1 # GET /types/1.json def show diff --git a/app/controllers/types_controller.rb~ b/app/controllers/types_controller.rb~ new file mode 100755 index 0000000..da826f4 --- /dev/null +++ b/app/controllers/types_controller.rb~ @@ -0,0 +1,83 @@ +class TypesController < ApplicationController + # GET /types + # GET /types.json + def index + @types = Type.all + + 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 + @type = Type.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @type } + end + end + + # GET /types/new + # GET /types/new.json + def new + @type = Type.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @type } + end + end + + # GET /types/1/edit + def edit + @type = Type.find(params[:id]) + end + + # POST /types + # POST /types.json + def create + @type = Type.new(params[:type]) + + respond_to do |format| + if @type.save + format.html { redirect_to @type, notice: 'Type was successfully created.' } + format.json { render json: @type, status: :created, location: @type } + else + format.html { render action: "new" } + format.json { render json: @type.errors, status: :unprocessable_entity } + end + end + end + + # PUT /types/1 + # PUT /types/1.json + def update + @type = Type.find(params[:id]) + + respond_to do |format| + if @type.update_attributes(params[:type]) + format.html { redirect_to @type, notice: 'Type was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @type.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /types/1 + # DELETE /types/1.json + def destroy + @type = Type.find(params[:id]) + @type.destroy + + respond_to do |format| + format.html { redirect_to types_url } + format.json { head :no_content } + end + end +end diff --git a/app/controllers/visits_controller.rb b/app/controllers/visits_controller.rb old mode 100644 new mode 100755 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb old mode 100644 new mode 100755 diff --git a/app/helpers/comentarios_helper.rb b/app/helpers/comentarios_helper.rb new file mode 100755 index 0000000..a8f928b --- /dev/null +++ b/app/helpers/comentarios_helper.rb @@ -0,0 +1,2 @@ +module ComentariosHelper +end diff --git a/app/helpers/planet_helper.rb b/app/helpers/planet_helper.rb old mode 100644 new mode 100755 diff --git a/app/helpers/sites_helper.rb b/app/helpers/sites_helper.rb old mode 100644 new mode 100755 diff --git a/app/helpers/trips_helper.rb b/app/helpers/trips_helper.rb old mode 100644 new mode 100755 diff --git a/app/helpers/types_helper.rb b/app/helpers/types_helper.rb old mode 100644 new mode 100755 diff --git a/app/helpers/visits_helper.rb b/app/helpers/visits_helper.rb old mode 100644 new mode 100755 diff --git a/app/mailers/.gitkeep b/app/mailers/.gitkeep old mode 100644 new mode 100755 diff --git a/app/models/.gitkeep b/app/models/.gitkeep old mode 100644 new mode 100755 diff --git a/app/models/comentario.rb b/app/models/comentario.rb new file mode 100755 index 0000000..471e904 --- /dev/null +++ b/app/models/comentario.rb @@ -0,0 +1,6 @@ +class Comentario < ActiveRecord::Base + belongs_to :site + belongs_to :user + + attr_protected :user_id +end diff --git a/app/models/comentario.rb~ b/app/models/comentario.rb~ new file mode 100755 index 0000000..8b39078 --- /dev/null +++ b/app/models/comentario.rb~ @@ -0,0 +1,4 @@ +class Comentario < ActiveRecord::Base + belongs_to :site + belongs_to :user +end diff --git a/app/models/site.rb b/app/models/site.rb old mode 100644 new mode 100755 index 7a3bd34..39848d4 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -3,11 +3,13 @@ class Site < ActiveRecord::Base belongs_to :user has_many :visits has_many :trips, :through => :visits + has_many :comentarios + has_attached_file :image # 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 + validates :name, :type_id, :presence => true # campo obligatorio end diff --git a/app/models/site.rb~ b/app/models/site.rb~ new file mode 100755 index 0000000..54ca9d0 --- /dev/null +++ b/app/models/site.rb~ @@ -0,0 +1,14 @@ +class Site < ActiveRecord::Base + belongs_to :type + belongs_to :user + has_many :visits + has_many :trips, :through => :visits + has_many :comentarios + + + # 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/trip.rb b/app/models/trip.rb old mode 100644 new mode 100755 diff --git a/app/models/type.rb b/app/models/type.rb old mode 100644 new mode 100755 diff --git a/app/models/user.rb b/app/models/user.rb old mode 100644 new mode 100755 index 35b8159..9b60370 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,6 +1,7 @@ class User < ActiveRecord::Base has_many :sites + has_many :comentarios has_many :trips # Include default devise modules. Others available are: diff --git a/app/models/user.rb~ b/app/models/user.rb~ new file mode 100755 index 0000000..9b60370 --- /dev/null +++ b/app/models/user.rb~ @@ -0,0 +1,16 @@ +class User < ActiveRecord::Base + + has_many :sites + has_many :comentarios + has_many :trips + + # 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/models/visit.rb b/app/models/visit.rb old mode 100644 new mode 100755 diff --git a/app/views/comentarios/_form.html.erb b/app/views/comentarios/_form.html.erb new file mode 100755 index 0000000..4f67d52 --- /dev/null +++ b/app/views/comentarios/_form.html.erb @@ -0,0 +1,30 @@ +<%= form_for(@comentario) do |f| %> + <% if @comentario.errors.any? %> +
+
|
+
+
+
+ <% if comentario.user == current_user %>
+ <%= link_to 'Edit', edit_comentario_path(comentario) %> + <%= link_to 'Destroy', comentario, confirm: 'Are you sure?', method: :delete %> + <% end %> + |
+
| <%= comentario.user.name if comentario.user %> | + +
+
|
+
+
+
+
+
+ <% if comentario.user == current_user %>
+ <%= link_to 'Edit', edit_comentario_path(comentario) %> + <%= link_to 'Destroy', comentario, confirm: 'Are you sure?', method: :delete %> + <% end %> + |
+
<%= notice %>
+ ++ Coment: + <%= @comentario.coment %> +
+ ++ Autor: + + <%= @comentario.user.name if @comentario.user %> +
+ ++ Site: + + <%= @comentario.site.name if @comentario.site %> +
+ + +<%= link_to 'Edit', edit_comentario_path(@comentario) %> | +<%= link_to 'Back', comentarios_path %> | +<%= link_to 'Destroy', @comentario, :confirm => 'Are you sure?', :method => :delete %> diff --git a/app/views/comentarios/show.html.erb~ b/app/views/comentarios/show.html.erb~ new file mode 100755 index 0000000..c7a6dec --- /dev/null +++ b/app/views/comentarios/show.html.erb~ @@ -0,0 +1,25 @@ +<%= notice %>
+ ++ Coment: + <%= @comentario.coment %> +
+ ++ Autor: + + <%= @comentario.user.name if @comentario.user %> +
+ ++ Site: + + <%= @comentario.site.name if @comentario.site %> +
+ + +<%= link_to 'Edit', edit_comentario_path(@comentario) %> | +<%= link_to 'Back', comentarios_path %> +<%= link_to 'Destroy', @comentario, + :confirm => 'Are you sure?', + :method => :delete %> diff --git a/app/views/devise/_links.erb b/app/views/devise/_links.erb old mode 100644 new mode 100755 diff --git a/app/views/devise/confirmations/new.html.erb b/app/views/devise/confirmations/new.html.erb old mode 100644 new mode 100755 diff --git a/app/views/devise/mailer/confirmation_instructions.html.erb b/app/views/devise/mailer/confirmation_instructions.html.erb old mode 100644 new mode 100755 diff --git a/app/views/devise/mailer/reset_password_instructions.html.erb b/app/views/devise/mailer/reset_password_instructions.html.erb old mode 100644 new mode 100755 diff --git a/app/views/devise/mailer/unlock_instructions.html.erb b/app/views/devise/mailer/unlock_instructions.html.erb old mode 100644 new mode 100755 diff --git a/app/views/devise/passwords/edit.html.erb b/app/views/devise/passwords/edit.html.erb old mode 100644 new mode 100755 diff --git a/app/views/devise/passwords/new.html.erb b/app/views/devise/passwords/new.html.erb old mode 100644 new mode 100755 diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb old mode 100644 new mode 100755 diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb old mode 100644 new mode 100755 diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb old mode 100644 new mode 100755 diff --git a/app/views/devise/unlocks/new.html.erb b/app/views/devise/unlocks/new.html.erb old mode 100644 new mode 100755 diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb old mode 100644 new mode 100755 index 82edd70..cc90224 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -6,7 +6,12 @@ <%= javascript_include_tag "application" %> <%= csrf_meta_tags %> - + + @@ -14,22 +19,41 @@