Skip to content

Commit

Permalink
commit proyecto2
Browse files Browse the repository at this point in the history
  • Loading branch information
ralfsaldana committed Mar 17, 2012
1 parent 3c719bd commit fac5033
Show file tree
Hide file tree
Showing 18 changed files with 374 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/assets/javascripts/cursos.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/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/cursos.css.scss
@@ -0,0 +1,3 @@
// Place all the styles related to the Cursos controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
56 changes: 56 additions & 0 deletions app/assets/stylesheets/scaffolds.css.scss
@@ -0,0 +1,56 @@
body {
background-color: #fff;
color: #333;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 13px;
line-height: 18px; }

p, ol, ul, td {
font-family: verdana, arial, helvetica, sans-serif;
font-size: 13px;
line-height: 18px; }

pre {
background-color: #eee;
padding: 10px;
font-size: 11px; }

a {
color: #000;
&:visited {
color: #666; }
&:hover {
color: #fff;
background-color: #000; } }

div {
&.field, &.actions {
margin-bottom: 10px; } }

#notice {
color: green; }

.field_with_errors {
padding: 2px;
background-color: red;
display: table; }

#error_explanation {
width: 450px;
border: 2px solid red;
padding: 7px;
padding-bottom: 0;
margin-bottom: 20px;
background-color: #f0f0f0;
h2 {
text-align: left;
font-weight: bold;
padding: 5px 5px 5px 15px;
font-size: 12px;
margin: -7px;
margin-bottom: 0px;
background-color: #c00;
color: #fff; }
ul li {
font-size: 12px;
list-style: square; } }
83 changes: 83 additions & 0 deletions app/controllers/cursos_controller.rb
@@ -0,0 +1,83 @@
class CursosController < ApplicationController
# GET /cursos
# GET /cursos.json
def index
@cursos = Curso.all

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

# GET /cursos/1
# GET /cursos/1.json
def show
@curso = Curso.find(params[:id])

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

# GET /cursos/new
# GET /cursos/new.json
def new
@curso = Curso.new

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

# GET /cursos/1/edit
def edit
@curso = Curso.find(params[:id])
end

# POST /cursos
# POST /cursos.json
def create
@curso = Curso.new(params[:curso])

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

# PUT /cursos/1
# PUT /cursos/1.json
def update
@curso = Curso.find(params[:id])

respond_to do |format|
if @curso.update_attributes(params[:curso])
format.html { redirect_to @curso, notice: 'Curso was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @curso.errors, status: :unprocessable_entity }
end
end
end

# DELETE /cursos/1
# DELETE /cursos/1.json
def destroy
@curso = Curso.find(params[:id])
@curso.destroy

respond_to do |format|
format.html { redirect_to cursos_url }
format.json { head :no_content }
end
end
end
2 changes: 2 additions & 0 deletions app/helpers/cursos_helper.rb
@@ -0,0 +1,2 @@
module CursosHelper
end
2 changes: 2 additions & 0 deletions app/models/curso.rb
@@ -0,0 +1,2 @@
class Curso < ActiveRecord::Base
end
37 changes: 37 additions & 0 deletions app/views/cursos/_form.html.erb
@@ -0,0 +1,37 @@
<%= form_for(@curso) do |f| %>
<% if @curso.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@curso.errors.count, "error") %> prohibited this curso from being saved:</h2>

<ul>
<% @curso.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>

<div class="field">
<%= f.label :nombre %><br />
<%= f.text_field :nombre %>
</div>
<div class="field">
<%= f.label :formula %><br />
<%= f.text_field :formula %>
</div>
<div class="field">
<%= f.label :cantpcs %><br />
<%= f.number_field :cantpcs %>
</div>
<div class="field">
<%= f.label :exafinal %><br />
<%= f.check_box :exafinal %>
</div>
<div class="field">
<%= f.label :proyecto %><br />
<%= f.check_box :proyecto %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
6 changes: 6 additions & 0 deletions app/views/cursos/edit.html.erb
@@ -0,0 +1,6 @@
<h1>Editing curso</h1>

<%= render 'form' %>
<%= link_to 'Show', @curso %> |
<%= link_to 'Back', cursos_path %>
31 changes: 31 additions & 0 deletions app/views/cursos/index.html.erb
@@ -0,0 +1,31 @@
<h1>Listing cursos</h1>

<table>
<tr>
<th>Nombre</th>
<th>Formula</th>
<th>Cantpcs</th>
<th>Exafinal</th>
<th>Proyecto</th>
<th></th>
<th></th>
<th></th>
</tr>

<% @cursos.each do |curso| %>
<tr>
<td><%= curso.nombre %></td>
<td><%= curso.formula %></td>
<td><%= curso.cantpcs %></td>
<td><%= curso.exafinal %></td>
<td><%= curso.proyecto %></td>
<td><%= link_to 'Show', curso %></td>
<td><%= link_to 'Edit', edit_curso_path(curso) %></td>
<td><%= link_to 'Destroy', curso, confirm: 'Are you sure?', method: :delete %></td>
</tr>
<% end %>
</table>

<br />

<%= link_to 'New Curso', new_curso_path %>
5 changes: 5 additions & 0 deletions app/views/cursos/new.html.erb
@@ -0,0 +1,5 @@
<h1>New curso</h1>

<%= render 'form' %>
<%= link_to 'Back', cursos_path %>
30 changes: 30 additions & 0 deletions app/views/cursos/show.html.erb
@@ -0,0 +1,30 @@
<p id="notice"><%= notice %></p>

<p>
<b>Nombre:</b>
<%= @curso.nombre %>
</p>

<p>
<b>Formula:</b>
<%= @curso.formula %>
</p>

<p>
<b>Cantpcs:</b>
<%= @curso.cantpcs %>
</p>

<p>
<b>Exafinal:</b>
<%= @curso.exafinal %>
</p>

<p>
<b>Proyecto:</b>
<%= @curso.proyecto %>
</p>


<%= link_to 'Edit', edit_curso_path(@curso) %> |
<%= link_to 'Back', cursos_path %>
2 changes: 2 additions & 0 deletions config/routes.rb
@@ -1,4 +1,6 @@
TDEW2012::Application.routes.draw do
resources :cursos

# The priority is based upon order of creation:
# first created -> highest priority.

Expand Down
13 changes: 13 additions & 0 deletions db/migrate/20120317220952_create_cursos.rb
@@ -0,0 +1,13 @@
class CreateCursos < ActiveRecord::Migration
def change
create_table :cursos do |t|
t.string :nombre
t.string :formula
t.integer :cantpcs
t.boolean :exafinal
t.boolean :proyecto

t.timestamps
end
end
end
26 changes: 26 additions & 0 deletions db/schema.rb
@@ -0,0 +1,26 @@
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20120317220952) do

create_table "cursos", :force => true do |t|
t.string "nombre"
t.string "formula"
t.integer "cantpcs"
t.boolean "exafinal"
t.boolean "proyecto"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end

end
15 changes: 15 additions & 0 deletions test/fixtures/cursos.yml
@@ -0,0 +1,15 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html

one:
nombre: MyString
formula: MyString
cantpcs: 1
exafinal: false
proyecto: false

two:
nombre: MyString
formula: MyString
cantpcs: 1
exafinal: false
proyecto: false
49 changes: 49 additions & 0 deletions test/functional/cursos_controller_test.rb
@@ -0,0 +1,49 @@
require 'test_helper'

class CursosControllerTest < ActionController::TestCase
setup do
@curso = cursos(:one)
end

test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:cursos)
end

test "should get new" do
get :new
assert_response :success
end

test "should create curso" do
assert_difference('Curso.count') do
post :create, curso: @curso.attributes
end

assert_redirected_to curso_path(assigns(:curso))
end

test "should show curso" do
get :show, id: @curso
assert_response :success
end

test "should get edit" do
get :edit, id: @curso
assert_response :success
end

test "should update curso" do
put :update, id: @curso, curso: @curso.attributes
assert_redirected_to curso_path(assigns(:curso))
end

test "should destroy curso" do
assert_difference('Curso.count', -1) do
delete :destroy, id: @curso
end

assert_redirected_to cursos_path
end
end
7 changes: 7 additions & 0 deletions test/unit/curso_test.rb
@@ -0,0 +1,7 @@
require 'test_helper'

class CursoTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
4 changes: 4 additions & 0 deletions test/unit/helpers/cursos_helper_test.rb
@@ -0,0 +1,4 @@
require 'test_helper'

class CursosHelperTest < ActionView::TestCase
end

0 comments on commit fac5033

Please sign in to comment.