Description:
sort available problem group by date_added, name bulk manage user filter by remark as well
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r675:4404040ff0ce - - 2 files changed: 12 inserted, 2 deleted

@@ -403,25 +403,25
403 end
403 end
404 end
404 end
405
405
406 flash[:notice] = 'User(s) ' + note.join(', ') +
406 flash[:notice] = 'User(s) ' + note.join(', ') +
407 ' were successfully modified. '
407 ' were successfully modified. '
408 redirect_to :action => 'mass_mailing'
408 redirect_to :action => 'mass_mailing'
409 end
409 end
410
410
411 #bulk manage
411 #bulk manage
412 def bulk_manage
412 def bulk_manage
413
413
414 begin
414 begin
415 - @users = User.where('login REGEXP ?',params[:regex]) if params[:regex]
415 + @users = User.where('(login REGEXP ?) OR (remark REGEXP ?)',params[:regex],params[:regex]) if params[:regex]
416 @users.count if @users #i don't know why I have to call count, but if I won't exception is not raised
416 @users.count if @users #i don't know why I have to call count, but if I won't exception is not raised
417 rescue Exception
417 rescue Exception
418 flash[:error] = 'Regular Expression is malformed'
418 flash[:error] = 'Regular Expression is malformed'
419 @users = nil
419 @users = nil
420 end
420 end
421
421
422 if params[:commit]
422 if params[:commit]
423 @action = {}
423 @action = {}
424 @action[:set_enable] = params[:enabled]
424 @action[:set_enable] = params[:enabled]
425 @action[:enabled] = params[:enable] == "1"
425 @action[:enabled] = params[:enable] == "1"
426 @action[:gen_password] = params[:gen_password]
426 @action[:gen_password] = params[:gen_password]
427 @action[:add_group] = params[:add_group]
427 @action[:add_group] = params[:add_group]
@@ -308,25 +308,35
308 end
308 end
309 end
309 end
310 other_avaiable_problems = Problem.available.find_all {|p| pin[p.id]==nil and p.contests.length==0}
310 other_avaiable_problems = Problem.available.find_all {|p| pin[p.id]==nil and p.contests.length==0}
311 return contest_problems + other_avaiable_problems
311 return contest_problems + other_avaiable_problems
312 end
312 end
313 end
313 end
314
314
315 def available_problems_in_group
315 def available_problems_in_group
316 problem = []
316 problem = []
317 self.groups.each do |group|
317 self.groups.each do |group|
318 group.problems.where(available: true).each { |p| problem << p }
318 group.problems.where(available: true).each { |p| problem << p }
319 end
319 end
320 - return problem.uniq
320 + problem.uniq!.sort! do |a,b|
321 + case
322 + when a.date_added < b.date_added
323 + -1
324 + when a.date_added > b.date_added
325 + 1
326 + else
327 + a.name <=> b.name
328 + end
329 + end
330 + return problem
321 end
331 end
322
332
323 def can_view_problem?(problem)
333 def can_view_problem?(problem)
324 if not GraderConfiguration.multicontests?
334 if not GraderConfiguration.multicontests?
325 return problem.available
335 return problem.available
326 else
336 else
327 return problem_in_user_contests? problem
337 return problem_in_user_contests? problem
328 end
338 end
329 end
339 end
330
340
331 def self.clear_last_login
341 def self.clear_last_login
332 User.update_all(:last_ip => nil)
342 User.update_all(:last_ip => nil)
You need to be logged in to leave comments. Login now