esp-permissions 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +3 -0
  3. data/Rakefile +28 -0
  4. data/app/assets/images/esp_permissions/gh_icons.png +0 -0
  5. data/app/assets/images/esp_permissions/wood.jpg +0 -0
  6. data/app/assets/javascripts/esp_permissions/application.js +3 -0
  7. data/app/assets/javascripts/esp_permissions/jquery.noisy.min.js +3 -0
  8. data/app/assets/javascripts/esp_permissions/permissions.js +29 -0
  9. data/app/assets/stylesheets/esp_permissions/application.css +7 -0
  10. data/app/assets/stylesheets/esp_permissions/buttons.sass +300 -0
  11. data/app/assets/stylesheets/esp_permissions/pagination.sass +17 -0
  12. data/app/assets/stylesheets/esp_permissions/permissions.sass +144 -0
  13. data/app/controllers/esp_permissions/application_controller.rb +4 -0
  14. data/app/controllers/esp_permissions/permissions_controller.rb +13 -0
  15. data/app/controllers/esp_permissions/users_controller.rb +33 -0
  16. data/app/helpers/esp_permissions/permissions_helper.rb +4 -0
  17. data/app/models/user_search.rb +11 -0
  18. data/app/views/esp_permissions/permissions/new.html.erb +17 -0
  19. data/app/views/esp_permissions/users/index.html.erb +50 -0
  20. data/app/views/layouts/esp_permissions/application.html.erb +22 -0
  21. data/config/locales/ru.yml +24 -0
  22. data/config/routes.rb +6 -0
  23. data/lib/esp-permissions.rb +4 -0
  24. data/lib/esp-permissions/engine.rb +5 -0
  25. data/lib/esp-permissions/version.rb +3 -0
  26. data/lib/generators/esp_permissions/install/install_generator.rb +24 -0
  27. data/lib/generators/esp_permissions/install/templates/migration.rb +10 -0
  28. data/lib/tasks/esp-permissions_tasks.rake +4 -0
  29. metadata +255 -0
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2012 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = EspPermissions
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'EspPermissions'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+
27
+ Bundler::GemHelper.install_tasks
28
+
@@ -0,0 +1,3 @@
1
+ //= require jquery
2
+ //= require jquery_ujs
3
+ //= require_tree .
@@ -0,0 +1,3 @@
1
+ (function(c){c.fn.noisy=function(b){var b=c.extend({},c.fn.noisy.defaults,b),d,h,a=!1;try{h="localStorage"in window&&window.localStorage!==null}catch(l){h=!1}window.JSON&&h&&(a=localStorage.getItem(window.JSON.stringify(b)));if(a)d=a;else{a=document.createElement("canvas");if(a.getContext){a.width=a.height=b.size;for(var i=a.getContext("2d"),e=i.createImageData(a.width,a.height),j=b.intensity*Math.pow(b.size,2),k=255*b.opacity;j--;){var f=~~(Math.random()*a.width),g=~~(Math.random()*a.height),f=(f+
2
+ g*e.width)*4,g=j%255;e.data[f]=g;e.data[f+1]=b.monochrome?g:~~(Math.random()*255);e.data[f+2]=b.monochrome?g:~~(Math.random()*255);e.data[f+3]=~~(Math.random()*k)}i.putImageData(e,0,0);d=a.toDataURL("image/png");if(d.indexOf("data:image/png")!=0||c.browser.msie&&c.browser.version.substr(0,1)<9&&d.length>32768)d=b.fallback}else d=b.fallback;window.JSON&&h&&localStorage.setItem(window.JSON.stringify(b),d)}return this.each(function(){c(this).css("background-image","url('"+d+"'),"+c(this).css("background-image"))})};
3
+ c.fn.noisy.defaults={intensity:0.9,size:200,opacity:0.08,fallback:"",monochrome:!1}})(jQuery);
@@ -0,0 +1,29 @@
1
+ //= require esp_permissions/jquery.noisy.min.js
2
+
3
+ $(function(){
4
+ $('.container').noisy({
5
+   'intensity' : 1,
6
+  'size' : 200,
7
+   'opacity' : 0.08,
8
+   'fallback' : '',
9
+   'monochrome' : false
10
+ });
11
+
12
+ $('.show_permissions').click(function(){
13
+ var $this = $(this);
14
+ var this_permission_list = $this.parent().next('.permission_list');
15
+
16
+ $('.permission_list').not(this_permission_list).slideUp();
17
+ $('.show_permissions').not($this).removeClass('active').html('&darr;&nbsp;Показать права доступа');
18
+
19
+ this_permission_list.slideToggle('slow',function(){
20
+ if ($(this).is(':visible')) {
21
+ $this.addClass('active').html('&uarr;&nbsp;Скрыть права доступа');
22
+ }else{
23
+ $this.removeClass('active').html('&darr;&nbsp;Показать права доступа');
24
+ };
25
+ });
26
+
27
+ return false;
28
+ });
29
+ });
@@ -0,0 +1,7 @@
1
+ /*
2
+ * This is a manifest file that'll automatically include all the stylesheets available in this directory
3
+ * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
4
+ * the top of the compiled file, but it's generally better to create a new file per style scope.
5
+ *= require_self
6
+ *= require_tree .
7
+ */
@@ -0,0 +1,300 @@
1
+ /* ------------------------------------------
2
+ *CSS3 GITHUB BUTTONS (Nicolas Gallagher)
3
+ *Licensed under Unlicense
4
+ *http://github.com/necolas/css3-github-buttons
5
+ *------------------------------------------
6
+ */
7
+
8
+ /* ------------------------------------------------------------------------------------------------------------- BUTTON
9
+ */
10
+
11
+ @import "compass/css3"
12
+
13
+ button.button,
14
+ input.button,
15
+ a.button,
16
+ #title_bar .action_items a // hack for manage
17
+ position: relative
18
+ overflow: visible
19
+ display: inline-block
20
+ padding: 5px 7px 4px 8px
21
+ border: 1px solid #d4d4d4
22
+ margin: 0
23
+ text-decoration: none
24
+ +single-text-shadow(#fff, 1px, 1px, 0)
25
+ font-family: Helvetica, Arial, Verdana, sans-serif
26
+ font-size: 11px
27
+ font-weight: normal
28
+ color: #333
29
+ white-space: nowrap
30
+ cursor: pointer
31
+ outline: none
32
+ background-color: #ececec
33
+ +background-image(linear-gradient(color-stops(#f4f4f4, #ececec)))
34
+ +background-clip(padding-box)
35
+ /*background-clip: padding-box;
36
+ /* commented out due to Opera 11.10 bug
37
+ +border-radius
38
+ /* IE hacks
39
+ zoom: 1
40
+ *display: inline
41
+ &:hover, &:focus, &:active, &.active
42
+ border-color: #3072b3
43
+ border-bottom-color: #2a65a0
44
+ text-decoration: none
45
+ +single-text-shadow(rgba(0, 0, 0, 0.3), -1px, -1px, 0)
46
+ color: #fff
47
+ background-color: #3C8DDE
48
+ +background-image(linear-gradient(color-stops(#599bdc, #3072b3)))
49
+ &:active, &.active
50
+ border-color: #2a65a0
51
+ border-bottom-color: #3884CF
52
+ background-color: #3072b3
53
+ +background-image(linear-gradient(color-stops(#3072b3, #599bdc)))
54
+ &::-moz-focus-inner
55
+ padding: 0
56
+ border: 0
57
+ &.icon:before
58
+ content: ""
59
+ position: relative
60
+ top: 1px
61
+ float: left
62
+ width: 12px
63
+ height: 12px
64
+ margin: 0 0.75em 0 -0.25em
65
+ background: image_url("esp_permissions/gh_icons.png") 0 99px no-repeat
66
+ &.arrowup.icon
67
+ &:before
68
+ background-position: 0 0
69
+ &:hover:before, &:focus:before, &:active:before
70
+ background-position: -12px 0
71
+ &.arrowdown.icon
72
+ &:before
73
+ background-position: 0 -12px
74
+ &:hover:before, &:focus:before, &:active:before
75
+ background-position: -12px -12px
76
+ &.arrowleft.icon
77
+ &:before
78
+ background-position: 0 -24px
79
+ &:hover:before, &:focus:before, &:active:before
80
+ background-position: -12px -24px
81
+ &.arrowright.icon
82
+ &:before
83
+ float: right
84
+ margin: 0 -0.25em 0 0.5em
85
+ background-position: 0 -36px
86
+ &:hover:before, &:focus:before, &:active:before
87
+ background-position: -12px -36px
88
+ &.approve.icon
89
+ &:before
90
+ background-position: 0 -48px
91
+ &:hover:before, &:focus:before, &:active:before
92
+ background-position: -12px -48px
93
+ &.add.icon
94
+ &:before
95
+ background-position: 0 -288px
96
+ &:hover:before, &:focus:before, &:active:before
97
+ background-position: -12px -288px
98
+ &.remove.icon
99
+ &:before
100
+ background-position: 0 -60px
101
+ &:hover:before, &:focus:before, &:active:before
102
+ background-position: -12px -60px
103
+ &.log.icon
104
+ &:before
105
+ background-position: 0 -72px
106
+ &:hover:before, &:focus:before, &:active:before
107
+ background-position: -12px -72px
108
+ &.calendar.icon
109
+ &:before
110
+ background-position: 0 -84px
111
+ &:hover:before, &:focus:before, &:active:before
112
+ background-position: -12px -84px
113
+ &.chat.icon
114
+ &:before
115
+ background-position: 0 -96px
116
+ &:hover:before, &:focus:before, &:active:before
117
+ background-position: -12px -96px
118
+ &.clock.icon
119
+ &:before
120
+ background-position: 0 -108px
121
+ &:hover:before, &:focus:before, &:active:before
122
+ background-position: -12px -108px
123
+ &.settings.icon
124
+ &:before
125
+ background-position: 0 -120px
126
+ &:hover:before, &:focus:before, &:active:before
127
+ background-position: -12px -120px
128
+ &.comment.icon
129
+ &:before
130
+ background-position: 0 -132px
131
+ &:hover:before, &:focus:before, &:active:before
132
+ background-position: -12px -132px
133
+ &.fork.icon
134
+ &:before
135
+ background-position: 0 -144px
136
+ &:hover:before, &:focus:before, &:active:before
137
+ background-position: -12px -144px
138
+ &.like.icon
139
+ &:before
140
+ background-position: 0 -156px
141
+ &:hover:before, &:focus:before, &:active:before
142
+ background-position: -12px -156px
143
+ &.favorite.icon
144
+ &:before
145
+ background-position: 0 -348px
146
+ &:hover:before, &:focus:before, &:active:before
147
+ background-position: -12px -348px
148
+ &.home.icon
149
+ &:before
150
+ background-position: 0 -168px
151
+ &:hover:before, &:focus:before, &:active:before
152
+ background-position: -12px -168px
153
+ &.key.icon
154
+ &:before
155
+ background-position: 0 -180px
156
+ &:hover:before, &:focus:before, &:active:before
157
+ background-position: -12px -180px
158
+ &.lock.icon
159
+ &:before
160
+ background-position: 0 -192px
161
+ &:hover:before, &:focus:before, &:active:before
162
+ background-position: -12px -192px
163
+ &.unlock.icon
164
+ &:before
165
+ background-position: 0 -204px
166
+ &:hover:before, &:focus:before, &:active:before
167
+ background-position: -12px -204px
168
+ &.loop.icon
169
+ &:before
170
+ background-position: 0 -216px
171
+ &:hover:before, &:focus:before, &:active:before
172
+ background-position: -12px -216px
173
+ &.search.icon
174
+ &:before
175
+ background-position: 0 -228px
176
+ &:hover:before, &:focus:before, &:active:before
177
+ background-position: -12px -228px
178
+ &.mail.icon
179
+ &:before
180
+ background-position: 0 -240px
181
+ &:hover:before, &:focus:before, &:active:before
182
+ background-position: -12px -240px
183
+ &.move.icon
184
+ &:before
185
+ background-position: 0 -252px
186
+ &:hover:before, &:focus:before, &:active:before
187
+ background-position: -12px -252px
188
+ &.edit.icon
189
+ &:before
190
+ background-position: 0 -264px
191
+ &:hover:before, &:focus:before, &:active:before
192
+ background-position: -12px -264px
193
+ &.pin.icon
194
+ &:before
195
+ background-position: 0 -276px
196
+ &:hover:before, &:focus:before, &:active:before
197
+ background-position: -12px -276px
198
+ &.reload.icon
199
+ &:before
200
+ background-position: 0 -300px
201
+ &:hover:before, &:focus:before, &:active:before
202
+ background-position: -12px -300px
203
+ &.rss.icon
204
+ &:before
205
+ background-position: 0 -312px
206
+ &:hover:before, &:focus:before, &:active:before
207
+ background-position: -12px -312px
208
+ &.tag.icon
209
+ &:before
210
+ background-position: 0 -324px
211
+ &:hover:before, &:focus:before, &:active:before
212
+ background-position: -12px -324px
213
+ &.trash.icon
214
+ &:before
215
+ background-position: 0 -336px
216
+ &:hover:before, &:focus:before, &:active:before
217
+ background-position: -12px -336px
218
+ &.user.icon
219
+ &:before
220
+ background-position: 0 -360px
221
+ &:hover:before, &:focus:before, &:active:before
222
+ background-position: -12px -360px
223
+ &.primary
224
+ font-weight: bold
225
+ &.danger
226
+ color: #900
227
+ &:hover, &:focus
228
+ border-color: #b53f3a
229
+ border-bottom-color: #a0302a
230
+ color: #fff
231
+ background-color: #dc5f59
232
+ +background-image(linear-gradient(color-stops(#dc5f59, #b33630)))
233
+ &:active
234
+ color: #fff
235
+ border-color: #a0302a
236
+ border-bottom-color: #bf4843
237
+ background-color: #b33630
238
+ +background-image(linear-gradient(color-stops(#b33630, #dc5f59)))
239
+ &.active
240
+ border-color: #a0302a
241
+ border-bottom-color: #bf4843
242
+ background-color: #b33630
243
+ +background-image(linear-gradient(color-stops(#b33630, #dc5f59)))
244
+ &.pill
245
+ +border-radius(50em)
246
+ &.disable
247
+ opacity: 0.5
248
+ &.big
249
+ font-size: 14px
250
+ &.icon:before
251
+ top: 0
252
+
253
+ .button-group
254
+ display: inline-block
255
+ list-style: none
256
+ padding: 0
257
+ margin: 0
258
+ /* IE hacks
259
+ zoom: 1
260
+ *display: inline
261
+
262
+ .button +
263
+ .button, .button-group
264
+ margin-left: 15px
265
+
266
+ .button-group
267
+ +
268
+ .button, .button-group
269
+ margin-left: 15px
270
+ li
271
+ float: left
272
+ padding: 0
273
+ margin: 0
274
+ .button
275
+ float: left
276
+ margin-left: -1px
277
+ > .button:not(:first-child):not(:last-child), li:not(:first-child):not(:last-child) .button
278
+ +border-radius(0)
279
+ > .button:first-child, li:first-child .button
280
+ margin-left: 0
281
+ +border-top-right-radius(0)
282
+ +border-bottom-right-radius(0)
283
+ > .button:last-child, li:last-child > .button
284
+ +border-top-left-radius(0)
285
+ +border-bottom-left-radius(0)
286
+ &.minor-group .button
287
+ border: 1px solid #d4d4d4
288
+ +single-text-shadow(none)
289
+ background-image: none
290
+ background-color: #fff
291
+ &:hover, &:focus
292
+ background-color: #599bdc
293
+ &:active, &.active
294
+ background-color: #3072b3
295
+ &.icon:before
296
+ opacity: 0.8
297
+
298
+ .button-container
299
+ .button, .button-group
300
+ vertical-align: top
@@ -0,0 +1,17 @@
1
+ @import "compass/utilities"
2
+ @import "compass/css3"
3
+
4
+ .pagination
5
+ span
6
+ +inline-block
7
+ border: 1px solid #ccc
8
+ +border-radius
9
+ margin: 0 2px
10
+ &.current,
11
+ &.gap,
12
+ a
13
+ +inline-block
14
+ padding: 5px 10px
15
+ &.current,
16
+ &.gap
17
+ cursor: default
@@ -0,0 +1,144 @@
1
+ @import "compass/utilities"
2
+ @import "compass/reset"
3
+ @import "compass/css3"
4
+ @import "buttons"
5
+
6
+ body
7
+ background: #73351F image_url('esp_permissions/wood.jpg') no-repeat center top fixed
8
+ color: #333
9
+ font-family: Helvetica, Verdana, sans-serif
10
+ font-size: 13px
11
+ line-height: 16px
12
+
13
+ a
14
+ color: #484B51
15
+ outline: none
16
+ text-decoration: none
17
+
18
+ &:active, &:hover
19
+ color: #484B51
20
+ text-decoration: underline
21
+
22
+ h1
23
+ +single-text-shadow(#555, 1px, 1px, 3px)
24
+ color: whitesmoke
25
+ font-size: 28px
26
+ text-align: center
27
+ padding: 15px 0
28
+ width: 100%
29
+
30
+ h3
31
+ font-size: 14px
32
+
33
+ span
34
+ font-weight: bold
35
+
36
+ .container
37
+ +border-radius(4px)
38
+ +single-box-shadow(#555, 0px, 0px, 20px)
39
+ background: #EEF1F8
40
+ margin: 5px auto 0
41
+ padding: 25px 30px
42
+ width: 960px
43
+
44
+ .logged_info
45
+ border-bottom: 1px solid #A17345
46
+ margin: 0 0 15px
47
+ padding: 0 0 5px
48
+ text-align: right
49
+ width: 100%
50
+
51
+ .back_link
52
+ float: left
53
+
54
+ .permission_list
55
+ display: none
56
+
57
+ .collection_list
58
+ li
59
+ +border-radius(4px)
60
+ +clearfix
61
+ border: 1px solid #A17345
62
+ margin: 0 0 15px 0
63
+ padding: 15px 20px
64
+
65
+ ul
66
+ +clearfix
67
+ width: 100%
68
+
69
+ li
70
+ +border-radius(none)
71
+ border: none
72
+ margin: 5px 0
73
+ padding: 0
74
+
75
+ ul
76
+ margin: 0 0 0 15px
77
+
78
+ .name, .email, h4
79
+ float: left
80
+ font-size: 14px
81
+ line-height: 26px
82
+ margin: 0 10px 0 0
83
+
84
+ .name
85
+ font-weight: bold
86
+
87
+ .button-group
88
+ float: right
89
+
90
+ .remove
91
+ margin: 0 0 0 10px
92
+
93
+ .show_permissions
94
+ float: right
95
+ text-decoration: none
96
+
97
+ .links
98
+ +clearfix
99
+ line-height: 26px
100
+
101
+ .formtastic
102
+ .inline-errors
103
+ background: transparent image_url("inline_error_arrow.png") no-repeat left center
104
+ font-size: 12px
105
+ color: #933
106
+ padding: 0 0 0 18px
107
+
108
+ .inputs
109
+ li
110
+ margin: 15px 0
111
+
112
+ .label
113
+ display: block
114
+ margin: 0 0 5px 0
115
+
116
+ select
117
+ font-size: 14px
118
+ height: 26px
119
+ padding: 2px 3px
120
+ width: 954px
121
+
122
+ .button-group
123
+ margin: 15px 0
124
+
125
+ .user_search
126
+ +clearfix
127
+
128
+ .inputs
129
+ +clearfix
130
+ float: left
131
+ margin: 0 10px 15px 0
132
+
133
+ li
134
+ margin: 0
135
+
136
+ input
137
+ font-size: 14px
138
+ height: 20px
139
+ padding: 3px 4px
140
+ width: 868px
141
+
142
+ .buttons
143
+ +clearfix
144
+ margin: 2px 0 0 0
@@ -0,0 +1,4 @@
1
+ class EspPermissions::ApplicationController < ApplicationController
2
+ inherit_resources
3
+ before_filter :authenticate_user!
4
+ end
@@ -0,0 +1,13 @@
1
+ class EspPermissions::PermissionsController < EspPermissions::ApplicationController
2
+ belongs_to :user, :shallow => true
3
+ actions :new, :create, :destroy
4
+
5
+ def create
6
+ create!{ [:manage, :permissions, :users]}
7
+ end
8
+
9
+ def destroy
10
+ destroy!{ [:manage, :permissions, :users] }
11
+ end
12
+
13
+ end
@@ -0,0 +1,33 @@
1
+ class EspPermissions::UsersController < EspPermissions::ApplicationController
2
+ has_searcher
3
+ actions :index
4
+ has_scope :page, :default => 1
5
+
6
+ protected
7
+
8
+ def collection
9
+ get_collection_ivar || set_collection_ivar(search_and_paginate_collection)
10
+ end
11
+
12
+ def search_and_paginate_collection
13
+ if params[:utf8]
14
+ search_object = searcher_for(resource_instance_name)
15
+ search_object.pagination = paginate_options
16
+ search_object.results
17
+ else
18
+ end_of_association_chain
19
+ end
20
+ end
21
+
22
+ def paginate_options(options={})
23
+ {
24
+ :page => params[:page],
25
+ :per_page => per_page
26
+ }.merge(options)
27
+ end
28
+
29
+ def per_page
30
+ 20
31
+ end
32
+
33
+ end
@@ -0,0 +1,4 @@
1
+ module EspPermissions
2
+ module PermissionsHelper
3
+ end
4
+ end
@@ -0,0 +1,11 @@
1
+ class UserSearch < Search
2
+ column :keywords, :text
3
+ end
4
+
5
+ # == Schema Information
6
+ #
7
+ # Table name: searches
8
+ #
9
+ # keywords :text
10
+ #
11
+
@@ -0,0 +1,17 @@
1
+ <h3>
2
+ <%= t('permissions.You are adding role to') %>
3
+ <span>
4
+ <%= @user.name %>
5
+ &lt;<%= mail_to @user.email, @user.email %>&gt;
6
+ </span>
7
+ </h3>
8
+ <%= semantic_form_for resource, :url => esp_permissions.user_permissions_path(@user) do |form| %>
9
+ <%= form.inputs do %>
10
+ <%= form.input :context, :collection => current_user.availaible_contexts, :member_label => :context_title, :include_blank => t('permissions.not_selected') %>
11
+ <%= form.input :role, :as => :select, :collection => Permission.human_enums[:role].invert, :include_blank => t('permissions.not_selected') %>
12
+ <% end %>
13
+ <%= form.buttons :class => 'button-group' do %>
14
+ <li><%= button_tag t('permissions.create'), :class => 'button icon approve' %></li>
15
+ <li><%= link_to t('permissions.cancel'), esp_permissions.users_path, :class => 'button icon arrowleft' %></li>
16
+ <% end %>
17
+ <% end %>
@@ -0,0 +1,50 @@
1
+ <%= semantic_search_form_for :user, :url => esp_permissions.users_path do |form| %>
2
+ <%= form.inputs do %>
3
+ <%= form.input :keywords, :as => :string, :label => false %>
4
+ <% end %>
5
+ <%= form.buttons do %>
6
+ <li><%= button_tag t('permissions.search'), :class => 'button icon search' %></li>
7
+ <% end %>
8
+ <% end %>
9
+ <ul class="collection_list">
10
+ <% collection.each do | user | %>
11
+ <li>
12
+ <div class='name'>
13
+ <%= user.name %>
14
+ </div>
15
+
16
+ <div class='email'>
17
+ &lt;<%= mail_to user.email, user.email %>&gt;
18
+ </div>
19
+
20
+ <div class="links">
21
+ <%= link_to "&darr;&nbsp;#{t('permissions.show_permissions')}".html_safe, '#', :class => 'show_permissions' %>
22
+ <%= link_to "&#43;#{t('permissions.new')}".html_safe, esp_permissions.new_user_permission_path(user), :class => 'add' if can?(:update, user) %>
23
+ </div>
24
+
25
+ <%= content_tag :ul, :class => 'permission_list' do %>
26
+ <% if user.permissions.exists? %>
27
+ <% user.permissions.group_by(&:role).each do |role, permissions| %>
28
+ <li>
29
+ <h4><%= Permission.human_enums[:role][role] %></h4>
30
+ <ul>
31
+ <% permissions.each do |permission| %>
32
+ <li>
33
+ <%= permission.context %>
34
+ <%= link_to t('permissions.delete'),
35
+ manage_permissions_permission_path(permission),
36
+ :method => :delete,
37
+ :confirm => t('Are you sure?'),
38
+ :class => 'buttton icon remove danger' if can?(:delete, permission) %>
39
+ </li>
40
+ <% end %>
41
+ </ul>
42
+ </li>
43
+ <% end %>
44
+ <% else %>
45
+ <li>Нет прав доступа</li>
46
+ <% end %>
47
+ <% end %>
48
+ </li>
49
+ <% end %>
50
+ </ul>
@@ -0,0 +1,22 @@
1
+ <!DOCTYPE HTML>
2
+ <html lang="ru">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title><%= t('permissions.title') %></title>
6
+ <%= stylesheet_link_tag 'esp_permissions/application' %>
7
+ <%= javascript_include_tag 'esp_permissions/application' %>
8
+ <%= csrf_meta_tags %>
9
+ </head>
10
+ <body>
11
+ <h1><%= t('permissions.title') %></h1>
12
+ <div class="container">
13
+ <div class="logged_info">
14
+ <%= link_to "&larr; #{t('permissions.back_to_manage')}".html_safe, '/manage', :class => 'back_link' %>
15
+ <%= t('permissions.You are sign in as') %>
16
+ <%= "#{current_user.name} &lt;#{current_user.email}&gt;".html_safe %>
17
+ <%= link_to t('permissions.sign_out'), '/sso/sign_out' %>
18
+ </div>
19
+ <%= yield %>
20
+ </div>
21
+ </body>
22
+ </html>
@@ -0,0 +1,24 @@
1
+ ru:
2
+ activerecord:
3
+ attributes:
4
+ permission:
5
+ context: Категория
6
+ role: Роль
7
+
8
+ models:
9
+ permission: Право доступа
10
+
11
+ permissions:
12
+ 'Are you sure?': Вы уверены, в том что хотите удалить запись?
13
+ 'You are sign in as': Вы вошли как
14
+ 'You are adding role to': Вы добавляете роль для
15
+ back_to_manage: Назад в раздел управления контентом
16
+ cancel: Отмена
17
+ create: Создать
18
+ delete: Удалить
19
+ new: Добавить право доступа
20
+ not_selected: -- не выбрано --
21
+ search: Поиск
22
+ show_permissions: Показать права доступа
23
+ sign_out: Выход
24
+ title: Управление правами доступа
data/config/routes.rb ADDED
@@ -0,0 +1,6 @@
1
+ EspPermissions::Engine.routes.draw do
2
+ resources :users, :only => :index do
3
+ resources :permissions, :only => [:new, :create, :destroy], :shallow => true
4
+ end
5
+ root :to => 'users#index'
6
+ end
@@ -0,0 +1,4 @@
1
+ require "esp-permissions/engine"
2
+
3
+ module EspPermissions
4
+ end
@@ -0,0 +1,5 @@
1
+ module EspPermissions
2
+ class Engine < Rails::Engine
3
+ isolate_namespace EspPermissions
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module EspPermissions
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,24 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+
4
+ module EspPermissions
5
+ module Generators
6
+ class InstallGenerator < Rails::Generators::Base
7
+ include Rails::Generators::Migration
8
+
9
+ source_root File.expand_path('../templates', __FILE__)
10
+
11
+ def self.next_migration_number(dirname)
12
+ Time.now.strftime('%Y%m%d%H%M%S')
13
+ end
14
+
15
+ # def create_models
16
+ # template 'model.rb', 'app/models/user.rb'
17
+ # end
18
+
19
+ def create_migration
20
+ migration_template 'migration.rb', 'db/migrate/esp_permissions_create_permissions.rb'
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,10 @@
1
+ class EspPermissionsCreatePermissions < ActiveRecord::Migration
2
+ def change
3
+ create_table :permissions do |t|
4
+ t.references :user
5
+ t.references :context
6
+ t.string :role
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :esp-permissions do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,255 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: esp-permissions
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - http://openteam.ru
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-01-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: cancan
16
+ requirement: &20430700 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *20430700
25
+ - !ruby/object:Gem::Dependency
26
+ name: compass
27
+ requirement: &20429460 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 0.12.alpha.2
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *20429460
36
+ - !ruby/object:Gem::Dependency
37
+ name: formtastic
38
+ requirement: &20428620 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *20428620
47
+ - !ruby/object:Gem::Dependency
48
+ name: has_enum
49
+ requirement: &20427700 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *20427700
58
+ - !ruby/object:Gem::Dependency
59
+ name: has_searcher
60
+ requirement: &20426500 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: *20426500
69
+ - !ruby/object:Gem::Dependency
70
+ name: inherited_resources
71
+ requirement: &20425620 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: *20425620
80
+ - !ruby/object:Gem::Dependency
81
+ name: kaminari
82
+ requirement: &20298560 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :runtime
89
+ prerelease: false
90
+ version_requirements: *20298560
91
+ - !ruby/object:Gem::Dependency
92
+ name: rails
93
+ requirement: &20297060 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ type: :runtime
100
+ prerelease: false
101
+ version_requirements: *20297060
102
+ - !ruby/object:Gem::Dependency
103
+ name: sass
104
+ requirement: &20295480 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: *20295480
113
+ - !ruby/object:Gem::Dependency
114
+ name: sass-rails
115
+ requirement: &20293540 !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ type: :runtime
122
+ prerelease: false
123
+ version_requirements: *20293540
124
+ - !ruby/object:Gem::Dependency
125
+ name: sso_client
126
+ requirement: &20292380 !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: *20292380
135
+ - !ruby/object:Gem::Dependency
136
+ name: sunspot_rails
137
+ requirement: &20291440 !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ type: :runtime
144
+ prerelease: false
145
+ version_requirements: *20291440
146
+ - !ruby/object:Gem::Dependency
147
+ name: sqlite3
148
+ requirement: &20264680 !ruby/object:Gem::Requirement
149
+ none: false
150
+ requirements:
151
+ - - ! '>='
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ type: :development
155
+ prerelease: false
156
+ version_requirements: *20264680
157
+ - !ruby/object:Gem::Dependency
158
+ name: sunspot_solr
159
+ requirement: &20263540 !ruby/object:Gem::Requirement
160
+ none: false
161
+ requirements:
162
+ - - ! '>='
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ type: :development
166
+ prerelease: false
167
+ version_requirements: *20263540
168
+ - !ruby/object:Gem::Dependency
169
+ name: uglifier
170
+ requirement: &20262660 !ruby/object:Gem::Requirement
171
+ none: false
172
+ requirements:
173
+ - - ! '>='
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ type: :development
177
+ prerelease: false
178
+ version_requirements: *20262660
179
+ - !ruby/object:Gem::Dependency
180
+ name: therubyracer
181
+ requirement: &20261820 !ruby/object:Gem::Requirement
182
+ none: false
183
+ requirements:
184
+ - - ! '>='
185
+ - !ruby/object:Gem::Version
186
+ version: '0'
187
+ type: :development
188
+ prerelease: false
189
+ version_requirements: *20261820
190
+ description: Description of EspPermissions.
191
+ email:
192
+ - mail@openteam.ru
193
+ executables: []
194
+ extensions: []
195
+ extra_rdoc_files: []
196
+ files:
197
+ - app/assets/images/esp_permissions/wood.jpg
198
+ - app/assets/images/esp_permissions/gh_icons.png
199
+ - app/assets/stylesheets/esp_permissions/pagination.sass
200
+ - app/assets/stylesheets/esp_permissions/application.css
201
+ - app/assets/stylesheets/esp_permissions/permissions.sass
202
+ - app/assets/stylesheets/esp_permissions/buttons.sass
203
+ - app/assets/javascripts/esp_permissions/jquery.noisy.min.js
204
+ - app/assets/javascripts/esp_permissions/application.js
205
+ - app/assets/javascripts/esp_permissions/permissions.js
206
+ - app/helpers/esp_permissions/permissions_helper.rb
207
+ - app/models/user_search.rb
208
+ - app/controllers/esp_permissions/users_controller.rb
209
+ - app/controllers/esp_permissions/application_controller.rb
210
+ - app/controllers/esp_permissions/permissions_controller.rb
211
+ - app/views/layouts/esp_permissions/application.html.erb
212
+ - app/views/esp_permissions/permissions/new.html.erb
213
+ - app/views/esp_permissions/users/index.html.erb
214
+ - config/routes.rb
215
+ - config/locales/ru.yml
216
+ - lib/generators/esp_permissions/install/install_generator.rb
217
+ - lib/generators/esp_permissions/install/templates/migration.rb
218
+ - lib/esp-permissions/engine.rb
219
+ - lib/esp-permissions/version.rb
220
+ - lib/tasks/esp-permissions_tasks.rake
221
+ - lib/esp-permissions.rb
222
+ - MIT-LICENSE
223
+ - Rakefile
224
+ - README.rdoc
225
+ homepage:
226
+ licenses: []
227
+ post_install_message:
228
+ rdoc_options: []
229
+ require_paths:
230
+ - lib
231
+ required_ruby_version: !ruby/object:Gem::Requirement
232
+ none: false
233
+ requirements:
234
+ - - ! '>='
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
237
+ segments:
238
+ - 0
239
+ hash: 2624684332384223134
240
+ required_rubygems_version: !ruby/object:Gem::Requirement
241
+ none: false
242
+ requirements:
243
+ - - ! '>='
244
+ - !ruby/object:Gem::Version
245
+ version: '0'
246
+ segments:
247
+ - 0
248
+ hash: 2624684332384223134
249
+ requirements: []
250
+ rubyforge_project:
251
+ rubygems_version: 1.8.10
252
+ signing_key:
253
+ specification_version: 3
254
+ summary: Summary of EspPermissions.
255
+ test_files: []