Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entrega Final Rails Planet #62

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

# Ignore the default SQLite database.
/db/*.sqlite3

/db/*.sql
# Ignore all logfiles and tempfiles.
/log/*.log
/tmp
Expand All @@ -19,4 +19,4 @@

# ignore paperclip installation files
public/system
.project
.project
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ group :development, :test do
end

group :production do
gem 'pg'
gem 'pg'
end


Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ GEM
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.18)
multi_json (1.3.1)
multi_json (1.2.0)
orm_adapter (0.0.7)
paperclip (3.0.2)
activemodel (>= 3.0.0)
Expand Down
Binary file added app/assets/images/author.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,29 @@
//= require cleditor
//= require jquery_ujs
//= require_tree .

function createMap(lat,lng,zoom) {

// Store my position (“y=mylat”, “x=mylong”) in variable “lating”
var latlng = new google.maps.LatLng(lat, lng);
// Define my Google Maps options in variable “myOptions”
var myOptions = {
zoom: zoom, // Define scale
center: latlng, // Define map center
mapTypeId: google.maps.MapTypeId.ROADMAP // tipo Roadmad, Satellite, Terrain, Hybrid
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
return map;
}

function addMarkerToMap(map,lat,lng,title) {
// Store my position (“y=mylat”, “x=mylong”) in variable “lating”
var latlng = new google.maps.LatLng(lat, lng);
// Add marker in Google Maps “map” in position defined by “lating”
var marker = new google.maps.Marker({
position: latlng,
map: map,
title: title
});
return false;
}
12 changes: 12 additions & 0 deletions app/assets/javascripts/site_map.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function siteMapFunction() {

var lat = $("#latitude").html();
var lng = $("#longitude").html();
var zoom = parseInt($("#zoom").html());

map = createMap(lat,lng,zoom);
addMarkerToMap(map,lat,lng);

return false;
}

17 changes: 17 additions & 0 deletions app/assets/javascripts/trip_map.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function tripMapFunction() {
// Creates a default map
map = createMap(0,0,1);

// Get the values for each
$(".list_parameters").each(function(index,element) {

var lat = $("#latitude",$(this)).html();
var lng = $("#longitude",$(this)).html();
var title = $("#name",$(this)).html();

addMarkerToMap(map,lat,lng,title);
});

return false;
}

11 changes: 11 additions & 0 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,14 @@
*= require cleditor
*= require_tree .
*/

.search_box {
font-size:15px;
float:right;
color: black;
padding-left:15px;
}

#min_visits {
width:70%;
}
10 changes: 10 additions & 0 deletions app/assets/stylesheets/planet.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* Global styles (no utilizados de momento) */


#planet #notice {
color: #000;
border: 2px solid red;
Expand All @@ -16,6 +17,12 @@
border-bottom: 3px dotted #77d;
}

/* Types */

.types_list li{
margin-left:-25px;
}

/* Styles for products/index */

#site_list table {
Expand Down Expand Up @@ -167,3 +174,6 @@
text-indent: 70%;
}

.hidden {
display:none;
}
6 changes: 5 additions & 1 deletion app/assets/stylesheets/planet.css.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Place all the styles related to the planet controller here.
// Place all the styles related to the Planet controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

#search_visits {
width:70%;
}
6 changes: 6 additions & 0 deletions app/assets/stylesheets/sites.css.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// 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/

.site_map {
float:right;
width: 500px;
height: 300px;
}
5 changes: 5 additions & 0 deletions app/assets/stylesheets/trips.css.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// Place all the styles related to the trips controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

.trip_map {
width: 900px;
height: 500px;
}
9 changes: 9 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
class ApplicationController < ActionController::Base
protect_from_forgery

before_filter :get_types

private #-----------------------

def get_types
@types = Type.find(:all)
end

end
38 changes: 36 additions & 2 deletions app/controllers/planet_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,42 @@ def index
# Método que define una acción vacía del controlador
def contact
end
# Método que define una acción vacía del controlador

def author
end


def ejemplo
end


def minsearch
if params[:min_visits].nil? || params[:min_visits].empty? || Integer(params[:min_visits]) < 2
flash[:notice] = "Busqueda no realizada informar numero minimo"
else
@sites = Site.find(:all,
:conditions => ["visitas > ?", params[:min_visits]])
if @sites.nil?
flash[:notice] = "Busqueda no resulto viajes con el numero minimo de viajes"
else
flash[:notice] = "Busqueda realizada con suceso"
end
end
end

def topsearch
if params[:query].nil? || params[:query].empty? || params[:query].length < 3
flash[:notice] = "Busqueda no realizada informar numero minimo"
else
@sites = Site.find(:all,
:conditions => ["name LIKE ? OR description LIKE ?", "%"+params[:query]+"%", "%"+params[:query]+"%"])
@trips = Trip.find(:all,
:conditions => ["name LIKE ? OR description LIKE ?", "%"+params[:query]+"%", "%"+params[:query]+"%"])
if (@sites.nil?||@sites.empty?) && (@trips.nil?||@trips.empty?)
flash[:notice] = "Busqueda no resulto viajes con el numero minimo de viajes"
else
flash[:notice] = "Busqueda realizada con suceso"
end
end
end

end
4 changes: 3 additions & 1 deletion app/controllers/sites_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ class SitesController < ApplicationController
def index
if params[:type_id].nil? or params[:type_id].empty?
@sites = Site.all # path: /types
else
@page_title = 'Todos los Sitios'
else
@sites = Type.find(params[:type_id]).sites # path: /types/id/sites
@page_title = Type.find(params[:type_id]).name
end
respond_to do |format|
format.html # index.html.erb
Expand Down
9 changes: 9 additions & 0 deletions app/controllers/types_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ def index
format.json { render json: @types }
end
end

def ordered
@types = Type.find(:all, :order => :name)

respond_to do |format|
format.html # ordered.html.erb
format.json { render json: @types }
end
end

# GET /types/1
# GET /types/1.json
Expand Down
4 changes: 3 additions & 1 deletion app/models/site.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
class Site < ActiveRecord::Base

belongs_to :type

belongs_to :user
has_many :visits
has_many :trips, :through => :visits
has_attached_file :image


# Debe estar protegido para evitar accesos indeseados
attr_protected :user_id

# Se añaden estas definiciones
validates :name, :type_id, :presence => true # campo obligatorio

end
5 changes: 3 additions & 2 deletions app/models/type.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
class Type < ActiveRecord::Base
has_many :sites


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
6 changes: 6 additions & 0 deletions app/views/layouts/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div id="search_box_visits">
<form id="searchbox" action="">
<input id="search" type="text" placeholder="Type here">
<input id="submit" type="submit" value="Go">
</form>
<div>
Loading