diff --git a/app/models/configuration.rb b/app/models/configuration.rb --- a/app/models/configuration.rb +++ b/app/models/configuration.rb @@ -1,5 +1,10 @@ +# +# This class also contains various login of the system. +# class Configuration < ActiveRecord::Base + SYSTEM_MODE_CONF_KEY = 'system.mode' + @@configurations = nil def self.get(key) @@ -21,6 +26,28 @@ @@configurations = nil end + # + # View decision + # + def self.show_submitbox_to?(user) + mode = get(SYSTEM_MODE_CONF_KEY) + return false if mode=='analysis' + if (mode=='contest') + return false if (user.site!=nil) and + ((user.site.started==false) or (user.site.finished?)) + end + return true + end + + def self.show_tasks_to?(user) + mode = get(SYSTEM_MODE_CONF_KEY) + if (mode=='contest') + return false if (user.site!=nil) and (user.site.started==false) + end + return true + end + + protected def self.read_config @@configurations = {}