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