Description:
[web] no site admin login box when not in contest mode
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@252 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r124:44e64c191944 - - 2 files changed: 5 inserted, 4 deleted
@@ -4,38 +4,39 | |||||
|
4 |
|
4 | ||
|
5 | before_filter :authenticate, :except => [:index, :login] |
|
5 | before_filter :authenticate, :except => [:index, :login] |
|
6 | before_filter :check_viewability, :except => [:index, :login] |
|
6 | before_filter :check_viewability, :except => [:index, :login] |
|
7 |
|
7 | ||
|
8 | # |
|
8 | # |
|
9 | # COMMENT OUT: filter in each action instead |
|
9 | # COMMENT OUT: filter in each action instead |
|
10 | # |
|
10 | # |
|
11 | # before_filter :verify_time_limit, :only => [:submit] |
|
11 | # before_filter :verify_time_limit, :only => [:submit] |
|
12 |
|
12 | ||
|
13 | verify :method => :post, :only => [:submit], |
|
13 | verify :method => :post, :only => [:submit], |
|
14 | :redirect_to => { :action => :index } |
|
14 | :redirect_to => { :action => :index } |
|
15 |
|
15 | ||
|
|
16 | + caches_action :index, :login | ||
|
16 |
|
17 | ||
|
17 | def index |
|
18 | def index |
|
18 | redirect_to :action => 'login' |
|
19 | redirect_to :action => 'login' |
|
19 | end |
|
20 | end |
|
20 |
|
21 | ||
|
21 | def login |
|
22 | def login |
|
22 | saved_notice = flash[:notice] |
|
23 | saved_notice = flash[:notice] |
|
23 | reset_session |
|
24 | reset_session |
|
24 | flash[:notice] = saved_notice |
|
25 | flash[:notice] = saved_notice |
|
25 |
|
26 | ||
|
26 | # |
|
27 | # |
|
27 | # These are for site administrator login |
|
28 | # These are for site administrator login |
|
28 | # |
|
29 | # |
|
29 | - @countries = Country.find(:all) |
|
30 | + @countries = Country.find(:all, :include => :sites) |
|
30 | @country_select = @countries.collect { |c| [c.name, c.id] } |
|
31 | @country_select = @countries.collect { |c| [c.name, c.id] } |
|
31 |
|
32 | ||
|
32 | @country_select_with_all = [['Any',0]] |
|
33 | @country_select_with_all = [['Any',0]] |
|
33 | @countries.each do |country| |
|
34 | @countries.each do |country| |
|
34 | @country_select_with_all << [country.name, country.id] |
|
35 | @country_select_with_all << [country.name, country.id] |
|
35 | end |
|
36 | end |
|
36 |
|
37 | ||
|
37 | @site_select = [] |
|
38 | @site_select = [] |
|
38 | @countries.each do |country| |
|
39 | @countries.each do |country| |
|
39 | country.sites.each do |site| |
|
40 | country.sites.each do |site| |
|
40 | @site_select << ["#{site.name}, #{country.name}", site.id] |
|
41 | @site_select << ["#{site.name}, #{country.name}", site.id] |
|
41 | end |
|
42 | end |
@@ -139,21 +140,21 | |||||
|
139 | @prob_submissions << { :count => sub.number, :submission => sub } |
|
140 | @prob_submissions << { :count => sub.number, :submission => sub } |
|
140 | else |
|
141 | else |
|
141 | @prob_submissions << { :count => 0, :submission => nil } |
|
142 | @prob_submissions << { :count => 0, :submission => nil } |
|
142 | end |
|
143 | end |
|
143 | end |
|
144 | end |
|
144 |
|
145 | ||
|
145 | @announcements = Announcement.find(:all, |
|
146 | @announcements = Announcement.find(:all, |
|
146 | :conditions => "published = 1", |
|
147 | :conditions => "published = 1", |
|
147 | :order => "created_at DESC") |
|
148 | :order => "created_at DESC") |
|
148 | end |
|
149 | end |
|
149 |
|
150 | ||
|
150 | def check_viewability |
|
151 | def check_viewability |
|
151 | - user = User.find(session[:user_id]) |
|
152 | + @user = User.find(session[:user_id]) |
|
152 | - if (!Configuration.show_tasks_to?(user)) and |
|
153 | + if (!Configuration.show_tasks_to?(@user)) and |
|
153 | ((action_name=='submission') or (action_name=='submit')) |
|
154 | ((action_name=='submission') or (action_name=='submit')) |
|
154 | redirect_to :action => 'list' and return |
|
155 | redirect_to :action => 'list' and return |
|
155 | end |
|
156 | end |
|
156 | end |
|
157 | end |
|
157 |
|
158 | ||
|
158 | end |
|
159 | end |
|
159 |
|
160 |
@@ -15,42 +15,42 | |||||
|
15 | - form_tag :controller => 'login', :action => 'login' do |
|
15 | - form_tag :controller => 'login', :action => 'login' do |
|
16 | %table |
|
16 | %table |
|
17 | %tr |
|
17 | %tr |
|
18 | %td{:align => "right"} Login: |
|
18 | %td{:align => "right"} Login: |
|
19 | %td= text_field_tag 'login' |
|
19 | %td= text_field_tag 'login' |
|
20 | %tr |
|
20 | %tr |
|
21 | %td{:align => "right"} Password: |
|
21 | %td{:align => "right"} Password: |
|
22 | %td= password_field_tag |
|
22 | %td= password_field_tag |
|
23 | = submit_tag 'Login' |
|
23 | = submit_tag 'Login' |
|
24 |
|
24 | ||
|
25 | %br/ |
|
25 | %br/ |
|
26 |
|
26 | ||
|
|
27 | + - if Configuration['system.mode']=='contest' | ||
|
27 | %script{:type => 'text/javascript'} |
|
28 | %script{:type => 'text/javascript'} |
|
28 | var siteList = new Array(); |
|
29 | var siteList = new Array(); |
|
29 | - @countries.each do |country| |
|
30 | - @countries.each do |country| |
|
30 | = "siteList[#{country.id}] = new Array();" |
|
31 | = "siteList[#{country.id}] = new Array();" |
|
31 | - country.sites.each do |site| |
|
32 | - country.sites.each do |site| |
|
32 | = "siteList[#{country.id}][#{site.id}] = \"#{site.name}\";" |
|
33 | = "siteList[#{country.id}][#{site.id}] = \"#{site.name}\";" |
|
33 |
|
34 | ||
|
34 | var allSiteList = new Array(); |
|
35 | var allSiteList = new Array(); |
|
35 | - @site_select.each do |sel| |
|
36 | - @site_select.each do |sel| |
|
36 | = "allSiteList[#{sel[1]}]=\"#{sel[0]}\";" |
|
37 | = "allSiteList[#{sel[1]}]=\"#{sel[0]}\";" |
|
37 |
|
38 | ||
|
38 | %script{:type => 'text/javascript', :src => '/javascripts/site_update.js'} |
|
39 | %script{:type => 'text/javascript', :src => '/javascripts/site_update.js'} |
|
39 |
|
40 | ||
|
40 | %div{ :style => "border: solid 1px gray; padding: 2px; background: #f0f0f0;"} |
|
41 | %div{ :style => "border: solid 1px gray; padding: 2px; background: #f0f0f0;"} |
|
41 | %b For Site Administrator. |
|
42 | %b For Site Administrator. |
|
42 | %br/ |
|
43 | %br/ |
|
43 | Please select your country and site and login. |
|
44 | Please select your country and site and login. |
|
44 | - .login-box |
|
||
|
45 | - form_for :login, nil, :url => {:controller => 'login', :action => 'site_login'} do |f| |
|
45 | - form_for :login, nil, :url => {:controller => 'login', :action => 'site_login'} do |f| |
|
46 | Country: |
|
46 | Country: |
|
47 | = select :site_country, :id, @country_select_with_all, {}, {:onchange => "updateSiteList();", :onclick => "updateSiteList();" } |
|
47 | = select :site_country, :id, @country_select_with_all, {}, {:onchange => "updateSiteList();", :onclick => "updateSiteList();" } |
|
48 | Site: |
|
48 | Site: |
|
49 | = select :login, :site_id, @site_select |
|
49 | = select :login, :site_id, @site_select |
|
50 | %br/ |
|
50 | %br/ |
|
51 | Password: |
|
51 | Password: |
|
52 | = f.password_field :password |
|
52 | = f.password_field :password |
|
53 | = submit_tag "Site Administrator Login" |
|
53 | = submit_tag "Site Administrator Login" |
|
54 |
|
54 | ||
|
55 | %script{:type => 'text/javascript'} |
|
55 | %script{:type => 'text/javascript'} |
|
56 | updateSiteList(); |
|
56 | updateSiteList(); |
You need to be logged in to leave comments.
Login now