Description:
fixed layout bugs again -- added explicit layout in main_controller git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@50 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

r26:a3328dc4a80b - - 1 file changed: 2 inserted, 0 deleted

@@ -1,52 +1,54
1 1 class MainController < ApplicationController
2 2
3 3 before_filter :authenticate, :except => [:index, :login]
4 4
5 + layout 'application'
6 +
5 7 verify :method => :post, :only => [:submit],
6 8 :redirect_to => { :action => :index }
7 9
8 10
9 11 def index
10 12 redirect_to :action => 'login'
11 13 end
12 14
13 15 def login
14 16 MainController.layout 'empty'
15 17 reset_session
16 18 end
17 19
18 20 def list
19 21 @problems = Problem.find_available_problems
20 22 @prob_submissions = Array.new
21 23 @user = User.find(session[:user_id])
22 24 @problems.each do |p|
23 25 c, sub = Submission.find_by_user_and_problem(@user.id,p.id)
24 26 @prob_submissions << [c,sub]
25 27 end
26 28 end
27 29
28 30 def submit
29 31 submission = Submission.new(params[:submission])
30 32 submission.user_id = session[:user_id]
31 33 submission.language_id = 0
32 34 source = params['file'].read
33 35 if source.length > 100_000
34 36 flash[:notice] = 'Error: file too long'
35 37 elsif (lang = Submission.find_language_in_source(source))==nil
36 38 flash[:notice] = 'Error: cannot determine language used'
37 39 elsif ((submission.problem_id==-1) and
38 40 !(problem=Submission.find_problem_in_source(source)))
39 41 flash[:notice] = 'Error: cannot determine problem submitted'
40 42 elsif ((submission.problem_id==-1) and
41 43 (problem.available == false))
42 44 flash[:notice] = 'Error: problem is not available'
43 45 else
44 46 submission.problem_id = problem.id if submission.problem_id == -1
45 47 submission.source = source
46 48 submission.language_id = lang.id
47 49 submission.submitted_at = Time.new
48 50 if submission.save == false
49 51 flash[:notice] = 'Error saving your submission'
50 52 elsif Task.create(:submission_id => submission.id) == false
51 53 flash[:notice] = 'Error adding your submission to task queue'
52 54 end
You need to be logged in to leave comments. Login now