Description:
wip: bootstrap toggle switch todo: add javascript that thisable button until reponse arrived
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r556:b4cf182747cd - - 9 files changed: 23 inserted, 4 deleted

@@ -1,71 +1,72
1 source 'https://rubygems.org'
1 source 'https://rubygems.org'
2
2
3 gem 'rails', '3.2.21'
3 gem 'rails', '3.2.21'
4
4
5 gem 'select2-rails'
5 gem 'select2-rails'
6
6
7 # Bundle edge Rails instead:
7 # Bundle edge Rails instead:
8 # gem 'rails', :git => 'git://github.com/rails/rails.git'
8 # gem 'rails', :git => 'git://github.com/rails/rails.git'
9
9
10 gem 'mysql2'
10 gem 'mysql2'
11
11
12 # Gems used only for assets and not required
12 # Gems used only for assets and not required
13 # in production environments by default.
13 # in production environments by default.
14 group :assets do
14 group :assets do
15 gem 'sass-rails', '~> 3.2.6'
15 gem 'sass-rails', '~> 3.2.6'
16 gem 'coffee-rails', '~> 3.2.2'
16 gem 'coffee-rails', '~> 3.2.2'
17
17
18 # See https://github.com/sstephenson/execjs#readme for more supported runtimes
18 # See https://github.com/sstephenson/execjs#readme for more supported runtimes
19 # gem 'therubyracer', :platforms => :ruby
19 # gem 'therubyracer', :platforms => :ruby
20
20
21 gem 'uglifier'
21 gem 'uglifier'
22 end
22 end
23
23
24 gem 'prototype-rails'
24 gem 'prototype-rails'
25
25
26 # To use ActiveModel has_secure_password
26 # To use ActiveModel has_secure_password
27 # gem 'bcrypt-ruby', '~> 3.0.0'
27 # gem 'bcrypt-ruby', '~> 3.0.0'
28
28
29 # To use Jbuilder templates for JSON
29 # To use Jbuilder templates for JSON
30 # gem 'jbuilder'
30 # gem 'jbuilder'
31
31
32 # Use unicorn as the app server
32 # Use unicorn as the app server
33 # gem 'unicorn'
33 # gem 'unicorn'
34
34
35 # Deploy with Capistrano
35 # Deploy with Capistrano
36 # gem 'capistrano'
36 # gem 'capistrano'
37
37
38 # To use debugger
38 # To use debugger
39 # gem 'debugger'
39 # gem 'debugger'
40 #
40 #
41
41
42 #in-place editor
42 #in-place editor
43 gem 'best_in_place', '~> 3.0.1'
43 gem 'best_in_place', '~> 3.0.1'
44
44
45 # jquery addition
45 # jquery addition
46 gem 'jquery-rails'
46 gem 'jquery-rails'
47 gem 'jquery-ui-sass-rails'
47 gem 'jquery-ui-sass-rails'
48 gem 'jquery-timepicker-addon-rails'
48 gem 'jquery-timepicker-addon-rails'
49 gem 'jquery-tablesorter'
49 gem 'jquery-tablesorter'
50
50
51 #syntax highlighter
51 #syntax highlighter
52 gem 'rouge'
52 gem 'rouge'
53
53
54 #add bootstrap
54 #add bootstrap
55 gem 'bootstrap-sass', '~> 3.2.0'
55 gem 'bootstrap-sass', '~> 3.2.0'
56 gem 'bootstrap-switch-rails'
56 gem 'bootstrap-switch-rails'
57 + gem 'bootstrap-toggle-rails'
57 gem 'autoprefixer-rails'
58 gem 'autoprefixer-rails'
58
59
59
60
60 gem 'haml'
61 gem 'haml'
61 gem 'mail'
62 gem 'mail'
62 gem 'rdiscount'
63 gem 'rdiscount'
63 gem 'test-unit'
64 gem 'test-unit'
64 gem 'will_paginate', '~> 3.0.7'
65 gem 'will_paginate', '~> 3.0.7'
65 gem 'dynamic_form'
66 gem 'dynamic_form'
66 gem 'in_place_editing'
67 gem 'in_place_editing'
67 gem 'verification', :git => 'https://github.com/sikachu/verification.git'
68 gem 'verification', :git => 'https://github.com/sikachu/verification.git'
68
69
69 group :test, :development do
70 group :test, :development do
70 gem 'rspec-rails', '~> 2.99.0'
71 gem 'rspec-rails', '~> 2.99.0'
71 end
72 end
@@ -1,187 +1,189
1 GIT
1 GIT
2 remote: https://github.com/sikachu/verification.git
2 remote: https://github.com/sikachu/verification.git
3 revision: 76eaf51b13276ecae54bd9cd115832595d2ff56d
3 revision: 76eaf51b13276ecae54bd9cd115832595d2ff56d
4 specs:
4 specs:
5 verification (1.0.3)
5 verification (1.0.3)
6 actionpack (>= 3.0.0, < 5.0)
6 actionpack (>= 3.0.0, < 5.0)
7 activesupport (>= 3.0.0, < 5.0)
7 activesupport (>= 3.0.0, < 5.0)
8
8
9 GEM
9 GEM
10 remote: https://rubygems.org/
10 remote: https://rubygems.org/
11 specs:
11 specs:
12 actionmailer (3.2.21)
12 actionmailer (3.2.21)
13 actionpack (= 3.2.21)
13 actionpack (= 3.2.21)
14 mail (~> 2.5.4)
14 mail (~> 2.5.4)
15 actionpack (3.2.21)
15 actionpack (3.2.21)
16 activemodel (= 3.2.21)
16 activemodel (= 3.2.21)
17 activesupport (= 3.2.21)
17 activesupport (= 3.2.21)
18 builder (~> 3.0.0)
18 builder (~> 3.0.0)
19 erubis (~> 2.7.0)
19 erubis (~> 2.7.0)
20 journey (~> 1.0.4)
20 journey (~> 1.0.4)
21 rack (~> 1.4.5)
21 rack (~> 1.4.5)
22 rack-cache (~> 1.2)
22 rack-cache (~> 1.2)
23 rack-test (~> 0.6.1)
23 rack-test (~> 0.6.1)
24 sprockets (~> 2.2.1)
24 sprockets (~> 2.2.1)
25 activemodel (3.2.21)
25 activemodel (3.2.21)
26 activesupport (= 3.2.21)
26 activesupport (= 3.2.21)
27 builder (~> 3.0.0)
27 builder (~> 3.0.0)
28 activerecord (3.2.21)
28 activerecord (3.2.21)
29 activemodel (= 3.2.21)
29 activemodel (= 3.2.21)
30 activesupport (= 3.2.21)
30 activesupport (= 3.2.21)
31 arel (~> 3.0.2)
31 arel (~> 3.0.2)
32 tzinfo (~> 0.3.29)
32 tzinfo (~> 0.3.29)
33 activeresource (3.2.21)
33 activeresource (3.2.21)
34 activemodel (= 3.2.21)
34 activemodel (= 3.2.21)
35 activesupport (= 3.2.21)
35 activesupport (= 3.2.21)
36 activesupport (3.2.21)
36 activesupport (3.2.21)
37 i18n (~> 0.6, >= 0.6.4)
37 i18n (~> 0.6, >= 0.6.4)
38 multi_json (~> 1.0)
38 multi_json (~> 1.0)
39 arel (3.0.3)
39 arel (3.0.3)
40 autoprefixer-rails (6.0.3)
40 autoprefixer-rails (6.0.3)
41 execjs
41 execjs
42 json
42 json
43 best_in_place (3.0.3)
43 best_in_place (3.0.3)
44 actionpack (>= 3.2)
44 actionpack (>= 3.2)
45 railties (>= 3.2)
45 railties (>= 3.2)
46 bootstrap-sass (3.2.0.2)
46 bootstrap-sass (3.2.0.2)
47 sass (~> 3.2)
47 sass (~> 3.2)
48 bootstrap-switch-rails (3.3.3)
48 bootstrap-switch-rails (3.3.3)
49 + bootstrap-toggle-rails (2.2.1.0)
49 builder (3.0.4)
50 builder (3.0.4)
50 coffee-rails (3.2.2)
51 coffee-rails (3.2.2)
51 coffee-script (>= 2.2.0)
52 coffee-script (>= 2.2.0)
52 railties (~> 3.2.0)
53 railties (~> 3.2.0)
53 coffee-script (2.3.0)
54 coffee-script (2.3.0)
54 coffee-script-source
55 coffee-script-source
55 execjs
56 execjs
56 coffee-script-source (1.9.0)
57 coffee-script-source (1.9.0)
57 diff-lcs (1.2.5)
58 diff-lcs (1.2.5)
58 dynamic_form (1.1.4)
59 dynamic_form (1.1.4)
59 erubis (2.7.0)
60 erubis (2.7.0)
60 execjs (2.3.0)
61 execjs (2.3.0)
61 haml (4.0.6)
62 haml (4.0.6)
62 tilt
63 tilt
63 hike (1.2.3)
64 hike (1.2.3)
64 i18n (0.7.0)
65 i18n (0.7.0)
65 in_place_editing (1.2.0)
66 in_place_editing (1.2.0)
66 journey (1.0.4)
67 journey (1.0.4)
67 jquery-rails (3.1.2)
68 jquery-rails (3.1.2)
68 railties (>= 3.0, < 5.0)
69 railties (>= 3.0, < 5.0)
69 thor (>= 0.14, < 2.0)
70 thor (>= 0.14, < 2.0)
70 jquery-tablesorter (1.13.4)
71 jquery-tablesorter (1.13.4)
71 railties (>= 3.1, < 5)
72 railties (>= 3.1, < 5)
72 jquery-timepicker-addon-rails (1.4.1)
73 jquery-timepicker-addon-rails (1.4.1)
73 railties (>= 3.1)
74 railties (>= 3.1)
74 jquery-ui-rails (4.0.3)
75 jquery-ui-rails (4.0.3)
75 jquery-rails
76 jquery-rails
76 railties (>= 3.1.0)
77 railties (>= 3.1.0)
77 jquery-ui-sass-rails (4.0.3.0)
78 jquery-ui-sass-rails (4.0.3.0)
78 jquery-rails
79 jquery-rails
79 jquery-ui-rails (= 4.0.3)
80 jquery-ui-rails (= 4.0.3)
80 railties (>= 3.1.0)
81 railties (>= 3.1.0)
81 json (1.8.2)
82 json (1.8.2)
82 mail (2.5.4)
83 mail (2.5.4)
83 mime-types (~> 1.16)
84 mime-types (~> 1.16)
84 treetop (~> 1.4.8)
85 treetop (~> 1.4.8)
85 mime-types (1.25.1)
86 mime-types (1.25.1)
86 multi_json (1.10.1)
87 multi_json (1.10.1)
87 mysql2 (0.3.20)
88 mysql2 (0.3.20)
88 polyglot (0.3.5)
89 polyglot (0.3.5)
89 power_assert (0.2.2)
90 power_assert (0.2.2)
90 prototype-rails (3.2.1)
91 prototype-rails (3.2.1)
91 rails (~> 3.2)
92 rails (~> 3.2)
92 rack (1.4.5)
93 rack (1.4.5)
93 rack-cache (1.2)
94 rack-cache (1.2)
94 rack (>= 0.4)
95 rack (>= 0.4)
95 rack-ssl (1.3.4)
96 rack-ssl (1.3.4)
96 rack
97 rack
97 rack-test (0.6.3)
98 rack-test (0.6.3)
98 rack (>= 1.0)
99 rack (>= 1.0)
99 rails (3.2.21)
100 rails (3.2.21)
100 actionmailer (= 3.2.21)
101 actionmailer (= 3.2.21)
101 actionpack (= 3.2.21)
102 actionpack (= 3.2.21)
102 activerecord (= 3.2.21)
103 activerecord (= 3.2.21)
103 activeresource (= 3.2.21)
104 activeresource (= 3.2.21)
104 activesupport (= 3.2.21)
105 activesupport (= 3.2.21)
105 bundler (~> 1.0)
106 bundler (~> 1.0)
106 railties (= 3.2.21)
107 railties (= 3.2.21)
107 railties (3.2.21)
108 railties (3.2.21)
108 actionpack (= 3.2.21)
109 actionpack (= 3.2.21)
109 activesupport (= 3.2.21)
110 activesupport (= 3.2.21)
110 rack-ssl (~> 1.3.2)
111 rack-ssl (~> 1.3.2)
111 rake (>= 0.8.7)
112 rake (>= 0.8.7)
112 rdoc (~> 3.4)
113 rdoc (~> 3.4)
113 thor (>= 0.14.6, < 2.0)
114 thor (>= 0.14.6, < 2.0)
114 rake (10.4.2)
115 rake (10.4.2)
115 rdiscount (2.1.8)
116 rdiscount (2.1.8)
116 rdoc (3.12.2)
117 rdoc (3.12.2)
117 json (~> 1.4)
118 json (~> 1.4)
118 rouge (1.8.0)
119 rouge (1.8.0)
119 rspec-collection_matchers (1.1.2)
120 rspec-collection_matchers (1.1.2)
120 rspec-expectations (>= 2.99.0.beta1)
121 rspec-expectations (>= 2.99.0.beta1)
121 rspec-core (2.99.2)
122 rspec-core (2.99.2)
122 rspec-expectations (2.99.2)
123 rspec-expectations (2.99.2)
123 diff-lcs (>= 1.1.3, < 2.0)
124 diff-lcs (>= 1.1.3, < 2.0)
124 rspec-mocks (2.99.3)
125 rspec-mocks (2.99.3)
125 rspec-rails (2.99.0)
126 rspec-rails (2.99.0)
126 actionpack (>= 3.0)
127 actionpack (>= 3.0)
127 activemodel (>= 3.0)
128 activemodel (>= 3.0)
128 activesupport (>= 3.0)
129 activesupport (>= 3.0)
129 railties (>= 3.0)
130 railties (>= 3.0)
130 rspec-collection_matchers
131 rspec-collection_matchers
131 rspec-core (~> 2.99.0)
132 rspec-core (~> 2.99.0)
132 rspec-expectations (~> 2.99.0)
133 rspec-expectations (~> 2.99.0)
133 rspec-mocks (~> 2.99.0)
134 rspec-mocks (~> 2.99.0)
134 sass (3.4.11)
135 sass (3.4.11)
135 sass-rails (3.2.6)
136 sass-rails (3.2.6)
136 railties (~> 3.2.0)
137 railties (~> 3.2.0)
137 sass (>= 3.1.10)
138 sass (>= 3.1.10)
138 tilt (~> 1.3)
139 tilt (~> 1.3)
139 select2-rails (4.0.1)
140 select2-rails (4.0.1)
140 thor (~> 0.14)
141 thor (~> 0.14)
141 sprockets (2.2.3)
142 sprockets (2.2.3)
142 hike (~> 1.2)
143 hike (~> 1.2)
143 multi_json (~> 1.0)
144 multi_json (~> 1.0)
144 rack (~> 1.0)
145 rack (~> 1.0)
145 tilt (~> 1.1, != 1.3.0)
146 tilt (~> 1.1, != 1.3.0)
146 test-unit (3.0.9)
147 test-unit (3.0.9)
147 power_assert
148 power_assert
148 thor (0.19.1)
149 thor (0.19.1)
149 tilt (1.4.1)
150 tilt (1.4.1)
150 treetop (1.4.15)
151 treetop (1.4.15)
151 polyglot
152 polyglot
152 polyglot (>= 0.3.1)
153 polyglot (>= 0.3.1)
153 tzinfo (0.3.43)
154 tzinfo (0.3.43)
154 uglifier (2.7.0)
155 uglifier (2.7.0)
155 execjs (>= 0.3.0)
156 execjs (>= 0.3.0)
156 json (>= 1.8.0)
157 json (>= 1.8.0)
157 will_paginate (3.0.7)
158 will_paginate (3.0.7)
158
159
159 PLATFORMS
160 PLATFORMS
160 ruby
161 ruby
161
162
162 DEPENDENCIES
163 DEPENDENCIES
163 autoprefixer-rails
164 autoprefixer-rails
164 best_in_place (~> 3.0.1)
165 best_in_place (~> 3.0.1)
165 bootstrap-sass (~> 3.2.0)
166 bootstrap-sass (~> 3.2.0)
166 bootstrap-switch-rails
167 bootstrap-switch-rails
168 + bootstrap-toggle-rails
167 coffee-rails (~> 3.2.2)
169 coffee-rails (~> 3.2.2)
168 dynamic_form
170 dynamic_form
169 haml
171 haml
170 in_place_editing
172 in_place_editing
171 jquery-rails
173 jquery-rails
172 jquery-tablesorter
174 jquery-tablesorter
173 jquery-timepicker-addon-rails
175 jquery-timepicker-addon-rails
174 jquery-ui-sass-rails
176 jquery-ui-sass-rails
175 mail
177 mail
176 mysql2
178 mysql2
177 prototype-rails
179 prototype-rails
178 rails (= 3.2.21)
180 rails (= 3.2.21)
179 rdiscount
181 rdiscount
180 rouge
182 rouge
181 rspec-rails (~> 2.99.0)
183 rspec-rails (~> 2.99.0)
182 sass-rails (~> 3.2.6)
184 sass-rails (~> 3.2.6)
183 select2-rails
185 select2-rails
184 test-unit
186 test-unit
185 uglifier
187 uglifier
186 verification!
188 verification!
187 will_paginate (~> 3.0.7)
189 will_paginate (~> 3.0.7)
@@ -1,27 +1,28
1 // This is a manifest file that'll be compiled into application.js, which will include all the files
1 // This is a manifest file that'll be compiled into application.js, which will include all the files
2 // listed below.
2 // listed below.
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 jquery.ui.all
15 //= require jquery.ui.all
16 //= require bootstrap-sprockets
16 //= require bootstrap-sprockets
17 - //= require bootstrap-switch
17 + //x= require bootstrap-switch
18 + //= require bootstrap-toggle
18 //= require select2
19 //= require select2
19 //= require custom
20 //= require custom
20
21
21
22
22 // since this is after blank line, it is not downloaded
23 // since this is after blank line, it is not downloaded
23 //x= require prototype
24 //x= require prototype
24 //x= require prototype_ujs
25 //x= require prototype_ujs
25 //x= require effects
26 //x= require effects
26 //x= require dragdrop
27 //x= require dragdrop
27 //x= require controls
28 //x= require controls
@@ -1,26 +1,27
1 $(document).on 'change', '.btn-file :file', ->
1 $(document).on 'change', '.btn-file :file', ->
2 input = $(this)
2 input = $(this)
3 numFiles = if input.get(0).files then input.get(0).files.length else 1
3 numFiles = if input.get(0).files then input.get(0).files.length else 1
4 label = input.val().replace(/\\/g, '/').replace(/.*\//, '')
4 label = input.val().replace(/\\/g, '/').replace(/.*\//, '')
5 input.trigger 'fileselect', [
5 input.trigger 'fileselect', [
6 numFiles
6 numFiles
7 label
7 label
8 ]
8 ]
9 return
9 return
10
10
11
11
12 # document ready
12 # document ready
13
13
14 $ ->
14 $ ->
15 $(".select2").select2()
15 $(".select2").select2()
16 - $(".bootstrap-switch").bootstrapSwitch()
16 + #$(".bootstrap-switch").bootstrapSwitch()
17 + $(".bootstrap-toggle").bootstrapToggle()
17 $('.btn-file :file').on 'fileselect', (event, numFiles, label) ->
18 $('.btn-file :file').on 'fileselect', (event, numFiles, label) ->
18 input = $(this).parents('.input-group').find(':text')
19 input = $(this).parents('.input-group').find(':text')
19 log = if numFiles > 1 then numFiles + ' files selected' else label
20 log = if numFiles > 1 then numFiles + ' files selected' else label
20 if input.length
21 if input.length
21 input.val log
22 input.val log
22 else
23 else
23 if log
24 if log
24 alert log
25 alert log
25 return
26 return
26 return
27 return
@@ -1,350 +1,351
1 /*
1 /*
2 * This is a manifest file that'll be compiled into application.css, which will include all the files
2 * This is a manifest file that'll be compiled into application.css, which will include all the files
3 * listed below.
3 * listed below.
4 *
4 *
5 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
5 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6 * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
6 * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7 *
7 *
8 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
8 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9 * compiled file so the styles you add here take precedence over styles defined in any styles
9 * compiled file so the styles you add here take precedence over styles defined in any styles
10 * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
10 * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11 * file per style scope.
11 * file per style scope.
12 *
12 *
13 // bootstrap says that we should not do this, but @import each file instead
13 // bootstrap says that we should not do this, but @import each file instead
14 # *= require_tree .
14 # *= require_tree .
15 # *= require_self
15 # *= require_self
16 */
16 */
17
17
18 @import jquery.ui.all
18 @import jquery.ui.all
19 @import jquery.ui.core
19 @import jquery.ui.core
20 @import jquery.ui.core
20 @import jquery.ui.core
21 @import jquery.ui.theme
21 @import jquery.ui.theme
22 @import jquery.ui.datepicker
22 @import jquery.ui.datepicker
23 @import jquery.ui.slider
23 @import jquery.ui.slider
24 @import jquery-ui-timepicker-addon
24 @import jquery-ui-timepicker-addon
25 @import jquery-tablesorter/theme.metro-dark
25 @import jquery-tablesorter/theme.metro-dark
26 @import tablesorter-theme.cafe
26 @import tablesorter-theme.cafe
27
27
28 //bootstrap
28 //bootstrap
29 @import bootstrap-sprockets
29 @import bootstrap-sprockets
30 @import bootstrap
30 @import bootstrap
31 @import select2
31 @import select2
32 @import select2-bootstrap
32 @import select2-bootstrap
33 - @import bootstrap3-switch
33 + //@import bootstrap3-switch
34 + @import bootstrap-toggle
34
35
35 .secondnavbar
36 .secondnavbar
36 top: 50px
37 top: 50px
37
38
38 .btn-file
39 .btn-file
39 position: relative
40 position: relative
40 overflow: hidden
41 overflow: hidden
41
42
42 .btn-file input[type=file]
43 .btn-file input[type=file]
43 position: absolute
44 position: absolute
44 top: 0
45 top: 0
45 right: 0
46 right: 0
46 min-width: 100%
47 min-width: 100%
47 min-height: 100%
48 min-height: 100%
48 font-size: 100px
49 font-size: 100px
49 text-align: right
50 text-align: right
50 filter: alpha(opacity=0)
51 filter: alpha(opacity=0)
51 opacity: 0
52 opacity: 0
52 outline: none
53 outline: none
53 background: white
54 background: white
54 cursor: inherit
55 cursor: inherit
55 display: block
56 display: block
56
57
57 body
58 body
58 background: white image-url("topbg.jpg") repeat-x top center
59 background: white image-url("topbg.jpg") repeat-x top center
59 //font-size: 13px
60 //font-size: 13px
60 //font-family: Tahoma, "sans-serif"
61 //font-family: Tahoma, "sans-serif"
61 margin: 10px
62 margin: 10px
62 padding: 10px
63 padding: 10px
63 padding-top: 100px
64 padding-top: 100px
64
65
65
66
66 input
67 input
67 font-family: Tahoma, "sans-serif"
68 font-family: Tahoma, "sans-serif"
68
69
69
70
70 h1
71 h1
71 font-size: 24px
72 font-size: 24px
72 color: #334488
73 color: #334488
73 line-height: 2em
74 line-height: 2em
74
75
75
76
76 h2
77 h2
77 font-size: 18px
78 font-size: 18px
78 color: #5566bb
79 color: #5566bb
79 line-height: 1.5em
80 line-height: 1.5em
80
81
81
82
82 hr
83 hr
83 border-top: 1px solid #dddddd
84 border-top: 1px solid #dddddd
84 border-bottom: 1px solid #eeeeee
85 border-bottom: 1px solid #eeeeee
85
86
86
87
87 a
88 a
88 color: #6666cc
89 color: #6666cc
89 text-decoration: none
90 text-decoration: none
90
91
91 &:link, &:visited
92 &:link, &:visited
92 color: #6666cc
93 color: #6666cc
93 text-decoration: none
94 text-decoration: none
94
95
95 &:hover, &:focus
96 &:hover, &:focus
96 color: #111166
97 color: #111166
97 text-decoration: none
98 text-decoration: none
98
99
99
100
100 div
101 div
101 &.userbar
102 &.userbar
102 line-height: 1.5em
103 line-height: 1.5em
103 text-align: right
104 text-align: right
104 font-size: 12px
105 font-size: 12px
105
106
106 &.title
107 &.title
107 padding: 10px 0px
108 padding: 10px 0px
108 line-height: 1.5em
109 line-height: 1.5em
109 font-size: 13px
110 font-size: 13px
110
111
111 span.contest-over-msg
112 span.contest-over-msg
112 font-size: 15px
113 font-size: 15px
113 color: red
114 color: red
114
115
115 table
116 table
116 width: 100%
117 width: 100%
117 font-weight: bold
118 font-weight: bold
118
119
119 td
120 td
120 &.left-col
121 &.left-col
121 text-align: left
122 text-align: left
122 vertical-align: top
123 vertical-align: top
123 color: #444444
124 color: #444444
124
125
125 &.right-col
126 &.right-col
126 text-align: right
127 text-align: right
127 vertical-align: top
128 vertical-align: top
128 font-size: 18px
129 font-size: 18px
129 color: #116699
130 color: #116699
130
131
131
132
132 table.info
133 table.info
133 margin: 10px 0
134 margin: 10px 0
134 border: 1px solid #666666
135 border: 1px solid #666666
135 border-collapse: collapse
136 border-collapse: collapse
136 font-size: 12px
137 font-size: 12px
137
138
138 th
139 th
139 border: 1px solid #666666
140 border: 1px solid #666666
140 line-height: 1.5em
141 line-height: 1.5em
141 padding: 0 0.5em
142 padding: 0 0.5em
142
143
143 td
144 td
144 border-left: 1px solid #666666
145 border-left: 1px solid #666666
145 border-right: 1px solid #666666
146 border-right: 1px solid #666666
146 line-height: 1.5em
147 line-height: 1.5em
147 padding: 0 0.5em
148 padding: 0 0.5em
148
149
149
150
150 tr
151 tr
151 &.info-head
152 &.info-head
152 background: #777777
153 background: #777777
153 color: white
154 color: white
154
155
155 &.info-odd
156 &.info-odd
156 background: #eeeeee
157 background: #eeeeee
157
158
158 &.info-even
159 &.info-even
159 background: #fcfcfc
160 background: #fcfcfc
160
161
161 =basicbox
162 =basicbox
162 background: #eeeeff
163 background: #eeeeff
163 border: 1px dotted #99aaee
164 border: 1px dotted #99aaee
164 padding: 5px
165 padding: 5px
165 margin: 10px 0px
166 margin: 10px 0px
166 color: black
167 color: black
167 font-size: 13px
168 font-size: 13px
168
169
169 .infobox
170 .infobox
170 +basicbox
171 +basicbox
171
172
172 .submitbox
173 .submitbox
173 +basicbox
174 +basicbox
174
175
175 .errorExplanation
176 .errorExplanation
176 border: 1px dotted gray
177 border: 1px dotted gray
177 color: #bb2222
178 color: #bb2222
178 padding: 5px 15px 5px 15px
179 padding: 5px 15px 5px 15px
179 margin-bottom: 5px
180 margin-bottom: 5px
180 background-color: white
181 background-color: white
181 font-weight: normal
182 font-weight: normal
182
183
183 h2
184 h2
184 color: #cc1111
185 color: #cc1111
185 font-weight: bold
186 font-weight: bold
186
187
187
188
188 table.uinfo
189 table.uinfo
189 border-collapse: collapse
190 border-collapse: collapse
190 border: 1px solid black
191 border: 1px solid black
191 font-size: 13px
192 font-size: 13px
192
193
193
194
194 td.uinfo
195 td.uinfo
195 vertical-align: top
196 vertical-align: top
196 border: 1px solid black
197 border: 1px solid black
197 padding: 5px
198 padding: 5px
198
199
199
200
200 th.uinfo
201 th.uinfo
201 background: lightgreen
202 background: lightgreen
202 vertical-align: top
203 vertical-align: top
203 text-align: right
204 text-align: right
204 border: 1px solid black
205 border: 1px solid black
205 padding: 5px
206 padding: 5px
206
207
207
208
208 div
209 div
209 &.compilermsgbody
210 &.compilermsgbody
210 font-family: monospace
211 font-family: monospace
211
212
212 &.task-menu
213 &.task-menu
213 text-align: center
214 text-align: center
214 font-size: 13px
215 font-size: 13px
215 line-height: 1.75em
216 line-height: 1.75em
216 font-weight: bold
217 font-weight: bold
217 border-top: 1px dashed gray
218 border-top: 1px dashed gray
218 border-bottom: 1px dashed gray
219 border-bottom: 1px dashed gray
219 margin-top: 2px
220 margin-top: 2px
220 margin-bottom: 4px
221 margin-bottom: 4px
221
222
222
223
223 table.taskdesc
224 table.taskdesc
224 border: 2px solid #dddddd
225 border: 2px solid #dddddd
225 border-collapse: collapse
226 border-collapse: collapse
226 margin: 10px auto
227 margin: 10px auto
227 width: 90%
228 width: 90%
228 font-size: 13px
229 font-size: 13px
229
230
230 p
231 p
231 font-size: 13px
232 font-size: 13px
232
233
233 tr.name
234 tr.name
234 border: 2px solid #dddddd
235 border: 2px solid #dddddd
235 background: #dddddd
236 background: #dddddd
236 color: #333333
237 color: #333333
237 font-weight: bold
238 font-weight: bold
238 font-size: 14px
239 font-size: 14px
239 line-height: 1.5em
240 line-height: 1.5em
240 text-align: center
241 text-align: center
241
242
242 td
243 td
243 &.desc-odd
244 &.desc-odd
244 padding: 5px
245 padding: 5px
245 padding-left: 20px
246 padding-left: 20px
246 background: #fefeee
247 background: #fefeee
247
248
248 &.desc-even
249 &.desc-even
249 padding: 5px
250 padding: 5px
250 padding-left: 20px
251 padding-left: 20px
251 background: #feeefe
252 background: #feeefe
252
253
253
254
254 .announcementbox
255 .announcementbox
255 margin: 10px 0px
256 margin: 10px 0px
256 background: #bbddee
257 background: #bbddee
257 padding: 1px
258 padding: 1px
258
259
259 span.title
260 span.title
260 font-weight: bold
261 font-weight: bold
261 color: #224455
262 color: #224455
262 padding-left: 10px
263 padding-left: 10px
263 line-height: 1.6em
264 line-height: 1.6em
264
265
265 .announcement
266 .announcement
266 margin: 2px
267 margin: 2px
267 background: white
268 background: white
268 padding: 1px
269 padding: 1px
269 padding-left: 10px
270 padding-left: 10px
270 padding-right: 10px
271 padding-right: 10px
271 padding-top: 5px
272 padding-top: 5px
272 padding-bottom: 5px
273 padding-bottom: 5px
273
274
274
275
275 .announcement p
276 .announcement p
276 font-size: 12px
277 font-size: 12px
277 margin: 2px
278 margin: 2px
278
279
279
280
280 .pub-info
281 .pub-info
281 text-align: right
282 text-align: right
282 font-style: italic
283 font-style: italic
283 font-size: 9px
284 font-size: 9px
284
285
285 p
286 p
286 text-align: right
287 text-align: right
287 font-style: italic
288 font-style: italic
288 font-size: 9px
289 font-size: 9px
289
290
290
291
291 .announcement
292 .announcement
292 .toggles
293 .toggles
293 font-weight: normal
294 font-weight: normal
294 float: right
295 float: right
295 font-size: 80%
296 font-size: 80%
296
297
297 .announcement-title
298 .announcement-title
298 font-weight: bold
299 font-weight: bold
299
300
300
301
301 div
302 div
302 &.message
303 &.message
303 margin: 10px 0 0
304 margin: 10px 0 0
304
305
305 div
306 div
306 &.message
307 &.message
307 margin: 0 0 0 30px
308 margin: 0 0 0 30px
308
309
309 &.body
310 &.body
310 border: 2px solid #dddddd
311 border: 2px solid #dddddd
311 background: #fff8f8
312 background: #fff8f8
312 padding-left: 5px
313 padding-left: 5px
313
314
314 &.reply-body
315 &.reply-body
315 border: 2px solid #bbbbbb
316 border: 2px solid #bbbbbb
316 background: #fffff8
317 background: #fffff8
317 padding-left: 5px
318 padding-left: 5px
318
319
319 &.stat
320 &.stat
320 font-size: 10px
321 font-size: 10px
321 line-height: 1.75em
322 line-height: 1.75em
322 padding: 0 5px
323 padding: 0 5px
323 color: #333333
324 color: #333333
324 background: #dddddd
325 background: #dddddd
325 font-weight: bold
326 font-weight: bold
326
327
327 &.message div.stat
328 &.message div.stat
328 font-size: 10px
329 font-size: 10px
329 line-height: 1.75em
330 line-height: 1.75em
330 padding: 0 5px
331 padding: 0 5px
331 color: #444444
332 color: #444444
332 background: #bbbbbb
333 background: #bbbbbb
333 font-weight: bold
334 font-weight: bold
334
335
335 &.contest-title
336 &.contest-title
336 color: white
337 color: white
337 text-align: center
338 text-align: center
338 line-height: 2em
339 line-height: 2em
339
340
340 &.registration-desc, &.test-desc
341 &.registration-desc, &.test-desc
341 border: 1px dotted gray
342 border: 1px dotted gray
342 background: #f5f5f5
343 background: #f5f5f5
343 padding: 5px
344 padding: 5px
344 margin: 10px 0
345 margin: 10px 0
345 font-size: 12px
346 font-size: 12px
346 line-height: 1.5em
347 line-height: 1.5em
347
348
348 h2.contest-title
349 h2.contest-title
349 margin-top: 5px
350 margin-top: 5px
350 margin-bottom: 5px
351 margin-bottom: 5px
@@ -1,91 +1,101
1 class AnnouncementsController < ApplicationController
1 class AnnouncementsController < ApplicationController
2
2
3 before_filter :admin_authorization
3 before_filter :admin_authorization
4
4
5 in_place_edit_for :announcement, :published
5 in_place_edit_for :announcement, :published
6
6
7 # GET /announcements
7 # GET /announcements
8 # GET /announcements.xml
8 # GET /announcements.xml
9 def index
9 def index
10 @announcements = Announcement.find(:all,
10 @announcements = Announcement.find(:all,
11 :order => "created_at DESC")
11 :order => "created_at DESC")
12
12
13 respond_to do |format|
13 respond_to do |format|
14 format.html # index.html.erb
14 format.html # index.html.erb
15 format.xml { render :xml => @announcements }
15 format.xml { render :xml => @announcements }
16 end
16 end
17 end
17 end
18
18
19 # GET /announcements/1
19 # GET /announcements/1
20 # GET /announcements/1.xml
20 # GET /announcements/1.xml
21 def show
21 def show
22 @announcement = Announcement.find(params[:id])
22 @announcement = Announcement.find(params[:id])
23
23
24 respond_to do |format|
24 respond_to do |format|
25 format.html # show.html.erb
25 format.html # show.html.erb
26 format.xml { render :xml => @announcement }
26 format.xml { render :xml => @announcement }
27 end
27 end
28 end
28 end
29
29
30 # GET /announcements/new
30 # GET /announcements/new
31 # GET /announcements/new.xml
31 # GET /announcements/new.xml
32 def new
32 def new
33 @announcement = Announcement.new
33 @announcement = Announcement.new
34
34
35 respond_to do |format|
35 respond_to do |format|
36 format.html # new.html.erb
36 format.html # new.html.erb
37 format.xml { render :xml => @announcement }
37 format.xml { render :xml => @announcement }
38 end
38 end
39 end
39 end
40
40
41 # GET /announcements/1/edit
41 # GET /announcements/1/edit
42 def edit
42 def edit
43 @announcement = Announcement.find(params[:id])
43 @announcement = Announcement.find(params[:id])
44 end
44 end
45
45
46 # POST /announcements
46 # POST /announcements
47 # POST /announcements.xml
47 # POST /announcements.xml
48 def create
48 def create
49 @announcement = Announcement.new(params[:announcement])
49 @announcement = Announcement.new(params[:announcement])
50
50
51 respond_to do |format|
51 respond_to do |format|
52 if @announcement.save
52 if @announcement.save
53 flash[:notice] = 'Announcement was successfully created.'
53 flash[:notice] = 'Announcement was successfully created.'
54 format.html { redirect_to(@announcement) }
54 format.html { redirect_to(@announcement) }
55 format.xml { render :xml => @announcement, :status => :created, :location => @announcement }
55 format.xml { render :xml => @announcement, :status => :created, :location => @announcement }
56 else
56 else
57 format.html { render :action => "new" }
57 format.html { render :action => "new" }
58 format.xml { render :xml => @announcement.errors, :status => :unprocessable_entity }
58 format.xml { render :xml => @announcement.errors, :status => :unprocessable_entity }
59 end
59 end
60 end
60 end
61 end
61 end
62
62
63 # PUT /announcements/1
63 # PUT /announcements/1
64 # PUT /announcements/1.xml
64 # PUT /announcements/1.xml
65 def update
65 def update
66 @announcement = Announcement.find(params[:id])
66 @announcement = Announcement.find(params[:id])
67
67
68 respond_to do |format|
68 respond_to do |format|
69 if @announcement.update_attributes(params[:announcement])
69 if @announcement.update_attributes(params[:announcement])
70 flash[:notice] = 'Announcement was successfully updated.'
70 flash[:notice] = 'Announcement was successfully updated.'
71 format.html { redirect_to(@announcement) }
71 format.html { redirect_to(@announcement) }
72 + format.js {}
72 format.xml { head :ok }
73 format.xml { head :ok }
73 else
74 else
74 format.html { render :action => "edit" }
75 format.html { render :action => "edit" }
76 + format.js {}
75 format.xml { render :xml => @announcement.errors, :status => :unprocessable_entity }
77 format.xml { render :xml => @announcement.errors, :status => :unprocessable_entity }
76 end
78 end
77 end
79 end
78 end
80 end
79
81
82 + def toggle
83 + @announcement = Announcement.find(params[:id])
84 + @announcement.update_attributes( published: params[:published] == 1)
85 + respond_to do |format|
86 + format.js {}
87 + end
88 + end
89 +
80 # DELETE /announcements/1
90 # DELETE /announcements/1
81 # DELETE /announcements/1.xml
91 # DELETE /announcements/1.xml
82 def destroy
92 def destroy
83 @announcement = Announcement.find(params[:id])
93 @announcement = Announcement.find(params[:id])
84 @announcement.destroy
94 @announcement.destroy
85
95
86 respond_to do |format|
96 respond_to do |format|
87 format.html { redirect_to(announcements_url) }
97 format.html { redirect_to(announcements_url) }
88 format.xml { head :ok }
98 format.xml { head :ok }
89 end
99 end
90 end
100 end
91 end
101 end
@@ -1,118 +1,119
1 class ApplicationController < ActionController::Base
1 class ApplicationController < ActionController::Base
2 protect_from_forgery
2 protect_from_forgery
3
3
4 before_filter :current_user
4 before_filter :current_user
5
5
6 SINGLE_USER_MODE_CONF_KEY = 'system.single_user_mode'
6 SINGLE_USER_MODE_CONF_KEY = 'system.single_user_mode'
7 MULTIPLE_IP_LOGIN_CONF_KEY = 'right.multiple_ip_login'
7 MULTIPLE_IP_LOGIN_CONF_KEY = 'right.multiple_ip_login'
8
8
9 # Returns the current logged-in user (if any).
9 # Returns the current logged-in user (if any).
10 def current_user
10 def current_user
11 + return nil unless session[:user_id]
11 @current_user ||= User.find(session[:user_id])
12 @current_user ||= User.find(session[:user_id])
12 end
13 end
13
14
14 def admin_authorization
15 def admin_authorization
15 return false unless authenticate
16 return false unless authenticate
16 user = User.find(session[:user_id], :include => ['roles'])
17 user = User.find(session[:user_id], :include => ['roles'])
17 unless user.admin?
18 unless user.admin?
18 flash[:notice] = 'You are not authorized to view the page you requested'
19 flash[:notice] = 'You are not authorized to view the page you requested'
19 redirect_to :controller => 'main', :action => 'login' unless user.admin?
20 redirect_to :controller => 'main', :action => 'login' unless user.admin?
20 return false
21 return false
21 end
22 end
22 return true
23 return true
23 end
24 end
24
25
25 def authorization_by_roles(allowed_roles)
26 def authorization_by_roles(allowed_roles)
26 return false unless authenticate
27 return false unless authenticate
27 user = User.find(session[:user_id])
28 user = User.find(session[:user_id])
28 unless user.roles.detect { |role| allowed_roles.member?(role.name) }
29 unless user.roles.detect { |role| allowed_roles.member?(role.name) }
29 flash[:notice] = 'You are not authorized to view the page you requested'
30 flash[:notice] = 'You are not authorized to view the page you requested'
30 redirect_to :controller => 'main', :action => 'login'
31 redirect_to :controller => 'main', :action => 'login'
31 return false
32 return false
32 end
33 end
33 end
34 end
34
35
35 protected
36 protected
36
37
37 def authenticate
38 def authenticate
38 unless session[:user_id]
39 unless session[:user_id]
39 flash[:notice] = 'You need to login'
40 flash[:notice] = 'You need to login'
40 if GraderConfiguration[SINGLE_USER_MODE_CONF_KEY]
41 if GraderConfiguration[SINGLE_USER_MODE_CONF_KEY]
41 flash[:notice] = 'You need to login but you cannot log in at this time'
42 flash[:notice] = 'You need to login but you cannot log in at this time'
42 end
43 end
43 redirect_to :controller => 'main', :action => 'login'
44 redirect_to :controller => 'main', :action => 'login'
44 return false
45 return false
45 end
46 end
46
47
47 # check if run in single user mode
48 # check if run in single user mode
48 if GraderConfiguration[SINGLE_USER_MODE_CONF_KEY]
49 if GraderConfiguration[SINGLE_USER_MODE_CONF_KEY]
49 user = User.find(session[:user_id])
50 user = User.find(session[:user_id])
50 if user==nil or (not user.admin?)
51 if user==nil or (not user.admin?)
51 flash[:notice] = 'You cannot log in at this time'
52 flash[:notice] = 'You cannot log in at this time'
52 redirect_to :controller => 'main', :action => 'login'
53 redirect_to :controller => 'main', :action => 'login'
53 return false
54 return false
54 end
55 end
55 return true
56 return true
56 end
57 end
57
58
58 if GraderConfiguration.multicontests?
59 if GraderConfiguration.multicontests?
59 user = User.find(session[:user_id])
60 user = User.find(session[:user_id])
60 return true if user.admin?
61 return true if user.admin?
61 begin
62 begin
62 if user.contest_stat(true).forced_logout
63 if user.contest_stat(true).forced_logout
63 flash[:notice] = 'You have been automatically logged out.'
64 flash[:notice] = 'You have been automatically logged out.'
64 redirect_to :controller => 'main', :action => 'index'
65 redirect_to :controller => 'main', :action => 'index'
65 end
66 end
66 rescue
67 rescue
67 end
68 end
68 end
69 end
69 return true
70 return true
70 end
71 end
71
72
72 def authenticate_by_ip_address
73 def authenticate_by_ip_address
73 #this assume that we have already authenticate normally
74 #this assume that we have already authenticate normally
74 unless GraderConfiguration[MULTIPLE_IP_LOGIN_CONF_KEY]
75 unless GraderConfiguration[MULTIPLE_IP_LOGIN_CONF_KEY]
75 user = User.find(session[:user_id])
76 user = User.find(session[:user_id])
76 if (not user.admin? and user.last_ip and user.last_ip != request.remote_ip)
77 if (not user.admin? and user.last_ip and user.last_ip != request.remote_ip)
77 flash[:notice] = "You cannot use the system from #{request.remote_ip}. Your last ip is #{user.last_ip}"
78 flash[:notice] = "You cannot use the system from #{request.remote_ip}. Your last ip is #{user.last_ip}"
78 redirect_to :controller => 'main', :action => 'login'
79 redirect_to :controller => 'main', :action => 'login'
79 puts "CHEAT: user #{user.login} tried to login from '#{request.remote_ip}' while last ip is '#{user.last_ip}' at #{Time.zone.now}"
80 puts "CHEAT: user #{user.login} tried to login from '#{request.remote_ip}' while last ip is '#{user.last_ip}' at #{Time.zone.now}"
80 return false
81 return false
81 end
82 end
82 unless user.last_ip
83 unless user.last_ip
83 user.last_ip = request.remote_ip
84 user.last_ip = request.remote_ip
84 user.save
85 user.save
85 end
86 end
86 end
87 end
87 return true
88 return true
88 end
89 end
89
90
90 def authorization
91 def authorization
91 return false unless authenticate
92 return false unless authenticate
92 user = User.find(session[:user_id])
93 user = User.find(session[:user_id])
93 unless user.roles.detect { |role|
94 unless user.roles.detect { |role|
94 role.rights.detect{ |right|
95 role.rights.detect{ |right|
95 right.controller == self.class.controller_name and
96 right.controller == self.class.controller_name and
96 (right.action == 'all' or right.action == action_name)
97 (right.action == 'all' or right.action == action_name)
97 }
98 }
98 }
99 }
99 flash[:notice] = 'You are not authorized to view the page you requested'
100 flash[:notice] = 'You are not authorized to view the page you requested'
100 #request.env['HTTP_REFERER'] ? (redirect_to :back) : (redirect_to :controller => 'login')
101 #request.env['HTTP_REFERER'] ? (redirect_to :back) : (redirect_to :controller => 'login')
101 redirect_to :controller => 'main', :action => 'login'
102 redirect_to :controller => 'main', :action => 'login'
102 return false
103 return false
103 end
104 end
104 end
105 end
105
106
106 def verify_time_limit
107 def verify_time_limit
107 return true if session[:user_id]==nil
108 return true if session[:user_id]==nil
108 user = User.find(session[:user_id], :include => :site)
109 user = User.find(session[:user_id], :include => :site)
109 return true if user==nil or user.site == nil
110 return true if user==nil or user.site == nil
110 if user.contest_finished?
111 if user.contest_finished?
111 flash[:notice] = 'Error: the contest you are participating is over.'
112 flash[:notice] = 'Error: the contest you are participating is over.'
112 redirect_to :back
113 redirect_to :back
113 return false
114 return false
114 end
115 end
115 return true
116 return true
116 end
117 end
117
118
118 end
119 end
@@ -1,41 +1,41
1 <h1>Listing announcements</h1>
1 <h1>Listing announcements</h1>
2
2
3 <%= link_to 'New announcement', new_announcement_path %>
3 <%= link_to 'New announcement', new_announcement_path %>
4
4
5 <table class="info">
5 <table class="info">
6 <tr class="info-head">
6 <tr class="info-head">
7 <th>Updated</th>
7 <th>Updated</th>
8 <th>Announcement</th>
8 <th>Announcement</th>
9 <th>Author</th>
9 <th>Author</th>
10 <th>Published</th>
10 <th>Published</th>
11 <th></th>
11 <th></th>
12 <th></th>
12 <th></th>
13 <th></th>
13 <th></th>
14 </tr>
14 </tr>
15
15
16 <% for announcement in @announcements %>
16 <% for announcement in @announcements %>
17 <tr class="info-<%= cycle 'odd', 'even' %>">
17 <tr class="info-<%= cycle 'odd', 'even' %>">
18 <% @announcement = announcement %>
18 <% @announcement = announcement %>
19 <td><%= time_ago_in_words announcement.updated_at %></td>
19 <td><%= time_ago_in_words announcement.updated_at %></td>
20 <td>
20 <td>
21 <% if !announcement.title.blank? %>
21 <% if !announcement.title.blank? %>
22 <b>Title:</b> <%=h announcement.title %><br/>
22 <b>Title:</b> <%=h announcement.title %><br/>
23 <% end %>
23 <% end %>
24 <% if !announcement.notes.blank? %>
24 <% if !announcement.notes.blank? %>
25 <b>Notes: <%=h announcement.notes %></b><br/>
25 <b>Notes: <%=h announcement.notes %></b><br/>
26 <% end %>
26 <% end %>
27 <%=h announcement.body %>
27 <%=h announcement.body %>
28 </td>
28 </td>
29 <td><%=h announcement.author %></td>
29 <td><%=h announcement.author %></td>
30 - <td><%= check_box_tag :published, 1, announcement.published, class: 'bootstrap-switch', data: {size: 'small'} %></td>
30 + <td><%= check_box_tag :published, 1, announcement.published, { class: 'bootstrap-toggle', id: "published-#{announcement.id}", data: {remote: true, method: 'PUT', url: url_for(controller: :announcements, action: :toggle, id: announcement), size: 'small', toggle: 'toggle' } } %></td>
31 <!-- <td><%= in_place_editor_field :announcement, :published, {}, :rows => 1 %></td> -->
31 <!-- <td><%= in_place_editor_field :announcement, :published, {}, :rows => 1 %></td> -->
32 <td><%= link_to 'Show', announcement %></td>
32 <td><%= link_to 'Show', announcement %></td>
33 <td><%= link_to 'Edit', edit_announcement_path(announcement) %></td>
33 <td><%= link_to 'Edit', edit_announcement_path(announcement) %></td>
34 <td><%= link_to 'Destroy', announcement, :confirm => 'Are you sure?', :method => :delete %></td>
34 <td><%= link_to 'Destroy', announcement, :confirm => 'Are you sure?', :method => :delete %></td>
35 </tr>
35 </tr>
36 <% end %>
36 <% end %>
37 </table>
37 </table>
38
38
39 <br />
39 <br />
40
40
41 <%= link_to 'New announcement', new_announcement_path %>
41 <%= link_to 'New announcement', new_announcement_path %>
@@ -1,25 +1,27
1 CafeGrader::Application.routes.draw do
1 CafeGrader::Application.routes.draw do
2 root :to => 'main#login'
2 root :to => 'main#login'
3
3
4 get "report/login"
4 get "report/login"
5
5
6 resources :contests
6 resources :contests
7
7
8 resources :announcements
8 resources :announcements
9 + match 'announcements/toggle/:id' => 'announcements#toggle', via: :put
10 +
9 resources :sites
11 resources :sites
10
12
11 resources :grader_configuration, controller: 'configurations'
13 resources :grader_configuration, controller: 'configurations'
12
14
13 match 'tasks/view/:file.:ext' => 'tasks#view'
15 match 'tasks/view/:file.:ext' => 'tasks#view'
14 match 'tasks/download/:id/:file.:ext' => 'tasks#download'
16 match 'tasks/download/:id/:file.:ext' => 'tasks#download'
15 match 'heartbeat/:id/edit' => 'heartbeat#edit'
17 match 'heartbeat/:id/edit' => 'heartbeat#edit'
16
18
17 #main
19 #main
18 get "main/list"
20 get "main/list"
19
21
20 # See how all your routes lay out with "rake routes"
22 # See how all your routes lay out with "rake routes"
21
23
22 # This is a legacy wild controller route that's not recommended for RESTful applications.
24 # This is a legacy wild controller route that's not recommended for RESTful applications.
23 # Note: This route will make all actions in every controller accessible via GET requests.
25 # Note: This route will make all actions in every controller accessible via GET requests.
24 match ':controller(/:action(/:id))(.:format)'
26 match ':controller(/:action(/:id))(.:format)'
25 end
27 end
You need to be logged in to leave comments. Login now