Description:
fixed error when submitted file is nil git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@366 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

r169:6eb47384a88d - - 1 file changed: 1 inserted, 1 deleted

@@ -32,49 +32,49
32 32 # logger.info "PATH: #{request.path}"
33 33 # if Configuration['system.single_user_mode'] and
34 34 # request.path!='/main/login'
35 35 # @hidelogin = true
36 36 # end
37 37
38 38 @announcements = Announcement.find_for_frontpage
39 39 render :action => 'login', :layout => 'empty'
40 40 end
41 41
42 42 def list
43 43 prepare_list_information
44 44 end
45 45
46 46 def help
47 47 @user = User.find(session[:user_id])
48 48 end
49 49
50 50 def submit
51 51 user = User.find(session[:user_id])
52 52
53 53 @submission = Submission.new(params[:submission])
54 54 @submission.user = user
55 55 @submission.language_id = 0
56 - if params['file']!=''
56 + if (params['file']) and (params['file']!='')
57 57 @submission.source = params['file'].read
58 58 @submission.source_filename = params['file'].original_filename
59 59 end
60 60 @submission.submitted_at = Time.new.gmtime
61 61
62 62 if Configuration[SYSTEM_MODE_CONF_KEY]=='contest' and
63 63 user.site!=nil and user.site.finished?
64 64 @submission.errors.add_to_base "The contest is over."
65 65 prepare_list_information
66 66 render :action => 'list' and return
67 67 end
68 68
69 69 if @submission.valid?
70 70 if @submission.save == false
71 71 flash[:notice] = 'Error saving your submission'
72 72 elsif Task.create(:submission_id => @submission.id,
73 73 :status => Task::STATUS_INQUEUE) == false
74 74 flash[:notice] = 'Error adding your submission to task queue'
75 75 end
76 76 else
77 77 prepare_list_information
78 78 render :action => 'list' and return
79 79 end
80 80 redirect_to :action => 'list'
You need to be logged in to leave comments. Login now