diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -13,6 +13,7 @@ verify :method => :post, :only => [:submit], :redirect_to => { :action => :index } + caches_action :index, :login def index redirect_to :action => 'login' @@ -26,7 +27,7 @@ # # These are for site administrator login # - @countries = Country.find(:all) + @countries = Country.find(:all, :include => :sites) @country_select = @countries.collect { |c| [c.name, c.id] } @country_select_with_all = [['Any',0]] @@ -148,8 +149,8 @@ end def check_viewability - user = User.find(session[:user_id]) - if (!Configuration.show_tasks_to?(user)) and + @user = User.find(session[:user_id]) + if (!Configuration.show_tasks_to?(@user)) and ((action_name=='submission') or (action_name=='submit')) redirect_to :action => 'list' and return end diff --git a/app/views/main/login.html.haml b/app/views/main/login.html.haml --- a/app/views/main/login.html.haml +++ b/app/views/main/login.html.haml @@ -24,24 +24,24 @@ %br/ -%script{:type => 'text/javascript'} - var siteList = new Array(); - - @countries.each do |country| - = "siteList[#{country.id}] = new Array();" - - country.sites.each do |site| - = "siteList[#{country.id}][#{site.id}] = \"#{site.name}\";" +- if Configuration['system.mode']=='contest' + %script{:type => 'text/javascript'} + var siteList = new Array(); + - @countries.each do |country| + = "siteList[#{country.id}] = new Array();" + - country.sites.each do |site| + = "siteList[#{country.id}][#{site.id}] = \"#{site.name}\";" - var allSiteList = new Array(); - - @site_select.each do |sel| - = "allSiteList[#{sel[1]}]=\"#{sel[0]}\";" - -%script{:type => 'text/javascript', :src => '/javascripts/site_update.js'} + var allSiteList = new Array(); + - @site_select.each do |sel| + = "allSiteList[#{sel[1]}]=\"#{sel[0]}\";" -%div{ :style => "border: solid 1px gray; padding: 2px; background: #f0f0f0;"} - %b For Site Administrator. - %br/ - Please select your country and site and login. - .login-box + %script{:type => 'text/javascript', :src => '/javascripts/site_update.js'} + + %div{ :style => "border: solid 1px gray; padding: 2px; background: #f0f0f0;"} + %b For Site Administrator. + %br/ + Please select your country and site and login. - form_for :login, nil, :url => {:controller => 'login', :action => 'site_login'} do |f| Country: = select :site_country, :id, @country_select_with_all, {}, {:onchange => "updateSiteList();", :onclick => "updateSiteList();" } @@ -52,5 +52,5 @@ = f.password_field :password = submit_tag "Site Administrator Login" -%script{:type => 'text/javascript'} - updateSiteList(); + %script{:type => 'text/javascript'} + updateSiteList();