Show More
Commit Description:
removed caching on Configuration...
Commit Description:
removed caching on Configuration git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@285 6386c4cd-e34a-4fa8-8920-d93eb39b512e
File last commit:
Show/Diff file:
Action:
app/models/site.rb | 50 lines | 1.0 KiB | text/x-ruby | RubyLexer |
jittat
[web] added site and time out basic functionality...
r85 class Site < ActiveRecord::Base
jittat
[web] import from site...
r106 belongs_to :country
has_many :users
jittat
[web] added site and time out basic functionality...
r85 def clear_start_time_if_not_started
if !self.started
self.start_time = nil
end
end
jittat
[web] site start/stop supports...
r123 def time_left
contest_time = Configuration['contest.time_limit']
if tmatch = /(\d+):(\d+)/.match(contest_time)
h = tmatch[1].to_i
m = tmatch[2].to_i
jittat
[web] fix nil problem in various place, some styling...
r129
jittat
[web] site start/stop supports...
r123 current_time = Time.now.gmtime
jittat
[web] fix nil problem in various place, some styling...
r129 if self.start_time!=nil
finish_time = self.start_time + h.hour + m.minute
else
finish_time = current_time + h.hour + m.minute
end
jittat
[web] site start/stop supports...
r123
if current_time > finish_time
return current_time - current_time
else
finish_time - current_time
end
else
nil
end
end
jittat
[web] added site and time out basic functionality...
r85 def finished?
if !self.started
return false
end
contest_time = Configuration['contest.time_limit']
if tmatch = /(\d+):(\d+)/.match(contest_time)
h = tmatch[1].to_i
m = tmatch[2].to_i
jittat
[web] fix time.new, time.now to use gmtime...
r121 return Time.now.gmtime > (self.start_time + h.hour + m.minute)
jittat
[web] added site and time out basic functionality...
r85 else
false
end
end
end