Skip to content

Commit 438e6b5

Browse files
committed
Adding Niveis and Problemas with tests
1 parent 8ccbd3f commit 438e6b5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+5701
-3
lines changed

TODO

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Submissão automática
77

88
Problemas
99

10-
- Problemas (id_no_pku,nome,link,categorias_old,origem_old)
10+
FEITO - Problemas (id_no_pku,nome,link,categorias_old,origem_old)
1111
- Nível (facil,facil-medio,medio,medio-dificil, dificil)
1212

1313
Usuários

app/controllers/niveis_controller.rb

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
class NiveisController < ApplicationController
2+
# GET /niveis
3+
# GET /niveis.xml
4+
def index
5+
@niveis = Nivel.all
6+
7+
respond_to do |format|
8+
format.html # index.html.erb
9+
format.xml { render :xml => @niveis }
10+
end
11+
end
12+
13+
# GET /niveis/1
14+
# GET /niveis/1.xml
15+
def show
16+
@nivel = Nivel.find(params[:id])
17+
18+
respond_to do |format|
19+
format.html # show.html.erb
20+
format.xml { render :xml => @nivel }
21+
end
22+
end
23+
24+
# GET /niveis/new
25+
# GET /niveis/new.xml
26+
def new
27+
@nivel = Nivel.new
28+
29+
respond_to do |format|
30+
format.html # new.html.erb
31+
format.xml { render :xml => @nivel }
32+
end
33+
end
34+
35+
# GET /niveis/1/edit
36+
def edit
37+
@nivel = Nivel.find(params[:id])
38+
end
39+
40+
# POST /niveis
41+
# POST /niveis.xml
42+
def create
43+
@nivel = Nivel.new(params[:nivel])
44+
45+
respond_to do |format|
46+
if @nivel.save
47+
flash[:notice] = 'Nivel was successfully created.'
48+
format.html { redirect_to(@nivel) }
49+
format.xml { render :xml => @nivel, :status => :created, :location => @nivel }
50+
else
51+
format.html { render :action => "new" }
52+
format.xml { render :xml => @nivel.errors, :status => :unprocessable_entity }
53+
end
54+
end
55+
end
56+
57+
# PUT /niveis/1
58+
# PUT /niveis/1.xml
59+
def update
60+
@nivel = Nivel.find(params[:id])
61+
62+
respond_to do |format|
63+
if @nivel.update_attributes(params[:nivel])
64+
flash[:notice] = 'Nivel was successfully updated.'
65+
format.html { redirect_to(@nivel) }
66+
format.xml { head :ok }
67+
else
68+
format.html { render :action => "edit" }
69+
format.xml { render :xml => @nivel.errors, :status => :unprocessable_entity }
70+
end
71+
end
72+
end
73+
74+
# DELETE /niveis/1
75+
# DELETE /niveis/1.xml
76+
def destroy
77+
@nivel = Nivel.find(params[:id])
78+
@nivel.destroy
79+
80+
respond_to do |format|
81+
format.html { redirect_to(niveis_url) }
82+
format.xml { head :ok }
83+
end
84+
end
85+
end

app/controllers/nivels_controller.rb

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
class NivelsController < ApplicationController
2+
# GET /nivels
3+
# GET /nivels.xml
4+
def index
5+
@nivels = Nivel.all
6+
7+
respond_to do |format|
8+
format.html # index.html.erb
9+
format.xml { render :xml => @nivels }
10+
end
11+
end
12+
13+
# GET /nivels/1
14+
# GET /nivels/1.xml
15+
def show
16+
@nivel = Nivel.find(params[:id])
17+
18+
respond_to do |format|
19+
format.html # show.html.erb
20+
format.xml { render :xml => @nivel }
21+
end
22+
end
23+
24+
# GET /nivels/new
25+
# GET /nivels/new.xml
26+
def new
27+
@nivel = Nivel.new
28+
29+
respond_to do |format|
30+
format.html # new.html.erb
31+
format.xml { render :xml => @nivel }
32+
end
33+
end
34+
35+
# GET /nivels/1/edit
36+
def edit
37+
@nivel = Nivel.find(params[:id])
38+
end
39+
40+
# POST /nivels
41+
# POST /nivels.xml
42+
def create
43+
@nivel = Nivel.new(params[:nivel])
44+
45+
respond_to do |format|
46+
if @nivel.save
47+
flash[:notice] = 'Nivel was successfully created.'
48+
format.html { redirect_to(@nivel) }
49+
format.xml { render :xml => @nivel, :status => :created, :location => @nivel }
50+
else
51+
format.html { render :action => "new" }
52+
format.xml { render :xml => @nivel.errors, :status => :unprocessable_entity }
53+
end
54+
end
55+
end
56+
57+
# PUT /nivels/1
58+
# PUT /nivels/1.xml
59+
def update
60+
@nivel = Nivel.find(params[:id])
61+
62+
respond_to do |format|
63+
if @nivel.update_attributes(params[:nivel])
64+
flash[:notice] = 'Nivel was successfully updated.'
65+
format.html { redirect_to(@nivel) }
66+
format.xml { head :ok }
67+
else
68+
format.html { render :action => "edit" }
69+
format.xml { render :xml => @nivel.errors, :status => :unprocessable_entity }
70+
end
71+
end
72+
end
73+
74+
# DELETE /nivels/1
75+
# DELETE /nivels/1.xml
76+
def destroy
77+
@nivel = Nivel.find(params[:id])
78+
@nivel.destroy
79+
80+
respond_to do |format|
81+
format.html { redirect_to(nivels_url) }
82+
format.xml { head :ok }
83+
end
84+
end
85+
end
+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
class ProblemasController < ApplicationController
2+
# GET /problemas
3+
# GET /problemas.xml
4+
def index
5+
@problemas = Problema.all
6+
7+
respond_to do |format|
8+
format.html # index.html.erb
9+
format.xml { render :xml => @problemas }
10+
end
11+
end
12+
13+
# GET /problemas/1
14+
# GET /problemas/1.xml
15+
def show
16+
@problema = Problema.find(params[:id])
17+
18+
respond_to do |format|
19+
format.html # show.html.erb
20+
format.xml { render :xml => @problema }
21+
end
22+
end
23+
24+
# GET /problemas/new
25+
# GET /problemas/new.xml
26+
def new
27+
@problema = Problema.new
28+
29+
respond_to do |format|
30+
format.html # new.html.erb
31+
format.xml { render :xml => @problema }
32+
end
33+
end
34+
35+
# GET /problemas/1/edit
36+
def edit
37+
@problema = Problema.find(params[:id])
38+
end
39+
40+
# POST /problemas
41+
# POST /problemas.xml
42+
def create
43+
@problema = Problema.new(params[:problema])
44+
45+
respond_to do |format|
46+
if @problema.save
47+
flash[:notice] = 'Problema was successfully created.'
48+
format.html { redirect_to(@problema) }
49+
format.xml { render :xml => @problema, :status => :created, :location => @problema }
50+
else
51+
format.html { render :action => "new" }
52+
format.xml { render :xml => @problema.errors, :status => :unprocessable_entity }
53+
end
54+
end
55+
end
56+
57+
# PUT /problemas/1
58+
# PUT /problemas/1.xml
59+
def update
60+
@problema = Problema.find(params[:id])
61+
62+
respond_to do |format|
63+
if @problema.update_attributes(params[:problema])
64+
flash[:notice] = 'Problema was successfully updated.'
65+
format.html { redirect_to(@problema) }
66+
format.xml { head :ok }
67+
else
68+
format.html { render :action => "edit" }
69+
format.xml { render :xml => @problema.errors, :status => :unprocessable_entity }
70+
end
71+
end
72+
end
73+
74+
# DELETE /problemas/1
75+
# DELETE /problemas/1.xml
76+
def destroy
77+
@problema = Problema.find(params[:id])
78+
@problema.destroy
79+
80+
respond_to do |format|
81+
format.html { redirect_to(problemas_url) }
82+
format.xml { head :ok }
83+
end
84+
end
85+
end

