Description:
wip: bootstrap toggle switch
todo: add javascript that thisable button until reponse arrived
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r556:b4cf182747cd - - 9 files changed: 23 inserted, 4 deleted
@@ -9,63 +9,64 | |||
|
9 | 9 | |
|
10 | 10 | gem 'mysql2' |
|
11 | 11 | |
|
12 | 12 | # Gems used only for assets and not required |
|
13 | 13 | # in production environments by default. |
|
14 | 14 | group :assets do |
|
15 | 15 | gem 'sass-rails', '~> 3.2.6' |
|
16 | 16 | gem 'coffee-rails', '~> 3.2.2' |
|
17 | 17 | |
|
18 | 18 | # See https://github.com/sstephenson/execjs#readme for more supported runtimes |
|
19 | 19 | # gem 'therubyracer', :platforms => :ruby |
|
20 | 20 | |
|
21 | 21 | gem 'uglifier' |
|
22 | 22 | end |
|
23 | 23 | |
|
24 | 24 | gem 'prototype-rails' |
|
25 | 25 | |
|
26 | 26 | # To use ActiveModel has_secure_password |
|
27 | 27 | # gem 'bcrypt-ruby', '~> 3.0.0' |
|
28 | 28 | |
|
29 | 29 | # To use Jbuilder templates for JSON |
|
30 | 30 | # gem 'jbuilder' |
|
31 | 31 | |
|
32 | 32 | # Use unicorn as the app server |
|
33 | 33 | # gem 'unicorn' |
|
34 | 34 | |
|
35 | 35 | # Deploy with Capistrano |
|
36 | 36 | # gem 'capistrano' |
|
37 | 37 | |
|
38 | 38 | # To use debugger |
|
39 | 39 | # gem 'debugger' |
|
40 | 40 | # |
|
41 | 41 | |
|
42 | 42 | #in-place editor |
|
43 | 43 | gem 'best_in_place', '~> 3.0.1' |
|
44 | 44 | |
|
45 | 45 | # jquery addition |
|
46 | 46 | gem 'jquery-rails' |
|
47 | 47 | gem 'jquery-ui-sass-rails' |
|
48 | 48 | gem 'jquery-timepicker-addon-rails' |
|
49 | 49 | gem 'jquery-tablesorter' |
|
50 | 50 | |
|
51 | 51 | #syntax highlighter |
|
52 | 52 | gem 'rouge' |
|
53 | 53 | |
|
54 | 54 | #add bootstrap |
|
55 | 55 | gem 'bootstrap-sass', '~> 3.2.0' |
|
56 | 56 | gem 'bootstrap-switch-rails' |
|
57 | + gem 'bootstrap-toggle-rails' | |
|
57 | 58 | gem 'autoprefixer-rails' |
|
58 | 59 | |
|
59 | 60 | |
|
60 | 61 | gem 'haml' |
|
61 | 62 | gem 'mail' |
|
62 | 63 | gem 'rdiscount' |
|
63 | 64 | gem 'test-unit' |
|
64 | 65 | gem 'will_paginate', '~> 3.0.7' |
|
65 | 66 | gem 'dynamic_form' |
|
66 | 67 | gem 'in_place_editing' |
|
67 | 68 | gem 'verification', :git => 'https://github.com/sikachu/verification.git' |
|
68 | 69 | |
|
69 | 70 | group :test, :development do |
|
70 | 71 | gem 'rspec-rails', '~> 2.99.0' |
|
71 | 72 | end |
@@ -1,96 +1,97 | |||
|
1 | 1 | GIT |
|
2 | 2 | remote: https://github.com/sikachu/verification.git |
|
3 | 3 | revision: 76eaf51b13276ecae54bd9cd115832595d2ff56d |
|
4 | 4 | specs: |
|
5 | 5 | verification (1.0.3) |
|
6 | 6 | actionpack (>= 3.0.0, < 5.0) |
|
7 | 7 | activesupport (>= 3.0.0, < 5.0) |
|
8 | 8 | |
|
9 | 9 | GEM |
|
10 | 10 | remote: https://rubygems.org/ |
|
11 | 11 | specs: |
|
12 | 12 | actionmailer (3.2.21) |
|
13 | 13 | actionpack (= 3.2.21) |
|
14 | 14 | mail (~> 2.5.4) |
|
15 | 15 | actionpack (3.2.21) |
|
16 | 16 | activemodel (= 3.2.21) |
|
17 | 17 | activesupport (= 3.2.21) |
|
18 | 18 | builder (~> 3.0.0) |
|
19 | 19 | erubis (~> 2.7.0) |
|
20 | 20 | journey (~> 1.0.4) |
|
21 | 21 | rack (~> 1.4.5) |
|
22 | 22 | rack-cache (~> 1.2) |
|
23 | 23 | rack-test (~> 0.6.1) |
|
24 | 24 | sprockets (~> 2.2.1) |
|
25 | 25 | activemodel (3.2.21) |
|
26 | 26 | activesupport (= 3.2.21) |
|
27 | 27 | builder (~> 3.0.0) |
|
28 | 28 | activerecord (3.2.21) |
|
29 | 29 | activemodel (= 3.2.21) |
|
30 | 30 | activesupport (= 3.2.21) |
|
31 | 31 | arel (~> 3.0.2) |
|
32 | 32 | tzinfo (~> 0.3.29) |
|
33 | 33 | activeresource (3.2.21) |
|
34 | 34 | activemodel (= 3.2.21) |
|
35 | 35 | activesupport (= 3.2.21) |
|
36 | 36 | activesupport (3.2.21) |
|
37 | 37 | i18n (~> 0.6, >= 0.6.4) |
|
38 | 38 | multi_json (~> 1.0) |
|
39 | 39 | arel (3.0.3) |
|
40 | 40 | autoprefixer-rails (6.0.3) |
|
41 | 41 | execjs |
|
42 | 42 | json |
|
43 | 43 | best_in_place (3.0.3) |
|
44 | 44 | actionpack (>= 3.2) |
|
45 | 45 | railties (>= 3.2) |
|
46 | 46 | bootstrap-sass (3.2.0.2) |
|
47 | 47 | sass (~> 3.2) |
|
48 | 48 | bootstrap-switch-rails (3.3.3) |
|
49 | + bootstrap-toggle-rails (2.2.1.0) | |
|
49 | 50 | builder (3.0.4) |
|
50 | 51 | coffee-rails (3.2.2) |
|
51 | 52 | coffee-script (>= 2.2.0) |
|
52 | 53 | railties (~> 3.2.0) |
|
53 | 54 | coffee-script (2.3.0) |
|
54 | 55 | coffee-script-source |
|
55 | 56 | execjs |
|
56 | 57 | coffee-script-source (1.9.0) |
|
57 | 58 | diff-lcs (1.2.5) |
|
58 | 59 | dynamic_form (1.1.4) |
|
59 | 60 | erubis (2.7.0) |
|
60 | 61 | execjs (2.3.0) |
|
61 | 62 | haml (4.0.6) |
|
62 | 63 | tilt |
|
63 | 64 | hike (1.2.3) |
|
64 | 65 | i18n (0.7.0) |
|
65 | 66 | in_place_editing (1.2.0) |
|
66 | 67 | journey (1.0.4) |
|
67 | 68 | jquery-rails (3.1.2) |
|
68 | 69 | railties (>= 3.0, < 5.0) |
|
69 | 70 | thor (>= 0.14, < 2.0) |
|
70 | 71 | jquery-tablesorter (1.13.4) |
|
71 | 72 | railties (>= 3.1, < 5) |
|
72 | 73 | jquery-timepicker-addon-rails (1.4.1) |
|
73 | 74 | railties (>= 3.1) |
|
74 | 75 | jquery-ui-rails (4.0.3) |
|
75 | 76 | jquery-rails |
|
76 | 77 | railties (>= 3.1.0) |
|
77 | 78 | jquery-ui-sass-rails (4.0.3.0) |
|
78 | 79 | jquery-rails |
|
79 | 80 | jquery-ui-rails (= 4.0.3) |
|
80 | 81 | railties (>= 3.1.0) |
|
81 | 82 | json (1.8.2) |
|
82 | 83 | mail (2.5.4) |
|
83 | 84 | mime-types (~> 1.16) |
|
84 | 85 | treetop (~> 1.4.8) |
|
85 | 86 | mime-types (1.25.1) |
|
86 | 87 | multi_json (1.10.1) |
|
87 | 88 | mysql2 (0.3.20) |
|
88 | 89 | polyglot (0.3.5) |
|
89 | 90 | power_assert (0.2.2) |
|
90 | 91 | prototype-rails (3.2.1) |
|
91 | 92 | rails (~> 3.2) |
|
92 | 93 | rack (1.4.5) |
|
93 | 94 | rack-cache (1.2) |
|
94 | 95 | rack (>= 0.4) |
|
95 | 96 | rack-ssl (1.3.4) |
|
96 | 97 | rack |
@@ -119,69 +120,70 | |||
|
119 | 120 | rspec-collection_matchers (1.1.2) |
|
120 | 121 | rspec-expectations (>= 2.99.0.beta1) |
|
121 | 122 | rspec-core (2.99.2) |
|
122 | 123 | rspec-expectations (2.99.2) |
|
123 | 124 | diff-lcs (>= 1.1.3, < 2.0) |
|
124 | 125 | rspec-mocks (2.99.3) |
|
125 | 126 | rspec-rails (2.99.0) |
|
126 | 127 | actionpack (>= 3.0) |
|
127 | 128 | activemodel (>= 3.0) |
|
128 | 129 | activesupport (>= 3.0) |
|
129 | 130 | railties (>= 3.0) |
|
130 | 131 | rspec-collection_matchers |
|
131 | 132 | rspec-core (~> 2.99.0) |
|
132 | 133 | rspec-expectations (~> 2.99.0) |
|
133 | 134 | rspec-mocks (~> 2.99.0) |
|
134 | 135 | sass (3.4.11) |
|
135 | 136 | sass-rails (3.2.6) |
|
136 | 137 | railties (~> 3.2.0) |
|
137 | 138 | sass (>= 3.1.10) |
|
138 | 139 | tilt (~> 1.3) |
|
139 | 140 | select2-rails (4.0.1) |
|
140 | 141 | thor (~> 0.14) |
|
141 | 142 | sprockets (2.2.3) |
|
142 | 143 | hike (~> 1.2) |
|
143 | 144 | multi_json (~> 1.0) |
|
144 | 145 | rack (~> 1.0) |
|
145 | 146 | tilt (~> 1.1, != 1.3.0) |
|
146 | 147 | test-unit (3.0.9) |
|
147 | 148 | power_assert |
|
148 | 149 | thor (0.19.1) |
|
149 | 150 | tilt (1.4.1) |
|
150 | 151 | treetop (1.4.15) |
|
151 | 152 | polyglot |
|
152 | 153 | polyglot (>= 0.3.1) |
|
153 | 154 | tzinfo (0.3.43) |
|
154 | 155 | uglifier (2.7.0) |
|
155 | 156 | execjs (>= 0.3.0) |
|
156 | 157 | json (>= 1.8.0) |
|
157 | 158 | will_paginate (3.0.7) |
|
158 | 159 | |
|
159 | 160 | PLATFORMS |
|
160 | 161 | ruby |
|
161 | 162 | |
|
162 | 163 | DEPENDENCIES |
|
163 | 164 | autoprefixer-rails |
|
164 | 165 | best_in_place (~> 3.0.1) |
|
165 | 166 | bootstrap-sass (~> 3.2.0) |
|
166 | 167 | bootstrap-switch-rails |
|
168 | + bootstrap-toggle-rails | |
|
167 | 169 | coffee-rails (~> 3.2.2) |
|
168 | 170 | dynamic_form |
|
169 | 171 | haml |
|
170 | 172 | in_place_editing |
|
171 | 173 | jquery-rails |
|
172 | 174 | jquery-tablesorter |
|
173 | 175 | jquery-timepicker-addon-rails |
|
174 | 176 | jquery-ui-sass-rails |
|
175 | 177 | |
|
176 | 178 | mysql2 |
|
177 | 179 | prototype-rails |
|
178 | 180 | rails (= 3.2.21) |
|
179 | 181 | rdiscount |
|
180 | 182 | rouge |
|
181 | 183 | rspec-rails (~> 2.99.0) |
|
182 | 184 | sass-rails (~> 3.2.6) |
|
183 | 185 | select2-rails |
|
184 | 186 | test-unit |
|
185 | 187 | uglifier |
|
186 | 188 | verification! |
|
187 | 189 | will_paginate (~> 3.0.7) |
@@ -1,27 +1,28 | |||
|
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 | 15 | //= require jquery.ui.all |
|
16 | 16 | //= require bootstrap-sprockets |
|
17 | - //= require bootstrap-switch | |
|
17 | + //x= require bootstrap-switch | |
|
18 | + //= require bootstrap-toggle | |
|
18 | 19 | //= require select2 |
|
19 | 20 | //= require custom |
|
20 | 21 | |
|
21 | 22 | |
|
22 | 23 | // since this is after blank line, it is not downloaded |
|
23 | 24 | //x= require prototype |
|
24 | 25 | //x= require prototype_ujs |
|
25 | 26 | //x= require effects |
|
26 | 27 | //x= require dragdrop |
|
27 | 28 | //x= require controls |
@@ -1,26 +1,27 | |||
|
1 | 1 | $(document).on 'change', '.btn-file :file', -> |
|
2 | 2 | input = $(this) |
|
3 | 3 | numFiles = if input.get(0).files then input.get(0).files.length else 1 |
|
4 | 4 | label = input.val().replace(/\\/g, '/').replace(/.*\//, '') |
|
5 | 5 | input.trigger 'fileselect', [ |
|
6 | 6 | numFiles |
|
7 | 7 | label |
|
8 | 8 | ] |
|
9 | 9 | return |
|
10 | 10 | |
|
11 | 11 | |
|
12 | 12 | # document ready |
|
13 | 13 | |
|
14 | 14 | $ -> |
|
15 | 15 | $(".select2").select2() |
|
16 | - $(".bootstrap-switch").bootstrapSwitch() | |
|
16 | + #$(".bootstrap-switch").bootstrapSwitch() | |
|
17 | + $(".bootstrap-toggle").bootstrapToggle() | |
|
17 | 18 | $('.btn-file :file').on 'fileselect', (event, numFiles, label) -> |
|
18 | 19 | input = $(this).parents('.input-group').find(':text') |
|
19 | 20 | log = if numFiles > 1 then numFiles + ' files selected' else label |
|
20 | 21 | if input.length |
|
21 | 22 | input.val log |
|
22 | 23 | else |
|
23 | 24 | if log |
|
24 | 25 | alert log |
|
25 | 26 | return |
|
26 | 27 | return |
@@ -1,81 +1,82 | |||
|
1 | 1 | /* |
|
2 | 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files |
|
3 | 3 | * listed below. |
|
4 | 4 | * |
|
5 | 5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, |
|
6 | 6 | * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path. |
|
7 | 7 | * |
|
8 | 8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the |
|
9 | 9 | * compiled file so the styles you add here take precedence over styles defined in any styles |
|
10 | 10 | * defined in the other CSS/SCSS files in this directory. It is generally better to create a new |
|
11 | 11 | * file per style scope. |
|
12 | 12 | * |
|
13 | 13 | // bootstrap says that we should not do this, but @import each file instead |
|
14 | 14 | # *= require_tree . |
|
15 | 15 | # *= require_self |
|
16 | 16 | */ |
|
17 | 17 | |
|
18 | 18 | @import jquery.ui.all |
|
19 | 19 | @import jquery.ui.core |
|
20 | 20 | @import jquery.ui.core |
|
21 | 21 | @import jquery.ui.theme |
|
22 | 22 | @import jquery.ui.datepicker |
|
23 | 23 | @import jquery.ui.slider |
|
24 | 24 | @import jquery-ui-timepicker-addon |
|
25 | 25 | @import jquery-tablesorter/theme.metro-dark |
|
26 | 26 | @import tablesorter-theme.cafe |
|
27 | 27 | |
|
28 | 28 | //bootstrap |
|
29 | 29 | @import bootstrap-sprockets |
|
30 | 30 | @import bootstrap |
|
31 | 31 | @import select2 |
|
32 | 32 | @import select2-bootstrap |
|
33 | - @import bootstrap3-switch | |
|
33 | + //@import bootstrap3-switch | |
|
34 | + @import bootstrap-toggle | |
|
34 | 35 | |
|
35 | 36 | .secondnavbar |
|
36 | 37 | top: 50px |
|
37 | 38 | |
|
38 | 39 | .btn-file |
|
39 | 40 | position: relative |
|
40 | 41 | overflow: hidden |
|
41 | 42 | |
|
42 | 43 | .btn-file input[type=file] |
|
43 | 44 | position: absolute |
|
44 | 45 | top: 0 |
|
45 | 46 | right: 0 |
|
46 | 47 | min-width: 100% |
|
47 | 48 | min-height: 100% |
|
48 | 49 | font-size: 100px |
|
49 | 50 | text-align: right |
|
50 | 51 | filter: alpha(opacity=0) |
|
51 | 52 | opacity: 0 |
|
52 | 53 | outline: none |
|
53 | 54 | background: white |
|
54 | 55 | cursor: inherit |
|
55 | 56 | display: block |
|
56 | 57 | |
|
57 | 58 | body |
|
58 | 59 | background: white image-url("topbg.jpg") repeat-x top center |
|
59 | 60 | //font-size: 13px |
|
60 | 61 | //font-family: Tahoma, "sans-serif" |
|
61 | 62 | margin: 10px |
|
62 | 63 | padding: 10px |
|
63 | 64 | padding-top: 100px |
|
64 | 65 | |
|
65 | 66 | |
|
66 | 67 | input |
|
67 | 68 | font-family: Tahoma, "sans-serif" |
|
68 | 69 | |
|
69 | 70 | |
|
70 | 71 | h1 |
|
71 | 72 | font-size: 24px |
|
72 | 73 | color: #334488 |
|
73 | 74 | line-height: 2em |
|
74 | 75 | |
|
75 | 76 | |
|
76 | 77 | h2 |
|
77 | 78 | font-size: 18px |
|
78 | 79 | color: #5566bb |
|
79 | 80 | line-height: 1.5em |
|
80 | 81 | |
|
81 | 82 |
@@ -24,68 +24,78 | |||
|
24 | 24 | respond_to do |format| |
|
25 | 25 | format.html # show.html.erb |
|
26 | 26 | format.xml { render :xml => @announcement } |
|
27 | 27 | end |
|
28 | 28 | end |
|
29 | 29 | |
|
30 | 30 | # GET /announcements/new |
|
31 | 31 | # GET /announcements/new.xml |
|
32 | 32 | def new |
|
33 | 33 | @announcement = Announcement.new |
|
34 | 34 | |
|
35 | 35 | respond_to do |format| |
|
36 | 36 | format.html # new.html.erb |
|
37 | 37 | format.xml { render :xml => @announcement } |
|
38 | 38 | end |
|
39 | 39 | end |
|
40 | 40 | |
|
41 | 41 | # GET /announcements/1/edit |
|
42 | 42 | def edit |
|
43 | 43 | @announcement = Announcement.find(params[:id]) |
|
44 | 44 | end |
|
45 | 45 | |
|
46 | 46 | # POST /announcements |
|
47 | 47 | # POST /announcements.xml |
|
48 | 48 | def create |
|
49 | 49 | @announcement = Announcement.new(params[:announcement]) |
|
50 | 50 | |
|
51 | 51 | respond_to do |format| |
|
52 | 52 | if @announcement.save |
|
53 | 53 | flash[:notice] = 'Announcement was successfully created.' |
|
54 | 54 | format.html { redirect_to(@announcement) } |
|
55 | 55 | format.xml { render :xml => @announcement, :status => :created, :location => @announcement } |
|
56 | 56 | else |
|
57 | 57 | format.html { render :action => "new" } |
|
58 | 58 | format.xml { render :xml => @announcement.errors, :status => :unprocessable_entity } |
|
59 | 59 | end |
|
60 | 60 | end |
|
61 | 61 | end |
|
62 | 62 | |
|
63 | 63 | # PUT /announcements/1 |
|
64 | 64 | # PUT /announcements/1.xml |
|
65 | 65 | def update |
|
66 | 66 | @announcement = Announcement.find(params[:id]) |
|
67 | 67 | |
|
68 | 68 | respond_to do |format| |
|
69 | 69 | if @announcement.update_attributes(params[:announcement]) |
|
70 | 70 | flash[:notice] = 'Announcement was successfully updated.' |
|
71 | 71 | format.html { redirect_to(@announcement) } |
|
72 | + format.js {} | |
|
72 | 73 | format.xml { head :ok } |
|
73 | 74 | else |
|
74 | 75 | format.html { render :action => "edit" } |
|
76 | + format.js {} | |
|
75 | 77 | format.xml { render :xml => @announcement.errors, :status => :unprocessable_entity } |
|
76 | 78 | end |
|
77 | 79 | end |
|
78 | 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 | 90 | # DELETE /announcements/1 |
|
81 | 91 | # DELETE /announcements/1.xml |
|
82 | 92 | def destroy |
|
83 | 93 | @announcement = Announcement.find(params[:id]) |
|
84 | 94 | @announcement.destroy |
|
85 | 95 | |
|
86 | 96 | respond_to do |format| |
|
87 | 97 | format.html { redirect_to(announcements_url) } |
|
88 | 98 | format.xml { head :ok } |
|
89 | 99 | end |
|
90 | 100 | end |
|
91 | 101 | end |
@@ -1,58 +1,59 | |||
|
1 | 1 | class ApplicationController < ActionController::Base |
|
2 | 2 | protect_from_forgery |
|
3 | 3 | |
|
4 | 4 | before_filter :current_user |
|
5 | 5 | |
|
6 | 6 | SINGLE_USER_MODE_CONF_KEY = 'system.single_user_mode' |
|
7 | 7 | MULTIPLE_IP_LOGIN_CONF_KEY = 'right.multiple_ip_login' |
|
8 | 8 | |
|
9 | 9 | # Returns the current logged-in user (if any). |
|
10 | 10 | def current_user |
|
11 | + return nil unless session[:user_id] | |
|
11 | 12 | @current_user ||= User.find(session[:user_id]) |
|
12 | 13 | end |
|
13 | 14 | |
|
14 | 15 | def admin_authorization |
|
15 | 16 | return false unless authenticate |
|
16 | 17 | user = User.find(session[:user_id], :include => ['roles']) |
|
17 | 18 | unless user.admin? |
|
18 | 19 | flash[:notice] = 'You are not authorized to view the page you requested' |
|
19 | 20 | redirect_to :controller => 'main', :action => 'login' unless user.admin? |
|
20 | 21 | return false |
|
21 | 22 | end |
|
22 | 23 | return true |
|
23 | 24 | end |
|
24 | 25 | |
|
25 | 26 | def authorization_by_roles(allowed_roles) |
|
26 | 27 | return false unless authenticate |
|
27 | 28 | user = User.find(session[:user_id]) |
|
28 | 29 | unless user.roles.detect { |role| allowed_roles.member?(role.name) } |
|
29 | 30 | flash[:notice] = 'You are not authorized to view the page you requested' |
|
30 | 31 | redirect_to :controller => 'main', :action => 'login' |
|
31 | 32 | return false |
|
32 | 33 | end |
|
33 | 34 | end |
|
34 | 35 | |
|
35 | 36 | protected |
|
36 | 37 | |
|
37 | 38 | def authenticate |
|
38 | 39 | unless session[:user_id] |
|
39 | 40 | flash[:notice] = 'You need to login' |
|
40 | 41 | if GraderConfiguration[SINGLE_USER_MODE_CONF_KEY] |
|
41 | 42 | flash[:notice] = 'You need to login but you cannot log in at this time' |
|
42 | 43 | end |
|
43 | 44 | redirect_to :controller => 'main', :action => 'login' |
|
44 | 45 | return false |
|
45 | 46 | end |
|
46 | 47 | |
|
47 | 48 | # check if run in single user mode |
|
48 | 49 | if GraderConfiguration[SINGLE_USER_MODE_CONF_KEY] |
|
49 | 50 | user = User.find(session[:user_id]) |
|
50 | 51 | if user==nil or (not user.admin?) |
|
51 | 52 | flash[:notice] = 'You cannot log in at this time' |
|
52 | 53 | redirect_to :controller => 'main', :action => 'login' |
|
53 | 54 | return false |
|
54 | 55 | end |
|
55 | 56 | return true |
|
56 | 57 | end |
|
57 | 58 | |
|
58 | 59 | if GraderConfiguration.multicontests? |
@@ -1,41 +1,41 | |||
|
1 | 1 | <h1>Listing announcements</h1> |
|
2 | 2 | |
|
3 | 3 | <%= link_to 'New announcement', new_announcement_path %> |
|
4 | 4 | |
|
5 | 5 | <table class="info"> |
|
6 | 6 | <tr class="info-head"> |
|
7 | 7 | <th>Updated</th> |
|
8 | 8 | <th>Announcement</th> |
|
9 | 9 | <th>Author</th> |
|
10 | 10 | <th>Published</th> |
|
11 | 11 | <th></th> |
|
12 | 12 | <th></th> |
|
13 | 13 | <th></th> |
|
14 | 14 | </tr> |
|
15 | 15 | |
|
16 | 16 | <% for announcement in @announcements %> |
|
17 | 17 | <tr class="info-<%= cycle 'odd', 'even' %>"> |
|
18 | 18 | <% @announcement = announcement %> |
|
19 | 19 | <td><%= time_ago_in_words announcement.updated_at %></td> |
|
20 | 20 | <td> |
|
21 | 21 | <% if !announcement.title.blank? %> |
|
22 | 22 | <b>Title:</b> <%=h announcement.title %><br/> |
|
23 | 23 | <% end %> |
|
24 | 24 | <% if !announcement.notes.blank? %> |
|
25 | 25 | <b>Notes: <%=h announcement.notes %></b><br/> |
|
26 | 26 | <% end %> |
|
27 | 27 | <%=h announcement.body %> |
|
28 | 28 | </td> |
|
29 | 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 | 31 | <!-- <td><%= in_place_editor_field :announcement, :published, {}, :rows => 1 %></td> --> |
|
32 | 32 | <td><%= link_to 'Show', announcement %></td> |
|
33 | 33 | <td><%= link_to 'Edit', edit_announcement_path(announcement) %></td> |
|
34 | 34 | <td><%= link_to 'Destroy', announcement, :confirm => 'Are you sure?', :method => :delete %></td> |
|
35 | 35 | </tr> |
|
36 | 36 | <% end %> |
|
37 | 37 | </table> |
|
38 | 38 | |
|
39 | 39 | <br /> |
|
40 | 40 | |
|
41 | 41 | <%= link_to 'New announcement', new_announcement_path %> |
@@ -1,25 +1,27 | |||
|
1 | 1 | CafeGrader::Application.routes.draw do |
|
2 | 2 | root :to => 'main#login' |
|
3 | 3 | |
|
4 | 4 | get "report/login" |
|
5 | 5 | |
|
6 | 6 | resources :contests |
|
7 | 7 | |
|
8 | 8 | resources :announcements |
|
9 | + match 'announcements/toggle/:id' => 'announcements#toggle', via: :put | |
|
10 | + | |
|
9 | 11 | resources :sites |
|
10 | 12 | |
|
11 | 13 | resources :grader_configuration, controller: 'configurations' |
|
12 | 14 | |
|
13 | 15 | match 'tasks/view/:file.:ext' => 'tasks#view' |
|
14 | 16 | match 'tasks/download/:id/:file.:ext' => 'tasks#download' |
|
15 | 17 | match 'heartbeat/:id/edit' => 'heartbeat#edit' |
|
16 | 18 | |
|
17 | 19 | #main |
|
18 | 20 | get "main/list" |
|
19 | 21 | |
|
20 | 22 | # See how all your routes lay out with "rake routes" |
|
21 | 23 | |
|
22 | 24 | # This is a legacy wild controller route that's not recommended for RESTful applications. |
|
23 | 25 | # Note: This route will make all actions in every controller accessible via GET requests. |
|
24 | 26 | match ':controller(/:action(/:id))(.:format)' |
|
25 | 27 | end |
You need to be logged in to leave comments.
Login now