Description:
add datatable
- now admin can login without checking agreement
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r691:81655bc0fe60 - - 7 files changed: 46 inserted, 19 deleted
@@ -14,78 +14,78 | |||
|
14 | 14 | #for testing |
|
15 | 15 | gem 'sqlite3' |
|
16 | 16 | #for dumping database into yaml |
|
17 | 17 | gem 'yaml_db' |
|
18 | 18 | |
|
19 | 19 | # Gems used only for assets and not required |
|
20 | 20 | # in production environments by default. |
|
21 | 21 | gem 'sass-rails' |
|
22 | 22 | gem 'coffee-rails' |
|
23 | 23 | |
|
24 | 24 | # See https://github.com/sstephenson/execjs#readme for more supported runtimes |
|
25 | 25 | # gem 'therubyracer', :platforms => :ruby |
|
26 | 26 | |
|
27 | 27 | gem 'uglifier' |
|
28 | 28 | |
|
29 | 29 | gem 'haml' |
|
30 | 30 | gem 'haml-rails' |
|
31 | 31 | # gem 'prototype-rails' |
|
32 | 32 | |
|
33 | 33 | # To use ActiveModel has_secure_password |
|
34 | 34 | # gem 'bcrypt-ruby', '~> 3.0.0' |
|
35 | 35 | |
|
36 | 36 | # To use Jbuilder templates for JSON |
|
37 | 37 | # gem 'jbuilder' |
|
38 | 38 | |
|
39 | 39 | # Use unicorn as the app server |
|
40 | 40 | # gem 'unicorn' |
|
41 | 41 | |
|
42 | 42 | # Deploy with Capistrano |
|
43 | 43 | # gem 'capistrano' |
|
44 | 44 | |
|
45 | 45 | # To use debugger |
|
46 | 46 | # gem 'debugger' |
|
47 | 47 | # |
|
48 | 48 | |
|
49 | 49 | #in-place editor |
|
50 | 50 | gem 'best_in_place', '~> 3.0.1' |
|
51 | 51 | |
|
52 | 52 | # jquery addition |
|
53 | 53 | gem 'jquery-rails' |
|
54 | 54 | gem 'jquery-ui-rails' |
|
55 | 55 | gem 'jquery-timepicker-addon-rails' |
|
56 | 56 | gem 'jquery-tablesorter' |
|
57 | 57 | gem 'jquery-countdown-rails' |
|
58 | 58 | |
|
59 | 59 | #syntax highlighter |
|
60 | 60 | gem 'rouge' |
|
61 | 61 | |
|
62 |
- # |
|
|
62 | + #bootstrap add-ons | |
|
63 | 63 | gem 'bootstrap-sass', '~> 3.2.0' |
|
64 | 64 | gem 'bootstrap-switch-rails' |
|
65 | 65 | gem 'bootstrap-toggle-rails' |
|
66 | 66 | gem 'autoprefixer-rails' |
|
67 | - | |
|
68 | - #bootstrap sortable | |
|
69 | 67 | gem 'momentjs-rails' |
|
70 | 68 | gem 'rails_bootstrap_sortable' |
|
69 | + gem 'bootstrap3-datetimepicker-rails', '~> 4.17.47' | |
|
70 | + gem 'jquery-datatables-rails' | |
|
71 | 71 | |
|
72 | 72 | #----------- user interface ----------------- |
|
73 | 73 | #select 2 |
|
74 | 74 | gem 'select2-rails' |
|
75 | 75 | #ace editor |
|
76 | 76 | gem 'ace-rails-ap' |
|
77 | 77 | #paginator |
|
78 | 78 | gem 'will_paginate', '~> 3.0.7' |
|
79 | 79 | |
|
80 | 80 | gem 'mail' |
|
81 | 81 | gem 'rdiscount' |
|
82 | 82 | gem 'dynamic_form' |
|
83 | 83 | gem 'in_place_editing' |
|
84 | 84 | gem 'verification', :git => 'https://github.com/sikachu/verification.git' |
|
85 | 85 | |
|
86 | 86 | |
|
87 | 87 | #---------------- testiing ----------------------- |
|
88 | 88 | gem 'minitest-reporters' |
|
89 | 89 | |
|
90 | 90 | #---------------- for console -------------------- |
|
91 | 91 | gem 'fuzzy-string-match' |
@@ -20,128 +20,135 | |||
|
20 | 20 | mail (~> 2.5, >= 2.5.4) |
|
21 | 21 | rails-dom-testing (~> 1.0, >= 1.0.5) |
|
22 | 22 | actionpack (4.2.7.1) |
|
23 | 23 | actionview (= 4.2.7.1) |
|
24 | 24 | activesupport (= 4.2.7.1) |
|
25 | 25 | rack (~> 1.6) |
|
26 | 26 | rack-test (~> 0.6.2) |
|
27 | 27 | rails-dom-testing (~> 1.0, >= 1.0.5) |
|
28 | 28 | rails-html-sanitizer (~> 1.0, >= 1.0.2) |
|
29 | 29 | actionview (4.2.7.1) |
|
30 | 30 | activesupport (= 4.2.7.1) |
|
31 | 31 | builder (~> 3.1) |
|
32 | 32 | erubis (~> 2.7.0) |
|
33 | 33 | rails-dom-testing (~> 1.0, >= 1.0.5) |
|
34 | 34 | rails-html-sanitizer (~> 1.0, >= 1.0.2) |
|
35 | 35 | activejob (4.2.7.1) |
|
36 | 36 | activesupport (= 4.2.7.1) |
|
37 | 37 | globalid (>= 0.3.0) |
|
38 | 38 | activemodel (4.2.7.1) |
|
39 | 39 | activesupport (= 4.2.7.1) |
|
40 | 40 | builder (~> 3.1) |
|
41 | 41 | activerecord (4.2.7.1) |
|
42 | 42 | activemodel (= 4.2.7.1) |
|
43 | 43 | activesupport (= 4.2.7.1) |
|
44 | 44 | arel (~> 6.0) |
|
45 | 45 | activerecord-session_store (1.0.0) |
|
46 | 46 | actionpack (>= 4.0, < 5.1) |
|
47 | 47 | activerecord (>= 4.0, < 5.1) |
|
48 | 48 | multi_json (~> 1.11, >= 1.11.2) |
|
49 | 49 | rack (>= 1.5.2, < 3) |
|
50 | 50 | railties (>= 4.0, < 5.1) |
|
51 | 51 | activesupport (4.2.7.1) |
|
52 | 52 | i18n (~> 0.7) |
|
53 | 53 | json (~> 1.7, >= 1.7.7) |
|
54 | 54 | minitest (~> 5.1) |
|
55 | 55 | thread_safe (~> 0.3, >= 0.3.4) |
|
56 | 56 | tzinfo (~> 1.1) |
|
57 | 57 | ansi (1.5.0) |
|
58 | 58 | arel (6.0.4) |
|
59 | 59 | autoprefixer-rails (6.6.0) |
|
60 | 60 | execjs |
|
61 | 61 | best_in_place (3.0.3) |
|
62 | 62 | actionpack (>= 3.2) |
|
63 | 63 | railties (>= 3.2) |
|
64 | 64 | bootstrap-sass (3.2.0.2) |
|
65 | 65 | sass (~> 3.2) |
|
66 | 66 | bootstrap-switch-rails (3.3.3) |
|
67 | 67 | bootstrap-toggle-rails (2.2.1.0) |
|
68 | + bootstrap3-datetimepicker-rails (4.17.47) | |
|
69 | + momentjs-rails (>= 2.8.1) | |
|
68 | 70 | builder (3.2.2) |
|
69 | 71 | coffee-rails (4.2.1) |
|
70 | 72 | coffee-script (>= 2.2.0) |
|
71 | 73 | railties (>= 4.0.0, < 5.2.x) |
|
72 | 74 | coffee-script (2.4.1) |
|
73 | 75 | coffee-script-source |
|
74 | 76 | execjs |
|
75 | 77 | coffee-script-source (1.12.2) |
|
76 | 78 | concurrent-ruby (1.0.4) |
|
77 | 79 | dynamic_form (1.1.4) |
|
78 | 80 | erubis (2.7.0) |
|
79 | 81 | execjs (2.7.0) |
|
80 | 82 | fuzzy-string-match (1.0.0) |
|
81 | 83 | RubyInline (>= 3.8.6) |
|
82 | 84 | globalid (0.3.7) |
|
83 | 85 | activesupport (>= 4.1.0) |
|
84 | 86 | haml (4.0.7) |
|
85 | 87 | tilt |
|
86 | 88 | haml-rails (0.9.0) |
|
87 | 89 | actionpack (>= 4.0.1) |
|
88 | 90 | activesupport (>= 4.0.1) |
|
89 | 91 | haml (>= 4.0.6, < 5.0) |
|
90 | 92 | html2haml (>= 1.0.1) |
|
91 | 93 | railties (>= 4.0.1) |
|
92 | 94 | html2haml (2.0.0) |
|
93 | 95 | erubis (~> 2.7.0) |
|
94 | 96 | haml (~> 4.0.0) |
|
95 | 97 | nokogiri (~> 1.6.0) |
|
96 | 98 | ruby_parser (~> 3.5) |
|
97 | 99 | i18n (0.7.0) |
|
98 | 100 | in_place_editing (1.2.0) |
|
99 | 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 | 107 | jquery-rails (4.2.1) |
|
101 | 108 | rails-dom-testing (>= 1, < 3) |
|
102 | 109 | railties (>= 4.2.0) |
|
103 | 110 | thor (>= 0.14, < 2.0) |
|
104 | 111 | jquery-tablesorter (1.23.3) |
|
105 | 112 | railties (>= 3.2, < 6) |
|
106 | 113 | jquery-timepicker-addon-rails (1.4.1) |
|
107 | 114 | railties (>= 3.1) |
|
108 | 115 | jquery-ui-rails (6.0.1) |
|
109 | 116 | railties (>= 3.2.16) |
|
110 | 117 | json (1.8.3) |
|
111 | 118 | loofah (2.0.3) |
|
112 | 119 | nokogiri (>= 1.5.9) |
|
113 | 120 | mail (2.6.4) |
|
114 | 121 | mime-types (>= 1.16, < 4) |
|
115 | 122 | mime-types (3.1) |
|
116 | 123 | mime-types-data (~> 3.2015) |
|
117 | 124 | mime-types-data (3.2016.0521) |
|
118 | 125 | mini_portile2 (2.1.0) |
|
119 | 126 | minitest (5.10.1) |
|
120 | 127 | minitest-reporters (1.1.13) |
|
121 | 128 | ansi |
|
122 | 129 | builder |
|
123 | 130 | minitest (>= 5.0) |
|
124 | 131 | ruby-progressbar |
|
125 | 132 | momentjs-rails (2.15.1) |
|
126 | 133 | railties (>= 3.1) |
|
127 | 134 | multi_json (1.12.1) |
|
128 | 135 | mysql2 (0.4.5) |
|
129 | 136 | nokogiri (1.6.8.1) |
|
130 | 137 | mini_portile2 (~> 2.1.0) |
|
131 | 138 | rack (1.6.5) |
|
132 | 139 | rack-test (0.6.3) |
|
133 | 140 | rack (>= 1.0) |
|
134 | 141 | rails (4.2.7.1) |
|
135 | 142 | actionmailer (= 4.2.7.1) |
|
136 | 143 | actionpack (= 4.2.7.1) |
|
137 | 144 | actionview (= 4.2.7.1) |
|
138 | 145 | activejob (= 4.2.7.1) |
|
139 | 146 | activemodel (= 4.2.7.1) |
|
140 | 147 | activerecord (= 4.2.7.1) |
|
141 | 148 | activesupport (= 4.2.7.1) |
|
142 | 149 | bundler (>= 1.3.0, < 2.0) |
|
143 | 150 | railties (= 4.2.7.1) |
|
144 | 151 | sprockets-rails |
|
145 | 152 | rails-deprecated_sanitizer (1.0.3) |
|
146 | 153 | activesupport (>= 4.2.0.alpha) |
|
147 | 154 | rails-dom-testing (1.0.8) |
@@ -159,77 +166,79 | |||
|
159 | 166 | thor (>= 0.18.1, < 2.0) |
|
160 | 167 | rake (12.0.0) |
|
161 | 168 | rdiscount (2.2.0.1) |
|
162 | 169 | rouge (2.0.7) |
|
163 | 170 | ruby-progressbar (1.8.1) |
|
164 | 171 | ruby_parser (3.8.3) |
|
165 | 172 | sexp_processor (~> 4.1) |
|
166 | 173 | sass (3.4.23) |
|
167 | 174 | sass-rails (5.0.6) |
|
168 | 175 | railties (>= 4.0.0, < 6) |
|
169 | 176 | sass (~> 3.1) |
|
170 | 177 | sprockets (>= 2.8, < 4.0) |
|
171 | 178 | sprockets-rails (>= 2.0, < 4.0) |
|
172 | 179 | tilt (>= 1.1, < 3) |
|
173 | 180 | select2-rails (4.0.3) |
|
174 | 181 | thor (~> 0.14) |
|
175 | 182 | sexp_processor (4.7.0) |
|
176 | 183 | sprockets (3.7.1) |
|
177 | 184 | concurrent-ruby (~> 1.0) |
|
178 | 185 | rack (> 1, < 3) |
|
179 | 186 | sprockets-rails (3.2.0) |
|
180 | 187 | actionpack (>= 4.0) |
|
181 | 188 | activesupport (>= 4.0) |
|
182 | 189 | sprockets (>= 3.0.0) |
|
183 | 190 | sqlite3 (1.3.12) |
|
184 | 191 | thor (0.19.4) |
|
185 | 192 | thread_safe (0.3.5) |
|
186 | 193 | tilt (2.0.5) |
|
187 | 194 | tzinfo (1.2.2) |
|
188 | 195 | thread_safe (~> 0.1) |
|
189 | 196 | uglifier (3.0.4) |
|
190 | 197 | execjs (>= 0.3.0, < 3) |
|
191 | 198 | will_paginate (3.0.12) |
|
192 | 199 | yaml_db (0.4.2) |
|
193 | 200 | rails (>= 3.0, < 5.1) |
|
194 | 201 | rake (>= 0.8.7) |
|
195 | 202 | |
|
196 | 203 | PLATFORMS |
|
197 | 204 | ruby |
|
198 | 205 | |
|
199 | 206 | DEPENDENCIES |
|
200 | 207 | ace-rails-ap |
|
201 | 208 | activerecord-session_store |
|
202 | 209 | autoprefixer-rails |
|
203 | 210 | best_in_place (~> 3.0.1) |
|
204 | 211 | bootstrap-sass (~> 3.2.0) |
|
205 | 212 | bootstrap-switch-rails |
|
206 | 213 | bootstrap-toggle-rails |
|
214 | + bootstrap3-datetimepicker-rails (~> 4.17.47) | |
|
207 | 215 | coffee-rails |
|
208 | 216 | dynamic_form |
|
209 | 217 | fuzzy-string-match |
|
210 | 218 | haml |
|
211 | 219 | haml-rails |
|
212 | 220 | in_place_editing |
|
213 | 221 | jquery-countdown-rails |
|
222 | + jquery-datatables-rails | |
|
214 | 223 | jquery-rails |
|
215 | 224 | jquery-tablesorter |
|
216 | 225 | jquery-timepicker-addon-rails |
|
217 | 226 | jquery-ui-rails |
|
218 | 227 | |
|
219 | 228 | minitest-reporters |
|
220 | 229 | momentjs-rails |
|
221 | 230 | mysql2 |
|
222 | 231 | rails (~> 4.2.0) |
|
223 | 232 | rails_bootstrap_sortable |
|
224 | 233 | rdiscount |
|
225 | 234 | rouge |
|
226 | 235 | sass-rails |
|
227 | 236 | select2-rails |
|
228 | 237 | sqlite3 |
|
229 | 238 | uglifier |
|
230 | 239 | verification! |
|
231 | 240 | will_paginate (~> 3.0.7) |
|
232 | 241 | yaml_db |
|
233 | 242 | |
|
234 | 243 | BUNDLED WITH |
|
235 |
- 1.1 |
|
|
244 | + 1.15.4 |
@@ -1,41 +1,45 | |||
|
1 | 1 | // This is a manifest file that'll be compiled into application.js, which will include all the files |
|
2 | 2 | // listed below. |
|
3 | 3 | // |
|
4 | 4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, |
|
5 | 5 | // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. |
|
6 | 6 | // |
|
7 | 7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the |
|
8 | 8 | // the compiled file. |
|
9 | 9 | // |
|
10 | 10 | // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD |
|
11 | 11 | // GO AFTER THE REQUIRES BELOW. |
|
12 | 12 | // |
|
13 | 13 | //= require jquery |
|
14 | 14 | //= require jquery_ujs |
|
15 | + //= require dataTables/jquery.dataTables | |
|
16 | + //= require dataTables/bootstrap/3/jquery.dataTables.bootstrap | |
|
15 | 17 | //= require jquery-ui |
|
16 | 18 | //= require bootstrap-sprockets |
|
17 | 19 | //= require moment |
|
20 | + //= require moment/th | |
|
18 | 21 | //= require bootstrap-sortable |
|
22 | + //= require bootstrap-datetimepicker | |
|
19 | 23 | //= require select2 |
|
20 | 24 | //= require ace-rails-ap |
|
21 | 25 | //= require ace/mode-c_cpp |
|
22 | 26 | //= require ace/mode-python |
|
23 | 27 | //= require ace/mode-ruby |
|
24 | 28 | //= require ace/mode-pascal |
|
25 | 29 | //= require ace/mode-javascript |
|
26 | 30 | //= require ace/mode-java |
|
27 | 31 | //= require ace/theme-merbivore |
|
28 | 32 | //= require custom |
|
29 | 33 | //= require jquery.countdown |
|
30 | 34 | //-------------- addition from local_jquery ----------- |
|
31 | 35 | //= require jquery-tablesorter |
|
32 | 36 | //= require best_in_place |
|
33 | 37 | //= require best_in_place.jquery-ui |
|
34 | 38 | //= require brython |
|
35 | 39 | |
|
36 | 40 | // since this is after blank line, it is not downloaded |
|
37 | 41 | //x= require prototype |
|
38 | 42 | //x= require prototype_ujs |
|
39 | 43 | //x= require effects |
|
40 | 44 | //x= require dragdrop |
|
41 | 45 | //x= require controls |
@@ -1,83 +1,85 | |||
|
1 | 1 | /* This is a manifest file that'll be compiled into application.css, which will include all the files |
|
2 | 2 | * listed below. |
|
3 | 3 | * |
|
4 | 4 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, |
|
5 | 5 | * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path. |
|
6 | 6 | * |
|
7 | 7 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the |
|
8 | 8 | * compiled file so the styles you add here take precedence over styles defined in any styles |
|
9 | 9 | * defined in the other CSS/SCSS files in this directory. It is generally better to create a new |
|
10 | 10 | * file per style scope. |
|
11 | 11 | * |
|
12 | 12 | * // bootstrap says that we should not do this, but @import each file instead |
|
13 | 13 | * # *= require_tree . |
|
14 | 14 | * # *= require_self |
|
15 | 15 | */ |
|
16 | 16 | |
|
17 | 17 | @import "jquery-ui"; |
|
18 | 18 | //@import "jquery.ui.core"; |
|
19 | 19 | //@import "jquery.ui.theme"; |
|
20 | 20 | //@import "jquery.ui.datepicker"; |
|
21 | 21 | //@import "jquery.ui.slider"; |
|
22 | 22 | @import "jquery-ui-timepicker-addon"; |
|
23 | 23 | @import "jquery-tablesorter/theme.metro-dark"; |
|
24 | 24 | @import "jquery.countdown"; |
|
25 | 25 | @import "tablesorter-theme.cafe"; |
|
26 | 26 | |
|
27 | 27 | //bootstrap |
|
28 | 28 | @import "bootstrap-sprockets"; |
|
29 | 29 | @import "bootstrap"; |
|
30 | 30 | @import "select2"; |
|
31 | 31 | @import "select2-bootstrap"; |
|
32 | 32 | |
|
33 | 33 | //@import bootstrap3-switch |
|
34 | 34 | @import "bootstrap-toggle"; |
|
35 | 35 | @import "bootstrap-sortable"; |
|
36 | + @import "bootstrap-datetimepicker"; | |
|
37 | + @import "dataTables/bootstrap/3/jquery.dataTables.bootstrap"; | |
|
36 | 38 | |
|
37 | 39 | //bootstrap navbar color (from) |
|
38 | 40 | $bgDefault: #19197b; |
|
39 | 41 | $bgHighlight: #06064b; |
|
40 | 42 | $colDefault: #8e8eb4; |
|
41 | 43 | $colHighlight: #ffffff; |
|
42 | 44 | $dropDown: false; |
|
43 | 45 | |
|
44 | 46 | @font-face { |
|
45 | 47 | font-family: 'Glyphicons Halflings'; |
|
46 | 48 | src: font-path('bootstrap/glyphicons-halflings-regular.eot'); |
|
47 | 49 | src: font-path('bootstrap/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), |
|
48 | 50 | font-path('bootstrap/glyphicons-halflings-regular.woff') format('woff'), |
|
49 | 51 | font-path('bootstrap/glyphicons-halflings-regular.ttf') format('truetype'), |
|
50 | 52 | font-path('bootstrap/glyphicons-halflings-regular.svg#glyphicons-halflingsregular') format('svg'); |
|
51 | 53 | } |
|
52 | 54 | |
|
53 | 55 | |
|
54 | 56 | .navbar-default { |
|
55 | 57 | background-color: $bgDefault; |
|
56 | 58 | border-color: $bgHighlight; |
|
57 | 59 | |
|
58 | 60 | .navbar-brand { |
|
59 | 61 | color: $colDefault; |
|
60 | 62 | |
|
61 | 63 | &:hover, &:focus { |
|
62 | 64 | color: $colHighlight; |
|
63 | 65 | } |
|
64 | 66 | } |
|
65 | 67 | |
|
66 | 68 | .navbar-text { |
|
67 | 69 | color: $colDefault; |
|
68 | 70 | } |
|
69 | 71 | |
|
70 | 72 | .navbar-nav { |
|
71 | 73 | > li { |
|
72 | 74 | > a { |
|
73 | 75 | color: $colDefault; |
|
74 | 76 | |
|
75 | 77 | &:hover, &:focus { |
|
76 | 78 | color: $colHighlight; |
|
77 | 79 | } |
|
78 | 80 | } |
|
79 | 81 | |
|
80 | 82 | @if $dropDown { |
|
81 | 83 | > .dropdown-menu { |
|
82 | 84 | background-color: $bgDefault; |
|
83 | 85 |
@@ -1,57 +1,63 | |||
|
1 | 1 | class LoginController < ApplicationController |
|
2 | 2 | |
|
3 | 3 | def index |
|
4 | 4 | # show login screen |
|
5 | 5 | reset_session |
|
6 | 6 | redirect_to :controller => 'main', :action => 'login' |
|
7 | 7 | end |
|
8 | 8 | |
|
9 | 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 | 18 | flash[:notice] = 'You must accept the agreement before logging in' |
|
12 | 19 | redirect_to :controller => 'main', :action => 'login' |
|
13 | - elsif user = User.authenticate(params[:login], params[:password]) | |
|
20 | + return | |
|
21 | + end | |
|
22 | + | |
|
23 | + #process logging in | |
|
14 | 24 |
|
|
15 | 25 |
|
|
16 | 26 | |
|
17 | 27 |
|
|
18 | 28 |
|
|
19 | 29 |
|
|
20 | 30 |
|
|
21 | 31 |
|
|
22 | 32 |
|
|
23 | 33 |
|
|
24 | 34 |
|
|
25 | 35 |
|
|
26 | 36 |
|
|
27 | 37 | |
|
28 | 38 |
|
|
29 | 39 |
|
|
30 | 40 | |
|
31 | 41 |
|
|
32 | - else | |
|
33 | - flash[:notice] = 'Wrong password' | |
|
34 | - redirect_to :controller => 'main', :action => 'login' | |
|
35 | - end | |
|
36 | 42 | end |
|
37 | 43 | |
|
38 | 44 | def site_login |
|
39 | 45 | begin |
|
40 | 46 | site = Site.find(params[:login][:site_id]) |
|
41 | 47 | rescue ActiveRecord::RecordNotFound |
|
42 | 48 | site = nil |
|
43 | 49 | end |
|
44 | 50 | if site==nil |
|
45 | 51 | flash[:notice] = 'Wrong site' |
|
46 | 52 | redirect_to :controller => 'main', :action => 'login' and return |
|
47 | 53 | end |
|
48 | 54 | if (site.password) and (site.password == params[:login][:password]) |
|
49 | 55 | session[:site_id] = site.id |
|
50 | 56 | redirect_to :controller => 'site', :action => 'index' |
|
51 | 57 | else |
|
52 | 58 | flash[:notice] = 'Wrong site password' |
|
53 | 59 | redirect_to :controller => 'site', :action => 'login' |
|
54 | 60 | end |
|
55 | 61 | end |
|
56 | 62 | |
|
57 | 63 | end |
@@ -1,74 +1,75 | |||
|
1 | 1 | require 'csv' |
|
2 | 2 | |
|
3 | 3 | class UserAdminController < ApplicationController |
|
4 | 4 | |
|
5 | 5 | include MailHelperMethods |
|
6 | 6 | |
|
7 | 7 | before_filter :admin_authorization |
|
8 | 8 | |
|
9 | 9 | # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) |
|
10 | 10 | verify :method => :post, :only => [ |
|
11 | 11 | :create, :create_from_list, |
|
12 | 12 | :update, |
|
13 | 13 | :manage_contest, |
|
14 | 14 | :bulk_mail |
|
15 | 15 | ], |
|
16 | 16 | :redirect_to => { :action => :list } |
|
17 | 17 | |
|
18 | 18 | def index |
|
19 | 19 | @user_count = User.count |
|
20 | 20 | if params[:page] == 'all' |
|
21 | 21 | @users = User.all |
|
22 | 22 | @paginated = false |
|
23 | 23 | else |
|
24 | 24 | @users = User.paginate :page => params[:page] |
|
25 | 25 | @paginated = true |
|
26 | 26 | end |
|
27 | + @users = User.all | |
|
27 | 28 | @hidden_columns = ['hashed_password', 'salt', 'created_at', 'updated_at'] |
|
28 | 29 | @contests = Contest.enabled |
|
29 | 30 | end |
|
30 | 31 | |
|
31 | 32 | def active |
|
32 | 33 | sessions = ActiveRecord::SessionStore::Session.where("updated_at >= ?", 60.minutes.ago) |
|
33 | 34 | @users = [] |
|
34 | 35 | sessions.each do |session| |
|
35 | 36 | if session.data[:user_id] |
|
36 | 37 | @users << User.find(session.data[:user_id]) |
|
37 | 38 | end |
|
38 | 39 | end |
|
39 | 40 | end |
|
40 | 41 | |
|
41 | 42 | def show |
|
42 | 43 | @user = User.find(params[:id]) |
|
43 | 44 | end |
|
44 | 45 | |
|
45 | 46 | def new |
|
46 | 47 | @user = User.new |
|
47 | 48 | end |
|
48 | 49 | |
|
49 | 50 | def create |
|
50 | 51 | @user = User.new(user_params) |
|
51 | 52 | @user.activated = true |
|
52 | 53 | if @user.save |
|
53 | 54 | flash[:notice] = 'User was successfully created.' |
|
54 | 55 | redirect_to :action => 'index' |
|
55 | 56 | else |
|
56 | 57 | render :action => 'new' |
|
57 | 58 | end |
|
58 | 59 | end |
|
59 | 60 | |
|
60 | 61 | def clear_last_ip |
|
61 | 62 | @user = User.find(params[:id]) |
|
62 | 63 | @user.last_ip = nil |
|
63 | 64 | @user.save |
|
64 | 65 | redirect_to action: 'index', page: params[:page] |
|
65 | 66 | end |
|
66 | 67 | |
|
67 | 68 | def create_from_list |
|
68 | 69 | lines = params[:user_list] |
|
69 | 70 | |
|
70 | 71 | note = [] |
|
71 | 72 | |
|
72 | 73 | lines.split("\n").each do |line| |
|
73 | 74 | items = line.chomp.split(',') |
|
74 | 75 | if items.length>=2 |
@@ -11,91 +11,96 | |||
|
11 | 11 | .form-group |
|
12 | 12 | = label_tag 'user_full_name', 'Full Name' |
|
13 | 13 | = text_field 'user', 'full_name', :size => 10,class: 'form-control' |
|
14 | 14 | .form-group |
|
15 | 15 | = label_tag 'user_password', 'Password' |
|
16 | 16 | = text_field 'user', 'password', :size => 10,class: 'form-control' |
|
17 | 17 | .form-group |
|
18 | 18 | = label_tag 'user_password_confirmation', 'Confirm' |
|
19 | 19 | = text_field 'user', 'password_confirmation', :size => 10,class: 'form-control' |
|
20 | 20 | .form-group |
|
21 | 21 | = label_tag 'user_email', 'email' |
|
22 | 22 | = text_field 'user', 'email', :size => 10,class: 'form-control' |
|
23 | 23 | =submit_tag "Create", class: 'btn btn-primary' |
|
24 | 24 | |
|
25 | 25 | .panel.panel-primary |
|
26 | 26 | .panel-title.panel-heading |
|
27 | 27 | Import from site management |
|
28 | 28 | .panel-body |
|
29 | 29 | = form_tag({:action => 'import'}, :multipart => true,class: 'form form-inline') do |
|
30 | 30 | .form-group |
|
31 | 31 | = label_tag :file, 'File:' |
|
32 | 32 | .input-group |
|
33 | 33 | %span.input-group-btn |
|
34 | 34 | %span.btn.btn-default.btn-file |
|
35 | 35 | Browse |
|
36 | 36 | = file_field_tag 'file' |
|
37 | 37 | = text_field_tag '' , nil, {readonly: true, class: 'form-control'} |
|
38 | 38 | = submit_tag 'Submit', class: 'btn btn-default' |
|
39 | 39 | |
|
40 | 40 | |
|
41 | 41 | %p |
|
42 | 42 | = link_to '+ New user', { :action => 'new' }, { class: 'btn btn-success '} |
|
43 | 43 | = link_to '+ New list of users', { :action => 'new_list' }, { class: 'btn btn-success '} |
|
44 | 44 | = link_to 'View administrators',{ :action => 'admin'}, { class: 'btn btn-default '} |
|
45 | 45 | = link_to 'Bulk Manage', bulk_manage_user_admin_path , { class: 'btn btn-default '} |
|
46 | 46 | = link_to 'Random passwords',{ :action => 'random_all_passwords'}, { class: 'btn btn-default '} |
|
47 | 47 | = link_to 'View active users',{ :action => 'active'}, { class: 'btn btn-default '} |
|
48 | 48 | = link_to 'Mass mailing',{ :action => 'mass_mailing'}, { class: 'btn btn-default '} |
|
49 | 49 | |
|
50 | 50 | - if GraderConfiguration.multicontests? |
|
51 | 51 | %br/ |
|
52 | 52 | %b Multi-contest: |
|
53 | 53 | = link_to '[Manage bulk users in contests]', :action => 'contest_management' |
|
54 | 54 | View users in: |
|
55 | 55 | - @contests.each do |contest| |
|
56 | 56 | = link_to "[#{contest.name}]", :action => 'contests', :id => contest.id |
|
57 | 57 | = link_to "[no contest]", :action => 'contests', :id => 'none' |
|
58 | 58 | |
|
59 | - Total #{@user_count} users | | |
|
60 | - - if !@paginated | |
|
61 |
- |
|
|
62 |
- |
|
|
63 | - - else | |
|
64 |
- |
|
|
65 |
- |
|
|
66 |
- |
|
|
59 | + -# Total #{@user_count} users | | |
|
60 | + -# - if !@paginated | |
|
61 | + -# Display all users. | |
|
62 | + -# \#{link_to '[show in pages]', :action => 'index', :page => '1'} | |
|
63 | + -# - else | |
|
64 | + -# Display in pages. | |
|
65 | + -# \#{link_to '[display all]', :action => 'index', :page => 'all'} | | |
|
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 | 70 | %thead |
|
71 | 71 | %th Login |
|
72 | 72 | %th Full name |
|
73 | 73 | %th email |
|
74 | 74 | %th Remark |
|
75 | 75 | %th |
|
76 | 76 | Activated |
|
77 | 77 | %sup{class: 'text-primary',data: {toggle: 'tooltip', placement: 'top'}, title: 'User has already confirmed the email?' } [?] |
|
78 | 78 | %th |
|
79 | 79 | Enabled |
|
80 | 80 | %sup{class: 'text-primary',data: {toggle: 'tooltip', placement: 'top'}, title: 'Allow the user to login?' } [?] |
|
81 | 81 | %th Last IP |
|
82 | 82 | %th |
|
83 | 83 | %th |
|
84 | 84 | %th |
|
85 | 85 | %th |
|
86 | 86 | - for user in @users |
|
87 | 87 | %tr |
|
88 | 88 | %td= link_to user.login, stat_user_path(user) |
|
89 | 89 | %td= user.full_name |
|
90 | 90 | %td= user.email |
|
91 | 91 | %td= user.remark |
|
92 | 92 | %td= toggle_button(user.activated?, toggle_activate_user_path(user),"toggle_activate_user_#{user.id}") |
|
93 | 93 | %td= toggle_button(user.enabled?, toggle_enable_user_path(user),"toggle_enable_user_#{user.id}") |
|
94 | 94 | %td= user.last_ip |
|
95 | 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 | 96 | %td= link_to 'Show', {:action => 'show', :id => user}, class: 'btn btn-default btn-xs btn-block' |
|
97 | 97 | %td= link_to 'Edit', {:action => 'edit', :id => user}, class: 'btn btn-default btn-xs btn-block' |
|
98 | 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 | 99 | %br/ |
|
100 | 100 | = link_to '+ New user', { :action => 'new' }, { class: 'btn btn-success '} |
|
101 | 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