app/helpers/niveis_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module NiveisHelper
2+
end

app/helpers/nivels_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module NivelsHelper
2+
end

app/helpers/problemas_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module ProblemasHelper
2+
end

app/models/nivel.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class Nivel < ActiveRecord::Base
2+
end

app/models/problema.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class Problema < ActiveRecord::Base
2+
end

app/views/layouts/niveis.html.erb

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3+
4+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5+
<head>
6+
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
7+
<title>Niveis: <%= controller.action_name %></title>
8+
<%= stylesheet_link_tag 'scaffold' %>
9+
</head>
10+
<body>
11+
12+
<p style="color: green"><%= flash[:notice] %></p>
13+
14+
<%= yield %>
15+
16+
</body>
17+
</html>

app/views/layouts/nivels.html.erb

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3+
4+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5+
<head>
6+
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
7+
<title>Nivels: <%= controller.action_name %></title>
8+
<%= stylesheet_link_tag 'scaffold' %>
9+
</head>
10+
<body>
11+
12+
<p style="color: green"><%= flash[:notice] %></p>
13+
14+
<%= yield %>
15+
16+
</body>
17+
</html>

app/views/layouts/problemas.html.erb

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3+
4+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5+
<head>
6+
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
7+
<title>Problemas: <%= controller.action_name %></title>
8+
<%= stylesheet_link_tag 'scaffold' %>
9+
</head>
10+
<body>
11+
12+
<p style="color: green"><%= flash[:notice] %></p>
13+
14+
<%= yield %>
15+
16+
</body>
17+
</html>

app/views/niveis/edit.html.erb

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<h1>Editing nivel</h1>
2+
3+
<% form_for(@nivel) do |f| %>
4+
<%= f.error_messages %>
5+
6+
<p>
7+
<%= f.label :descricao %><br />
8+
<%= f.text_field :descricao %>
9+
</p>
10+
<p>
11+
<%= f.submit 'Update' %>
12+
</p>
13+
<% end %>
14+
15+
<%= link_to 'Show', @nivel %> |
16+
<%= link_to 'Back', niveis_path %>

app/views/niveis/index.html.erb

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<h1>Listing niveis</h1>
2+
3+
<table>
4+
<tr>
5+
<th>Descricao</th>
6+
</tr>
7+
8+
<% @niveis.each do |nivel| %>
9+
<tr>
10+
<td><%=h nivel.descricao %></td>
11+
<td><%= link_to 'Show', nivel %></td>
12+
<td><%= link_to 'Edit', edit_nivel_path(nivel) %></td>
13+
<td><%= link_to 'Destroy', nivel, :confirm => 'Are you sure?', :method => :delete %></td>
14+
</tr>
15+
<% end %>
16+
</table>
17+
18+
<br />
19+
20+
<%= link_to 'New nivel', new_nivel_path %>

app/views/niveis/new.html.erb

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<h1>New nivel</h1>
2+
3+
<% form_for(@nivel) do |f| %>
4+
<%= f.error_messages %>
5+
6+
<p>
7+
<%= f.label :descricao %><br />
8+
<%= f.text_field :descricao %>
9+
</p>
10+
<p>
11+
<%= f.submit 'Create' %>
12+
</p>
13+
<% end %>
14+
15+
<%= link_to 'Back', niveis_path %>

0 commit comments

Comments
 (0)