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

Carlos González Merino y Elena Moreno Alonso #5

Open
wants to merge 3 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
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ GEM
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.4)
sqlite3 (1.3.4-x86-mingw32)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
Expand All @@ -107,6 +108,7 @@ GEM

PLATFORMS
ruby
x86-mingw32

DEPENDENCIES
coffee-rails (~> 3.1.1)
Expand Down
Binary file added app/assets/images/Carlos.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/Thumbs.db
Binary file not shown.
Binary file added app/assets/images/elena.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/assets/javascripts/trips.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
48 changes: 48 additions & 0 deletions app/assets/stylesheets/planet.css
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,48 @@
}



#trip_list table {
border-collapse: collapse;
}

#trip_list table tr td {
padding: 5px;
vertical-align: top;
}

#trip_list .list_name {
width: 40%;
margin: 0;
color: #244;
font-weight: bold;
font-size: larger;
text-align: center;
}

#trip_list .list_order {
width: 10%;
margin: 0;
color: #244;
font-size: larger;
text-align: center;
}

#trip_list .list_actions {
font-size: x-small;
text-align: right;
padding-left: 1em;
}

#trip_list .list_line_even {
background: #a8b8f8;
}

#trip_list .list_line_odd {
background: #88b0f8;
}


/* START:mainlayout */
/* Styles for main page */

Expand All @@ -78,6 +120,12 @@
text-align: center;
}

#banner a { color: #669999; }
a:visited { color: #66CCCC; }
a:hover { color: #0033CC;
background-color:#D8D8D8; }


#banner img {
float: left;
padding-left: 10px;
Expand Down
3 changes: 3 additions & 0 deletions app/assets/stylesheets/trips.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// 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/
9 changes: 1 addition & 8 deletions app/controllers/planet_controller.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
class PlanetController < ApplicationController
def index
end

def contact
end

# GET /planet/ejemplo
def ejemplo
def author
end

end
22 changes: 11 additions & 11 deletions app/controllers/sites_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ class SitesController < ApplicationController
# GET /sites
# GET /sites.json
def index

if params[:type_id].nil? or params[:type_id].empty?
@sites = Site.all
else
@sites = Type.find(params[:type_id]).sites
end
@trip = Trip.new

respond_to do |format|
format.html # index.html.erb
format.json { render json: @sites }
format.json { render :json=> @sites }
end
end

Expand All @@ -22,7 +22,7 @@ def show

respond_to do |format|
format.html # show.html.erb
format.json { render json: @site }
format.json { render :json=> @site }
end
end

Expand All @@ -33,7 +33,7 @@ def new

respond_to do |format|
format.html # new.html.erb
format.json { render json: @site }
format.json { render :json=> @site }
end
end

Expand All @@ -49,11 +49,11 @@ def create

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 }
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 }
format.html { render :action=> "new" }
format.json { render :json=> @site.errors, :status=> :unprocessable_entity }
end
end
end
Expand All @@ -65,11 +65,11 @@ def update

respond_to do |format|
if @site.update_attributes(params[:site])
format.html { redirect_to @site, notice: 'Site was successfully updated.' }
format.html { redirect_to @site, :notice=> 'Site was successfully updated.' }
format.json { head :ok }
else
format.html { render action: "edit" }
format.json { render json: @site.errors, status: :unprocessable_entity }
format.html { render :action=> "edit" }
format.json { render :json=> @site.errors, :status=> :unprocessable_entity }
end
end
end
Expand Down
120 changes: 120 additions & 0 deletions app/controllers/trips_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
class TripsController < ApplicationController
# GET /trips
# GET /trips.json
def index
@trips = Trip.all

respond_to do |format|
format.html # index.html.erb
format.json { render json: @trips }
end
end

# GET /trips/1
# GET /trips/1.json
def show
@trip = Trip.find(params[:id])

respond_to do |format|
format.html # show.html.erb
format.json { render json: @trip }
end
end

# GET /trips/new
# GET /trips/new.json
def new
@trip = Trip.new

respond_to do |format|
format.html # new.html.erb
format.json { render json: @trip }
end
end

# GET /trips/1/edit
def edit
@trip = Trip.find(params[:id])
end

# POST /trips
# POST /trips.json
def create
@trip = Trip.new(params[:trip])

if !Trip.find(:last, :order => 'trip_id').nil?
@trip.trip_id = Trip.find(:last, :order => 'trip_id').trip_id + 1
end

respond_to do |format|
if @trip.save
format.html { redirect_to @trip, notice: 'Trip was successfully created.' }
format.json { render json: @trip, status: :created, location: @trip }
else
format.html { render action: "new" }
format.json { render json: @trip.errors, status: :unprocessable_entity }
end
end

end

# PUT /trips/1
# PUT /trips/1.json
def update
@trip = Trip.find(params[:id])
# tid1 identificador de posicion viejo
tid1 = @trip.trip_id

