Description:
fix some layout problem: first time at main after login, using wrong layouts
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@39 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r15:ef7a1ef3afd0 - - 1 file changed: 2 inserted, 0 deleted
@@ -1,55 +1,57 | |||
|
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 | def index |
|
9 | 11 | redirect_to :action => 'login' |
|
10 | 12 | end |
|
11 | 13 | |
|
12 | 14 | def login |
|
13 | 15 | MainController.layout 'login' |
|
14 | 16 | reset_session |
|
15 | 17 | end |
|
16 | 18 | |
|
17 | 19 | def list |
|
18 | 20 | @problems = Problem.find_available_problems |
|
19 | 21 | @prob_submissions = Array.new |
|
20 | 22 | @user = User.find(session[:user_id]) |
|
21 | 23 | @problems.each do |p| |
|
22 | 24 | c, sub = Submission.find_by_user_and_problem(@user.id,p.id) |
|
23 | 25 | @prob_submissions << [c,sub] |
|
24 | 26 | end |
|
25 | 27 | end |
|
26 | 28 | |
|
27 | 29 | def submit |
|
28 | 30 | submission = Submission.new(params[:submission]) |
|
29 | 31 | submission.user_id = session[:user_id] |
|
30 | 32 | submission.language_id = 0 |
|
31 | 33 | source = params['file'].read |
|
32 | 34 | if source.length > 100_000 |
|
33 | 35 | flash[:notice] = 'Error: file too long' |
|
34 | 36 | elsif (lang = Submission.find_language_in_source(source))==nil |
|
35 | 37 | flash[:notice] = 'Error: cannot determine language used' |
|
36 | 38 | elsif ((submission.problem_id==-1) and |
|
37 | 39 | !(problem=Submission.find_problem_in_source(source))) |
|
38 | 40 | flash[:notice] = 'Error: cannot determine problem submitted' |
|
39 | 41 | elsif ((submission.problem_id==-1) and |
|
40 | 42 | (problem.available == false)) |
|
41 | 43 | flash[:notice] = 'Error: problem is not available' |
|
42 | 44 | else |
|
43 | 45 | submission.problem_id = problem.id if submission.problem_id == -1 |
|
44 | 46 | submission.source = source |
|
45 | 47 | submission.language_id = lang.id |
|
46 | 48 | submission.submitted_at = Time.new |
|
47 | 49 | if submission.save == false |
|
48 | 50 | flash[:notice] = 'Error saving your submission' |
|
49 | 51 | elsif Task.create(:submission_id => submission.id) == false |
|
50 | 52 | flash[:notice] = 'Error adding your submission to task queue' |
|
51 | 53 | end |
|
52 | 54 | end |
|
53 | 55 | redirect_to :action => 'list' |
|
54 | 56 | end |
|
55 | 57 |
You need to be logged in to leave comments.
Login now