Description:
moved to ror 2.0.2, add user rel to model submission git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@3 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r1:82d71b81c3b0 - - 7 files changed: 5 inserted, 10 deleted

@@ -9,15 +9,13
9
9
10 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
10 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
11 verify :method => :post, :only => [ :destroy, :create, :update ],
11 verify :method => :post, :only => [ :destroy, :create, :update ],
12 :redirect_to => { :action => :list }
12 :redirect_to => { :action => :list }
13
13
14 def list
14 def list
15 - @problem_pages, @problems = paginate(:problems,
15 + @problems = Problem.find(:all, :order => 'date_added DESC')
16 - :per_page => 10,
17 - :order => 'date_added DESC')
18 end
16 end
19
17
20 def show
18 def show
21 @problem = Problem.find(params[:id])
19 @problem = Problem.find(params[:id])
22 end
20 end
23
21
@@ -9,13 +9,13
9
9
10 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
10 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
11 verify :method => :post, :only => [ :destroy, :create, :update ],
11 verify :method => :post, :only => [ :destroy, :create, :update ],
12 :redirect_to => { :action => :list }
12 :redirect_to => { :action => :list }
13
13
14 def list
14 def list
15 - @user_pages, @users = paginate :users, :per_page => 50
15 + @users = User.find(:all)
16 end
16 end
17
17
18 def show
18 def show
19 @user = User.find(params[:id])
19 @user = User.find(params[:id])
20 end
20 end
21
21
@@ -1,10 +1,11
1 class Submission < ActiveRecord::Base
1 class Submission < ActiveRecord::Base
2
2
3 belongs_to :language
3 belongs_to :language
4 belongs_to :problem
4 belongs_to :problem
5 + belongs_to :user
5
6
6 def self.find_by_user_and_problem(user_id, problem_id)
7 def self.find_by_user_and_problem(user_id, problem_id)
7 subcount = count(:conditions => "user_id = #{user_id} AND problem_id = #{problem_id}")
8 subcount = count(:conditions => "user_id = #{user_id} AND problem_id = #{problem_id}")
8 if subcount != 0
9 if subcount != 0
9 last_sub = find(:first,
10 last_sub = find(:first,
10 :conditions => {:user_id => user_id,
11 :conditions => {:user_id => user_id,
@@ -22,12 +22,10
22 <td><%= link_to '[Edit]', :action => 'edit', :id => problem %></td>
22 <td><%= link_to '[Edit]', :action => 'edit', :id => problem %></td>
23 <td><%= link_to '[Destroy]', { :action => 'destroy', :id => problem }, :confirm => 'Are you sure?', :method => :post %></td>
23 <td><%= link_to '[Destroy]', { :action => 'destroy', :id => problem }, :confirm => 'Are you sure?', :method => :post %></td>
24 </tr>
24 </tr>
25 <% end %>
25 <% end %>
26 </table>
26 </table>
27
27
28 - <%= link_to 'Previous page', { :page => @problem_pages.current.previous } if @problem_pages.current.previous %>
29 - <%= link_to 'Next page', { :page => @problem_pages.current.next } if @problem_pages.current.next %>
30
28
31 <br />
29 <br />
32
30
33 <%= link_to 'New problem', :action => 'new' %>
31 <%= link_to 'New problem', :action => 'new' %>
@@ -44,12 +44,10
44 <td><%= link_to 'Edit', :action => 'edit', :id => user %></td>
44 <td><%= link_to 'Edit', :action => 'edit', :id => user %></td>
45 <td><%= link_to 'Destroy', { :action => 'destroy', :id => user }, :confirm => 'Are you sure?', :method => :post %></td>
45 <td><%= link_to 'Destroy', { :action => 'destroy', :id => user }, :confirm => 'Are you sure?', :method => :post %></td>
46 </tr>
46 </tr>
47 <% end %>
47 <% end %>
48 </table>
48 </table>
49
49
50 - <%= link_to 'Previous page', { :page => @user_pages.current.previous } if @user_pages.current.previous %>
51 - <%= link_to 'Next page', { :page => @user_pages.current.next } if @user_pages.current.next %>
52
50
53 <br />
51 <br />
54
52
55 <%= link_to 'New user', :action => 'new' %>
53 <%= link_to 'New user', :action => 'new' %>
@@ -2,13 +2,13
2
2
3 # Uncomment below to force Rails into production mode when
3 # Uncomment below to force Rails into production mode when
4 # you don't control web/app server and can't set it the proper way
4 # you don't control web/app server and can't set it the proper way
5 # ENV['RAILS_ENV'] ||= 'production'
5 # ENV['RAILS_ENV'] ||= 'production'
6
6
7 # Specifies gem version of Rails to use when vendor/rails is not present
7 # Specifies gem version of Rails to use when vendor/rails is not present
8 - RAILS_GEM_VERSION = '1.2.4' unless defined? RAILS_GEM_VERSION
8 + RAILS_GEM_VERSION = '2.0.2' unless defined? RAILS_GEM_VERSION
9
9
10 # Bootstrap the Rails environment, frameworks, and default configuration
10 # Bootstrap the Rails environment, frameworks, and default configuration
11 require File.join(File.dirname(__FILE__), 'boot')
11 require File.join(File.dirname(__FILE__), 'boot')
12
12
13 Rails::Initializer.run do |config|
13 Rails::Initializer.run do |config|
14 # Settings in config/environments/* take precedence over those specified here
14 # Settings in config/environments/* take precedence over those specified here
@@ -6,13 +6,13
6 config.cache_classes = false
6 config.cache_classes = false
7
7
8 # Log error messages when you accidentally call methods on nil.
8 # Log error messages when you accidentally call methods on nil.
9 config.whiny_nils = true
9 config.whiny_nils = true
10
10
11 # Enable the breakpoint server that script/breakpointer connects to
11 # Enable the breakpoint server that script/breakpointer connects to
12 - config.breakpoint_server = true
12 + #config.breakpoint_server = true
13
13
14 # Show full error reports and disable caching
14 # Show full error reports and disable caching
15 config.action_controller.consider_all_requests_local = true
15 config.action_controller.consider_all_requests_local = true
16 config.action_controller.perform_caching = false
16 config.action_controller.perform_caching = false
17 config.action_view.cache_template_extensions = false
17 config.action_view.cache_template_extensions = false
18 config.action_view.debug_rjs = true
18 config.action_view.debug_rjs = true
You need to be logged in to leave comments. Login now