respond_to do |format|
if @trip.update_attributes(params[:trip])

@trips = Trip.find(:all, :order => 'trip_id')

@trips.each do |trip|
# Si la posicion nueva esta por encima de la vieja, baja los que estuvieran entre ellas
if @trip.trip_id < tid1
if (trip.trip_id < tid1) && (trip.trip_id >= @trip.trip_id) && (trip.site_id != @trip.site_id)
trip.trip_id = trip.trip_id + 1
trip.save
end
end
# Si la posicion nueva esta por debajo de la vieja, sube los que estuvieran entre ellas
if @trip.trip_id > tid1
if (trip.trip_id > tid1) && (trip.trip_id <= @trip.trip_id) && (trip.site_id != @trip.site_id)
trip.trip_id = trip.trip_id - 1
trip.save
end
end
end

format.html { redirect_to @trip, notice: 'Trip was successfully created.' }
format.json { head :ok }
else
format.html { render action: "edit" }
format.json { render json: @trip.errors, status: :unprocessable_entity }
end
end
end

# DELETE /trips/1
# DELETE /trips/1.json
def destroy
@trip = Trip.find(params[:id])
# tid es la posicion borrada
tid = @trip.trip_id
@trip.destroy
@trips = Trip.find(:all, :order => 'trip_id')

@trips.each do |trip|
if trip.trip_id > tid
trip.trip_id = trip.trip_id - 1
trip.save
end
end

respond_to do |format|
format.html { redirect_to trips_url }
format.json { head :ok }
end
end
end
2 changes: 2 additions & 0 deletions app/helpers/trips_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module TripsHelper
end
2 changes: 2 additions & 0 deletions app/models/site.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
class Site < ActiveRecord::Base
belongs_to :type
belongs_to :trip
validates_presence_of :name, :message => "must be provided"
end
3 changes: 3 additions & 0 deletions app/models/trip.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Trip < ActiveRecord::Base
has_many :sites
end
32 changes: 26 additions & 6 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -1,26 +1,46 @@
<!DOCTYPE html>
<html>

<head>
<title>Planet</title>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>

<body id="planet">

<div id="banner">
<%= image_tag("logo3.png") %>
<%= @page_title || "Planet Travel Site" %>
<%= @page_title || "Planet Travel Site" %><br/><!-- <label id="code.depot.e.title"/> -->
<%= link_to "Home", planet_index_path %>
<%= link_to "Contacto", planet_contact_path %>
<%= link_to "Autor", planet_author_path %>
<%= link_to "Ejemplo", planet_ejemplo_path %>
</div>

<div id="columns">
<div id="side">
<%= link_to "Home", planet_index_path %><br />
<%= link_to "Tipos", types_path %><br />
<%= link_to "Sitios", sites_path %><br />
<%= link_to "Contact", planet_contact_path %>
<%= link_to "Sitios", sites_path %><br />
<%= link_to "Viajes", trips_path %> <br />
<%= link_to "Contacto", planet_contact_path %><br />
<%= link_to "Autor", planet_author_path %><br />
<%= link_to "Ejemplo", planet_ejemplo_path %>

</div>
<div id="main">
<%= yield %>
<div id="main">
<%= yield %>
</div>
</div>

<div id="banner">
<%= link_to "Home", planet_index_path %>
<%= link_to "Contacto", planet_contact_path %>
<%= link_to "Autor", planet_author_path %>
<%= link_to "Ejemplo", planet_ejemplo_path %>
</div>
</div>

</body>
</html>
13 changes: 13 additions & 0 deletions app/views/planet/author.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<h1>Elena Moreno Alonso </h1>
<%= image_tag('elena.png') %>
<p>Madrid</p>
<p>[email protected]</p>
<p>Estudiante de ingeniería de Telecomunicaciones</p>


<h1>Carlos González merino</h1>
<%= image_tag('Carlos.PNG') %>

<p>Madrid</p>
<p> [email protected]</p>
<p>Estudiante de ingeniería de Telecomunicaciones</p>
9 changes: 8 additions & 1 deletion app/views/sites/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
<tr class="<%= cycle('list_line_odd', 'list_line_even') %>">

<td>
<%= link_to image_tag(site.image_url, :class => 'list_image'), site %>
<% if site.image_url != "" %>
<%= link_to image_tag(site.image_url, :class => 'list_image'), site %>
<% end %>
</td>

<td class="list_description">
Expand All @@ -23,6 +25,11 @@
<%= link_to 'Destroy', site,
:confirm => 'Are you sure?',
:method => :delete %>
<%= form_for(@trip, remote: true) do |f| %>
<% f.number_field :trip_id, :value => 1, :hidden => true %>
<% f.number_field :site_id, :value => site.id, :hidden => true %>
<%= f.submit "Add site" %>
<% end %>
</td>
</tr>
<% end %>
Expand Down
Loading