Description:
fix layout problem, again git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@41 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

r17:af60767c1f7f - - 1 file changed: 1 inserted, 1 deleted

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