Description:
update errors.add_to_base("x") to Rails 3 errors.add(:base,"x")
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r347:6d2339b98fac - - 6 files changed: 12 inserted, 12 deleted

@@ -66,13 +66,13
66 @submission.source = params['file'].read
66 @submission.source = params['file'].read
67 @submission.source_filename = params['file'].original_filename
67 @submission.source_filename = params['file'].original_filename
68 end
68 end
69 @submission.submitted_at = Time.new.gmtime
69 @submission.submitted_at = Time.new.gmtime
70
70
71 if GraderConfiguration.time_limit_mode? and user.contest_finished?
71 if GraderConfiguration.time_limit_mode? and user.contest_finished?
72 - @submission.errors.add_to_base "The contest is over."
72 + @submission.errors.add(:base,"The contest is over.")
73 prepare_list_information
73 prepare_list_information
74 render :action => 'list' and return
74 render :action => 'list' and return
75 end
75 end
76
76
77 if @submission.valid?
77 if @submission.valid?
78 if @submission.save == false
78 if @submission.save == false
@@ -23,13 +23,13
23 prepare_index_information
23 prepare_index_information
24 render :action => 'index' and return
24 render :action => 'index' and return
25 end
25 end
26
26
27 if GraderConfiguration.time_limit_mode?
27 if GraderConfiguration.time_limit_mode?
28 if @user.contest_finished?
28 if @user.contest_finished?
29 - @submitted_test_request.errors.add_to_base('Contest is over.')
29 + @submitted_test_request.errors.add(:base,'Contest is over.')
30 prepare_index_information
30 prepare_index_information
31 render :action => 'index' and return
31 render :action => 'index' and return
32 end
32 end
33
33
34 if !GraderConfiguration.allow_test_request(@user)
34 if !GraderConfiguration.allow_test_request(@user)
35 prepare_index_information
35 prepare_index_information
@@ -59,13 +59,13
59 render :action => 'new_splash', :layout => 'empty'
59 render :action => 'new_splash', :layout => 'empty'
60 else
60 else
61 @admin_email = GraderConfiguration['system.admin_email']
61 @admin_email = GraderConfiguration['system.admin_email']
62 render :action => 'email_error', :layout => 'empty'
62 render :action => 'email_error', :layout => 'empty'
63 end
63 end
64 else
64 else
65 - @user.errors.add_to_base("Email cannot be blank") if @user.email==''
65 + @user.errors.add(:base,"Email cannot be blank") if @user.email==''
66 render :action => 'new', :layout => 'empty'
66 render :action => 'new', :layout => 'empty'
67 end
67 end
68 end
68 end
69
69
70 def confirm
70 def confirm
71 login = params[:login]
71 login = params[:login]
@@ -41,13 +41,13
41 importer = TestdataImporter.new(problem)
41 importer = TestdataImporter.new(problem)
42
42
43 if not importer.import_from_file(import_params[:file],
43 if not importer.import_from_file(import_params[:file],
44 import_params[:time_limit],
44 import_params[:time_limit],
45 import_params[:memory_limit],
45 import_params[:memory_limit],
46 import_to_db)
46 import_to_db)
47 - problem.errors.add_to_base('Import error.')
47 + problem.errors.add(:base,'Import error.')
48 end
48 end
49
49
50 return problem, importer.log_msg
50 return problem, importer.log_msg
51 end
51 end
52
52
53 def self.download_file_basedir
53 def self.download_file_basedir
@@ -74,23 +74,23
74 time_limit = Problem.to_f_or_default(params[:time_limit],
74 time_limit = Problem.to_f_or_default(params[:time_limit],
75 DEFAULT_TIME_LIMIT)
75 DEFAULT_TIME_LIMIT)
76 memory_limit = Problem.to_i_or_default(params[:memory_limit],
76 memory_limit = Problem.to_i_or_default(params[:memory_limit],
77 DEFAULT_MEMORY_LIMIT)
77 DEFAULT_MEMORY_LIMIT)
78
78
79 if time_limit<=0 or time_limit >60
79 if time_limit<=0 or time_limit >60
80 - problem.errors.add_to_base('Time limit out of range.')
80 + problem.errors.add(:base,'Time limit out of range.')
81 end
81 end
82
82
83 if memory_limit==0 and params[:memory_limit]!='0'
83 if memory_limit==0 and params[:memory_limit]!='0'
84 - problem.errors.add_to_base('Memory limit format errors.')
84 + problem.errors.add(:base,'Memory limit format errors.')
85 elsif memory_limit<=0 or memory_limit >512
85 elsif memory_limit<=0 or memory_limit >512
86 - problem.errors.add_to_base('Memory limit out of range.')
86 + problem.errors.add(:base,'Memory limit out of range.')
87 end
87 end
88
88
89 if params[:file]==nil or params[:file]==''
89 if params[:file]==nil or params[:file]==''
90 - problem.errors.add_to_base('No testdata file.')
90 + problem.errors.add(:base,'No testdata file.')
91 end
91 end
92
92
93 file = params[:file]
93 file = params[:file]
94
94
95 if !problem.errors.empty?
95 if !problem.errors.empty?
96 return nil, problem
96 return nil, problem
@@ -67,18 +67,18
67 else
67 else
68 test_request.submission = nil
68 test_request.submission = nil
69 end
69 end
70
70
71 # checks if the user submits any input file
71 # checks if the user submits any input file
72 if params[:input_file]==nil or params[:input_file]==""
72 if params[:input_file]==nil or params[:input_file]==""
73 - test_request.errors.add_to_base("No input submitted.")
73 + test_request.errors.add(:base,"No input submitted.")
74 test_request.input_file_name = nil
74 test_request.input_file_name = nil
75 else
75 else
76 test_request.input_file_name = save_input_file(params[:input_file], user, problem)
76 test_request.input_file_name = save_input_file(params[:input_file], user, problem)
77 if test_request.input_file_name == nil
77 if test_request.input_file_name == nil
78 - test_request.errors.add_to_base("No input submitted.")
78 + test_request.errors.adds(:base,"No input submitted.")
79 end
79 end
80 if params[:additional_file]!=nil and params[:additional_file]!=""
80 if params[:additional_file]!=nil and params[:additional_file]!=""
81 save_additional_file(params[:additional_file],
81 save_additional_file(params[:additional_file],
82 "#{test_request.input_file_name}.files")
82 "#{test_request.input_file_name}.files")
83 end
83 end
84 end
84 end
@@ -295,24 +295,24
295 Digest::SHA1.hexdigest(salt + string)
295 Digest::SHA1.hexdigest(salt + string)
296 end
296 end
297
297
298 def uniqueness_of_email_from_activated_users
298 def uniqueness_of_email_from_activated_users
299 user = User.activated_users.find_by_email(self.email)
299 user = User.activated_users.find_by_email(self.email)
300 if user and (user.login != self.login)
300 if user and (user.login != self.login)
301 - self.errors.add_to_base("Email has already been taken")
301 + self.errors.add(:base,"Email has already been taken")
302 end
302 end
303 end
303 end
304
304
305 def enough_time_interval_between_same_email_registrations
305 def enough_time_interval_between_same_email_registrations
306 return if !self.new_record?
306 return if !self.new_record?
307 return if self.activated
307 return if self.activated
308 open_user = User.find_by_email(self.email,
308 open_user = User.find_by_email(self.email,
309 :order => 'created_at DESC')
309 :order => 'created_at DESC')
310 if open_user and open_user.created_at and
310 if open_user and open_user.created_at and
311 (open_user.created_at > Time.now.gmtime - 5.minutes)
311 (open_user.created_at > Time.now.gmtime - 5.minutes)
312 - self.errors.add_to_base("There are already unactivated registrations with this e-mail address (please wait for 5 minutes)")
312 + self.errors.add(:base,"There are already unactivated registrations with this e-mail address (please wait for 5 minutes)")
313 end
313 end
314 end
314 end
315
315
316 def email_validation?
316 def email_validation?
317 begin
317 begin
318 return VALIDATE_USER_EMAILS
318 return VALIDATE_USER_EMAILS
You need to be logged in to leave comments. Login now