Description:
add datatable - now admin can login without checking agreement
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r691:81655bc0fe60 - - 7 files changed: 60 inserted, 33 deleted

@@ -50,33 +50,33
50 gem 'best_in_place', '~> 3.0.1'
50 gem 'best_in_place', '~> 3.0.1'
51
51
52 # jquery addition
52 # jquery addition
53 gem 'jquery-rails'
53 gem 'jquery-rails'
54 gem 'jquery-ui-rails'
54 gem 'jquery-ui-rails'
55 gem 'jquery-timepicker-addon-rails'
55 gem 'jquery-timepicker-addon-rails'
56 gem 'jquery-tablesorter'
56 gem 'jquery-tablesorter'
57 gem 'jquery-countdown-rails'
57 gem 'jquery-countdown-rails'
58
58
59 #syntax highlighter
59 #syntax highlighter
60 gem 'rouge'
60 gem 'rouge'
61
61
62 - #add bootstrap
62 + #bootstrap add-ons
63 gem 'bootstrap-sass', '~> 3.2.0'
63 gem 'bootstrap-sass', '~> 3.2.0'
64 gem 'bootstrap-switch-rails'
64 gem 'bootstrap-switch-rails'
65 gem 'bootstrap-toggle-rails'
65 gem 'bootstrap-toggle-rails'
66 gem 'autoprefixer-rails'
66 gem 'autoprefixer-rails'
67 -
68 - #bootstrap sortable
69 gem 'momentjs-rails'
67 gem 'momentjs-rails'
70 gem 'rails_bootstrap_sortable'
68 gem 'rails_bootstrap_sortable'
69 + gem 'bootstrap3-datetimepicker-rails', '~> 4.17.47'
70 + gem 'jquery-datatables-rails'
71
71
72 #----------- user interface -----------------
72 #----------- user interface -----------------
73 #select 2
73 #select 2
74 gem 'select2-rails'
74 gem 'select2-rails'
75 #ace editor
75 #ace editor
76 gem 'ace-rails-ap'
76 gem 'ace-rails-ap'
77 #paginator
77 #paginator
78 gem 'will_paginate', '~> 3.0.7'
78 gem 'will_paginate', '~> 3.0.7'
79
79
80 gem 'mail'
80 gem 'mail'
81 gem 'rdiscount'
81 gem 'rdiscount'
82 gem 'dynamic_form'
82 gem 'dynamic_form'
@@ -56,24 +56,26
56 tzinfo (~> 1.1)
56 tzinfo (~> 1.1)
57 ansi (1.5.0)
57 ansi (1.5.0)
58 arel (6.0.4)
58 arel (6.0.4)
59 autoprefixer-rails (6.6.0)
59 autoprefixer-rails (6.6.0)
60 execjs
60 execjs
61 best_in_place (3.0.3)
61 best_in_place (3.0.3)
62 actionpack (>= 3.2)
62 actionpack (>= 3.2)
63 railties (>= 3.2)
63 railties (>= 3.2)
64 bootstrap-sass (3.2.0.2)
64 bootstrap-sass (3.2.0.2)
65 sass (~> 3.2)
65 sass (~> 3.2)
66 bootstrap-switch-rails (3.3.3)
66 bootstrap-switch-rails (3.3.3)
67 bootstrap-toggle-rails (2.2.1.0)
67 bootstrap-toggle-rails (2.2.1.0)
68 + bootstrap3-datetimepicker-rails (4.17.47)
69 + momentjs-rails (>= 2.8.1)
68 builder (3.2.2)
70 builder (3.2.2)
69 coffee-rails (4.2.1)
71 coffee-rails (4.2.1)
70 coffee-script (>= 2.2.0)
72 coffee-script (>= 2.2.0)
71 railties (>= 4.0.0, < 5.2.x)
73 railties (>= 4.0.0, < 5.2.x)
72 coffee-script (2.4.1)
74 coffee-script (2.4.1)
73 coffee-script-source
75 coffee-script-source
74 execjs
76 execjs
75 coffee-script-source (1.12.2)
77 coffee-script-source (1.12.2)
76 concurrent-ruby (1.0.4)
78 concurrent-ruby (1.0.4)
77 dynamic_form (1.1.4)
79 dynamic_form (1.1.4)
78 erubis (2.7.0)
80 erubis (2.7.0)
79 execjs (2.7.0)
81 execjs (2.7.0)
@@ -88,24 +90,29
88 activesupport (>= 4.0.1)
90 activesupport (>= 4.0.1)
89 haml (>= 4.0.6, < 5.0)
91 haml (>= 4.0.6, < 5.0)
90 html2haml (>= 1.0.1)
92 html2haml (>= 1.0.1)
91 railties (>= 4.0.1)
93 railties (>= 4.0.1)
92 html2haml (2.0.0)
94 html2haml (2.0.0)
93 erubis (~> 2.7.0)
95 erubis (~> 2.7.0)
94 haml (~> 4.0.0)
96 haml (~> 4.0.0)
95 nokogiri (~> 1.6.0)
97 nokogiri (~> 1.6.0)
96 ruby_parser (~> 3.5)
98 ruby_parser (~> 3.5)
97 i18n (0.7.0)
99 i18n (0.7.0)
98 in_place_editing (1.2.0)
100 in_place_editing (1.2.0)
99 jquery-countdown-rails (2.0.2)
101 jquery-countdown-rails (2.0.2)
102 + jquery-datatables-rails (3.4.0)
103 + actionpack (>= 3.1)
104 + jquery-rails
105 + railties (>= 3.1)
106 + sass-rails
100 jquery-rails (4.2.1)
107 jquery-rails (4.2.1)
101 rails-dom-testing (>= 1, < 3)
108 rails-dom-testing (>= 1, < 3)
102 railties (>= 4.2.0)
109 railties (>= 4.2.0)
103 thor (>= 0.14, < 2.0)
110 thor (>= 0.14, < 2.0)
104 jquery-tablesorter (1.23.3)
111 jquery-tablesorter (1.23.3)
105 railties (>= 3.2, < 6)
112 railties (>= 3.2, < 6)
106 jquery-timepicker-addon-rails (1.4.1)
113 jquery-timepicker-addon-rails (1.4.1)
107 railties (>= 3.1)
114 railties (>= 3.1)
108 jquery-ui-rails (6.0.1)
115 jquery-ui-rails (6.0.1)
109 railties (>= 3.2.16)
116 railties (>= 3.2.16)
110 json (1.8.3)
117 json (1.8.3)
111 loofah (2.0.3)
118 loofah (2.0.3)
@@ -195,41 +202,43
195
202
196 PLATFORMS
203 PLATFORMS
197 ruby
204 ruby
198
205
199 DEPENDENCIES
206 DEPENDENCIES
200 ace-rails-ap
207 ace-rails-ap
201 activerecord-session_store
208 activerecord-session_store
202 autoprefixer-rails
209 autoprefixer-rails
203 best_in_place (~> 3.0.1)
210 best_in_place (~> 3.0.1)
204 bootstrap-sass (~> 3.2.0)
211 bootstrap-sass (~> 3.2.0)
205 bootstrap-switch-rails
212 bootstrap-switch-rails
206 bootstrap-toggle-rails
213 bootstrap-toggle-rails
214 + bootstrap3-datetimepicker-rails (~> 4.17.47)
207 coffee-rails
215 coffee-rails
208 dynamic_form
216 dynamic_form
209 fuzzy-string-match
217 fuzzy-string-match
210 haml
218 haml
211 haml-rails
219 haml-rails
212 in_place_editing
220 in_place_editing
213 jquery-countdown-rails
221 jquery-countdown-rails
222 + jquery-datatables-rails
214 jquery-rails
223 jquery-rails
215 jquery-tablesorter
224 jquery-tablesorter
216 jquery-timepicker-addon-rails
225 jquery-timepicker-addon-rails
217 jquery-ui-rails
226 jquery-ui-rails
218 mail
227 mail
219 minitest-reporters
228 minitest-reporters
220 momentjs-rails
229 momentjs-rails
221 mysql2
230 mysql2
222 rails (~> 4.2.0)
231 rails (~> 4.2.0)
223 rails_bootstrap_sortable
232 rails_bootstrap_sortable
224 rdiscount
233 rdiscount
225 rouge
234 rouge
226 sass-rails
235 sass-rails
227 select2-rails
236 select2-rails
228 sqlite3
237 sqlite3
229 uglifier
238 uglifier
230 verification!
239 verification!
231 will_paginate (~> 3.0.7)
240 will_paginate (~> 3.0.7)
232 yaml_db
241 yaml_db
233
242
234 BUNDLED WITH
243 BUNDLED WITH
235 - 1.13.6
244 + 1.15.4
@@ -3,28 +3,32
3 //
3 //
4 // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
4 // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5 // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
5 // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6 //
6 //
7 // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
7 // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8 // the compiled file.
8 // the compiled file.
9 //
9 //
10 // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
10 // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11 // GO AFTER THE REQUIRES BELOW.
11 // GO AFTER THE REQUIRES BELOW.
12 //
12 //
13 //= require jquery
13 //= require jquery
14 //= require jquery_ujs
14 //= require jquery_ujs
15 + //= require dataTables/jquery.dataTables
16 + //= require dataTables/bootstrap/3/jquery.dataTables.bootstrap
15 //= require jquery-ui
17 //= require jquery-ui
16 //= require bootstrap-sprockets
18 //= require bootstrap-sprockets
17 //= require moment
19 //= require moment
20 + //= require moment/th
18 //= require bootstrap-sortable
21 //= require bootstrap-sortable
22 + //= require bootstrap-datetimepicker
19 //= require select2
23 //= require select2
20 //= require ace-rails-ap
24 //= require ace-rails-ap
21 //= require ace/mode-c_cpp
25 //= require ace/mode-c_cpp
22 //= require ace/mode-python
26 //= require ace/mode-python
23 //= require ace/mode-ruby
27 //= require ace/mode-ruby
24 //= require ace/mode-pascal
28 //= require ace/mode-pascal
25 //= require ace/mode-javascript
29 //= require ace/mode-javascript
26 //= require ace/mode-java
30 //= require ace/mode-java
27 //= require ace/theme-merbivore
31 //= require ace/theme-merbivore
28 //= require custom
32 //= require custom
29 //= require jquery.countdown
33 //= require jquery.countdown
30 //-------------- addition from local_jquery -----------
34 //-------------- addition from local_jquery -----------
@@ -24,24 +24,26
24 @import "jquery.countdown";
24 @import "jquery.countdown";
25 @import "tablesorter-theme.cafe";
25 @import "tablesorter-theme.cafe";
26
26
27 //bootstrap
27 //bootstrap
28 @import "bootstrap-sprockets";
28 @import "bootstrap-sprockets";
29 @import "bootstrap";
29 @import "bootstrap";
30 @import "select2";
30 @import "select2";
31 @import "select2-bootstrap";
31 @import "select2-bootstrap";
32
32
33 //@import bootstrap3-switch
33 //@import bootstrap3-switch
34 @import "bootstrap-toggle";
34 @import "bootstrap-toggle";
35 @import "bootstrap-sortable";
35 @import "bootstrap-sortable";
36 + @import "bootstrap-datetimepicker";
37 + @import "dataTables/bootstrap/3/jquery.dataTables.bootstrap";
36
38
37 //bootstrap navbar color (from)
39 //bootstrap navbar color (from)
38 $bgDefault: #19197b;
40 $bgDefault: #19197b;
39 $bgHighlight: #06064b;
41 $bgHighlight: #06064b;
40 $colDefault: #8e8eb4;
42 $colDefault: #8e8eb4;
41 $colHighlight: #ffffff;
43 $colHighlight: #ffffff;
42 $dropDown: false;
44 $dropDown: false;
43
45
44 @font-face {
46 @font-face {
45 font-family: 'Glyphicons Halflings';
47 font-family: 'Glyphicons Halflings';
46 src: font-path('bootstrap/glyphicons-halflings-regular.eot');
48 src: font-path('bootstrap/glyphicons-halflings-regular.eot');
47 src: font-path('bootstrap/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'),
49 src: font-path('bootstrap/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'),
@@ -1,47 +1,53
1 class LoginController < ApplicationController
1 class LoginController < ApplicationController
2
2
3 def index
3 def index
4 # show login screen
4 # show login screen
5 reset_session
5 reset_session
6 redirect_to :controller => 'main', :action => 'login'
6 redirect_to :controller => 'main', :action => 'login'
7 end
7 end
8
8
9 def login
9 def login
10 - if (!GraderConfiguration['right.bypass_agreement']) and (!params[:accept_agree])
10 + user = User.authenticate(params[:login], params[:password])
11 + unless user
12 + flash[:notice] = 'Wrong password'
13 + redirect_to :controller => 'main', :action => 'login'
14 + return
15 + end
16 +
17 + if (!GraderConfiguration['right.bypass_agreement']) and (!params[:accept_agree]) and !user.admin?
11 flash[:notice] = 'You must accept the agreement before logging in'
18 flash[:notice] = 'You must accept the agreement before logging in'
12 redirect_to :controller => 'main', :action => 'login'
19 redirect_to :controller => 'main', :action => 'login'
13 - elsif user = User.authenticate(params[:login], params[:password])
20 + return
14 - session[:user_id] = user.id
21 + end
15 - session[:admin] = user.admin?
22 +
23 + #process logging in
24 + session[:user_id] = user.id
25 + session[:admin] = user.admin?
16
26
17 - # clear forced logout flag for multicontests contest change
27 + # clear forced logout flag for multicontests contest change
18 - if GraderConfiguration.multicontests?
28 + if GraderConfiguration.multicontests?
19 - contest_stat = user.contest_stat
29 + contest_stat = user.contest_stat
20 - if contest_stat.respond_to? :forced_logout
30 + if contest_stat.respond_to? :forced_logout
21 - if contest_stat.forced_logout
31 + if contest_stat.forced_logout
22 - contest_stat.forced_logout = false
32 + contest_stat.forced_logout = false
23 - contest_stat.save
33 + contest_stat.save
24 - end
25 end
34 end
26 end
35 end
27 -
36 + end
28 - #save login information
29 - Login.create(user_id: user.id, ip_address: request.remote_ip)
30
37
31 - redirect_to :controller => 'main', :action => 'list'
38 + #save login information
32 - else
39 + Login.create(user_id: user.id, ip_address: request.remote_ip)
33 - flash[:notice] = 'Wrong password'
40 +
34 - redirect_to :controller => 'main', :action => 'login'
41 + redirect_to :controller => 'main', :action => 'list'
35 - end
36 end
42 end
37
43
38 def site_login
44 def site_login
39 begin
45 begin
40 site = Site.find(params[:login][:site_id])
46 site = Site.find(params[:login][:site_id])
41 rescue ActiveRecord::RecordNotFound
47 rescue ActiveRecord::RecordNotFound
42 site = nil
48 site = nil
43 end
49 end
44 if site==nil
50 if site==nil
45 flash[:notice] = 'Wrong site'
51 flash[:notice] = 'Wrong site'
46 redirect_to :controller => 'main', :action => 'login' and return
52 redirect_to :controller => 'main', :action => 'login' and return
47 end
53 end
@@ -15,24 +15,25
15 ],
15 ],
16 :redirect_to => { :action => :list }
16 :redirect_to => { :action => :list }
17
17
18 def index
18 def index
19 @user_count = User.count
19 @user_count = User.count
20 if params[:page] == 'all'
20 if params[:page] == 'all'
21 @users = User.all
21 @users = User.all
22 @paginated = false
22 @paginated = false
23 else
23 else
24 @users = User.paginate :page => params[:page]
24 @users = User.paginate :page => params[:page]
25 @paginated = true
25 @paginated = true
26 end
26 end
27 + @users = User.all
27 @hidden_columns = ['hashed_password', 'salt', 'created_at', 'updated_at']
28 @hidden_columns = ['hashed_password', 'salt', 'created_at', 'updated_at']
28 @contests = Contest.enabled
29 @contests = Contest.enabled
29 end
30 end
30
31
31 def active
32 def active
32 sessions = ActiveRecord::SessionStore::Session.where("updated_at >= ?", 60.minutes.ago)
33 sessions = ActiveRecord::SessionStore::Session.where("updated_at >= ?", 60.minutes.ago)
33 @users = []
34 @users = []
34 sessions.each do |session|
35 sessions.each do |session|
35 if session.data[:user_id]
36 if session.data[:user_id]
36 @users << User.find(session.data[:user_id])
37 @users << User.find(session.data[:user_id])
37 end
38 end
38 end
39 end
@@ -47,35 +47,35
47 = link_to 'View active users',{ :action => 'active'}, { class: 'btn btn-default '}
47 = link_to 'View active users',{ :action => 'active'}, { class: 'btn btn-default '}
48 = link_to 'Mass mailing',{ :action => 'mass_mailing'}, { class: 'btn btn-default '}
48 = link_to 'Mass mailing',{ :action => 'mass_mailing'}, { class: 'btn btn-default '}
49
49
50 - if GraderConfiguration.multicontests?
50 - if GraderConfiguration.multicontests?
51 %br/
51 %br/
52 %b Multi-contest:
52 %b Multi-contest:
53 = link_to '[Manage bulk users in contests]', :action => 'contest_management'
53 = link_to '[Manage bulk users in contests]', :action => 'contest_management'
54 View users in:
54 View users in:
55 - @contests.each do |contest|
55 - @contests.each do |contest|
56 = link_to "[#{contest.name}]", :action => 'contests', :id => contest.id
56 = link_to "[#{contest.name}]", :action => 'contests', :id => contest.id
57 = link_to "[no contest]", :action => 'contests', :id => 'none'
57 = link_to "[no contest]", :action => 'contests', :id => 'none'
58
58
59 - Total #{@user_count} users |
59 + -# Total #{@user_count} users |
60 - - if !@paginated
60 + -# - if !@paginated
61 - Display all users.
61 + -# Display all users.
62 - \#{link_to '[show in pages]', :action => 'index', :page => '1'}
62 + -# \#{link_to '[show in pages]', :action => 'index', :page => '1'}
63 - - else
63 + -# - else
64 - Display in pages.
64 + -# Display in pages.
65 - \#{link_to '[display all]', :action => 'index', :page => 'all'} |
65 + -# \#{link_to '[display all]', :action => 'index', :page => 'all'} |
66 - \#{will_paginate @users, :container => false}
66 + -# \#{will_paginate @users, :container => false}
67
67
68
68
69 - %table.table.table-hover.table-condense
69 + %table.table.table-hover.table-condense.datatable
70 %thead
70 %thead
71 %th Login
71 %th Login
72 %th Full name
72 %th Full name
73 %th email
73 %th email
74 %th Remark
74 %th Remark
75 %th
75 %th
76 Activated
76 Activated
77 %sup{class: 'text-primary',data: {toggle: 'tooltip', placement: 'top'}, title: 'User has already confirmed the email?' } [?]
77 %sup{class: 'text-primary',data: {toggle: 'tooltip', placement: 'top'}, title: 'User has already confirmed the email?' } [?]
78 %th
78 %th
79 Enabled
79 Enabled
80 %sup{class: 'text-primary',data: {toggle: 'tooltip', placement: 'top'}, title: 'Allow the user to login?' } [?]
80 %sup{class: 'text-primary',data: {toggle: 'tooltip', placement: 'top'}, title: 'Allow the user to login?' } [?]
81 %th Last IP
81 %th Last IP
@@ -90,12 +90,17
90 %td= user.email
90 %td= user.email
91 %td= user.remark
91 %td= user.remark
92 %td= toggle_button(user.activated?, toggle_activate_user_path(user),"toggle_activate_user_#{user.id}")
92 %td= toggle_button(user.activated?, toggle_activate_user_path(user),"toggle_activate_user_#{user.id}")
93 %td= toggle_button(user.enabled?, toggle_enable_user_path(user),"toggle_enable_user_#{user.id}")
93 %td= toggle_button(user.enabled?, toggle_enable_user_path(user),"toggle_enable_user_#{user.id}")
94 %td= user.last_ip
94 %td= user.last_ip
95 %td= link_to 'Clear IP', {:action => 'clear_last_ip', :id => user, :page=>params[:page]}, :confirm => 'This will reset last logging in ip of the user, are you sure?', class: 'btn btn-default btn-xs btn-block'
95 %td= link_to 'Clear IP', {:action => 'clear_last_ip', :id => user, :page=>params[:page]}, :confirm => 'This will reset last logging in ip of the user, are you sure?', class: 'btn btn-default btn-xs btn-block'
96 %td= link_to 'Show', {:action => 'show', :id => user}, class: 'btn btn-default btn-xs btn-block'
96 %td= link_to 'Show', {:action => 'show', :id => user}, class: 'btn btn-default btn-xs btn-block'
97 %td= link_to 'Edit', {:action => 'edit', :id => user}, class: 'btn btn-default btn-xs btn-block'
97 %td= link_to 'Edit', {:action => 'edit', :id => user}, class: 'btn btn-default btn-xs btn-block'
98 %td= link_to 'Destroy', user_admin_destroy_path(user), data: {confirm: 'Are you sure?'}, method: :delete, class: 'btn btn-danger btn-xs btn-block'
98 %td= link_to 'Destroy', user_admin_destroy_path(user), data: {confirm: 'Are you sure?'}, method: :delete, class: 'btn btn-danger btn-xs btn-block'
99 %br/
99 %br/
100 = link_to '+ New user', { :action => 'new' }, { class: 'btn btn-success '}
100 = link_to '+ New user', { :action => 'new' }, { class: 'btn btn-success '}
101 = link_to '+ New list of users', { :action => 'new_list' }, { class: 'btn btn-success '}
101 = link_to '+ New list of users', { :action => 'new_list' }, { class: 'btn btn-success '}
102 +
103 + :javascript
104 + $('.datatable').DataTable({
105 + 'pageLength': 50
106 + });
You need to be logged in to leave comments. Login now