the_role 1.6.3 → 1.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +29 -2
- data/app/controllers/admin/role_sections_controller.rb +2 -3
- data/app/controllers/admin/roles_controller.rb +11 -7
- data/app/views/admin/roles/_role.html.haml +12 -12
- data/app/views/admin/roles/_sidebar.html.haml +1 -1
- data/app/views/admin/roles/new.html.haml +1 -1
- data/app/views/layouts/the_role.html.haml +3 -2
- data/config/locales/en.yml +36 -39
- data/lib/the_role/version.rb +1 -1
- metadata +14 -14
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# gem 'the_role' (alpha v0.
|
1
|
+
# gem 'the_role' (alpha v0.2)
|
2
2
|
|
3
3
|
| Bye bye CanCan, I got The Role! | Description |
|
4
4
|
|:------------- |:-------------|
|
@@ -362,4 +362,31 @@ new_role_hash = {
|
|
362
362
|
|
363
363
|
# delete rule in section
|
364
364
|
@role.delete_rule(:pages, :show)
|
365
|
-
```
|
365
|
+
```
|
366
|
+
|
367
|
+
### Changelog
|
368
|
+
|
369
|
+
* 1.6.4 - En locale (alpha 0.2)
|
370
|
+
* 1.6.3 - notifications
|
371
|
+
* 1.6.0 - stabile release (alpha 0.1)
|
372
|
+
|
373
|
+
##### Copyright (c) 2012 [Ilya N.Zykin]
|
374
|
+
|
375
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
376
|
+
a copy of this software and associated documentation files (the
|
377
|
+
"Software"), to deal in the Software without restriction, including
|
378
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
379
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
380
|
+
permit persons to whom the Software is furnished to do so, subject to
|
381
|
+
the following conditions:
|
382
|
+
|
383
|
+
The above copyright notice and this permission notice shall be
|
384
|
+
included in all copies or substantial portions of the Software.
|
385
|
+
|
386
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
387
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
388
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
389
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
390
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
391
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
392
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -1,5 +1,4 @@
|
|
1
1
|
class Admin::RoleSectionsController < ApplicationController
|
2
|
-
include TheRole::Requires
|
3
2
|
layout 'the_role'
|
4
3
|
|
5
4
|
before_filter :login_required
|
@@ -32,7 +31,7 @@ class Admin::RoleSectionsController < ApplicationController
|
|
32
31
|
if @role.rule_on section_name, rule_name
|
33
32
|
flash[:notice] = t 'the_role.section_rule_on'
|
34
33
|
else
|
35
|
-
flash[:error] = t 'the_role.
|
34
|
+
flash[:error] = t 'the_role.state_not_changed'
|
36
35
|
end
|
37
36
|
redirect_to_edit
|
38
37
|
end
|
@@ -43,7 +42,7 @@ class Admin::RoleSectionsController < ApplicationController
|
|
43
42
|
if @role.rule_off section_name, rule_name
|
44
43
|
flash[:notice] = t 'the_role.section_rule_off'
|
45
44
|
else
|
46
|
-
flash[:error] = t 'the_role.
|
45
|
+
flash[:error] = t 'the_role.state_not_changed'
|
47
46
|
end
|
48
47
|
redirect_to_edit
|
49
48
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
class Admin::RolesController < ApplicationController
|
2
|
-
include TheRole::Requires
|
3
2
|
layout 'the_role'
|
4
3
|
|
5
4
|
before_filter :login_required
|
@@ -9,7 +8,7 @@ class Admin::RolesController < ApplicationController
|
|
9
8
|
before_filter :owner_required, :only => [:edit, :update, :destroy]
|
10
9
|
|
11
10
|
def index
|
12
|
-
@roles = Role.all
|
11
|
+
@roles = Role.all :order => 'created_at ASC'
|
13
12
|
end
|
14
13
|
|
15
14
|
def new
|
@@ -19,11 +18,11 @@ class Admin::RolesController < ApplicationController
|
|
19
18
|
def edit; end
|
20
19
|
|
21
20
|
def create
|
22
|
-
@role = Role.new
|
21
|
+
@role = Role.new params[:role]
|
23
22
|
|
24
23
|
if @role.save
|
25
|
-
flash[:notice] = t
|
26
|
-
|
24
|
+
flash[:notice] = t 'the_role.role_created'
|
25
|
+
redirect_to_edit
|
27
26
|
else
|
28
27
|
render :action => :new
|
29
28
|
end
|
@@ -31,8 +30,8 @@ class Admin::RolesController < ApplicationController
|
|
31
30
|
|
32
31
|
def update
|
33
32
|
if @role.update_role params[:role].try(:[],:the_role)
|
34
|
-
flash[:notice] = t
|
35
|
-
|
33
|
+
flash[:notice] = t 'the_role.role_updated'
|
34
|
+
redirect_to_edit
|
36
35
|
else
|
37
36
|
render :action => :edit
|
38
37
|
end
|
@@ -40,6 +39,7 @@ class Admin::RolesController < ApplicationController
|
|
40
39
|
|
41
40
|
def destroy
|
42
41
|
@role.destroy
|
42
|
+
flash[:notice] = t 'the_role.role_deleted'
|
43
43
|
redirect_to admin_roles_url
|
44
44
|
end
|
45
45
|
|
@@ -49,5 +49,9 @@ class Admin::RolesController < ApplicationController
|
|
49
49
|
@role = Role.find params[:id]
|
50
50
|
@ownership_checking_object = @role
|
51
51
|
end
|
52
|
+
|
53
|
+
def redirect_to_edit
|
54
|
+
redirect_to edit_admin_role_path @role
|
55
|
+
end
|
52
56
|
|
53
57
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
.well
|
2
2
|
%h3
|
3
|
-
%b
|
3
|
+
%b= t '.role_name'
|
4
4
|
= role.name
|
5
5
|
|
6
6
|
%h5
|
7
|
-
%b
|
7
|
+
%b= t '.title'
|
8
8
|
= role.title
|
9
9
|
|
10
10
|
%p.description
|
11
|
-
%b
|
11
|
+
%b= t '.role_description'
|
12
12
|
= role.description
|
13
13
|
|
14
14
|
- role.to_hash.each_pair do |section, rules|
|
@@ -16,7 +16,7 @@
|
|
16
16
|
%h3= section
|
17
17
|
.delete
|
18
18
|
.btn-group
|
19
|
-
= button_to '
|
19
|
+
= button_to t('.delete_section'), admin_role_section_path(role, section), :method => :delete, :class => 'btn btn-danger', :confirm => t('.section_delete_confirm')
|
20
20
|
|
21
21
|
- rules.each_pair do |rule, value|
|
22
22
|
.rule
|
@@ -26,21 +26,21 @@
|
|
26
26
|
.controls
|
27
27
|
.btn-group
|
28
28
|
- klass = value ? :success : :info
|
29
|
-
- state = value ?
|
29
|
+
- state = value ? t('.enable') : t('.disable')
|
30
30
|
%button{ :class => "btn btn-#{klass}" }= state
|
31
31
|
%button{ :class => "btn btn-#{klass} dropdown-toggle", 'data-toggle' => :dropdown }
|
32
32
|
%span.caret
|
33
33
|
%ul.dropdown-menu
|
34
|
-
%li.success= link_to '
|
35
|
-
%li.info= link_to '
|
34
|
+
%li.success= link_to t('.enable'), rule_on_admin_role_section_path(role, section, :name => rule), :method => :put
|
35
|
+
%li.info= link_to t('.disable'), rule_off_admin_role_section_path(role, section, :name => rule), :method => :put
|
36
36
|
%li.divider
|
37
|
-
%li.error= link_to '
|
37
|
+
%li.error= link_to t('.delete_rule'), destroy_rule_admin_role_section_path(role, section, :name => rule), :method => :delete, :confirm => t('.rule_delete_confirm')
|
38
38
|
|
39
39
|
%h4 Create new section
|
40
40
|
|
41
41
|
= form_tag admin_role_sections_path(role), :class => 'well form-inline' do |f|
|
42
|
-
= text_field_tag :section_name, '', :class => 'input-xlarge', :placeholder =>
|
43
|
-
= submit_tag '
|
42
|
+
= text_field_tag :section_name, '', :class => 'input-xlarge', :placeholder => t('.new_section_placeholder')
|
43
|
+
= submit_tag t('.create_section'), :class => :btn
|
44
44
|
|
45
45
|
%h4 Create new rule
|
46
46
|
|
@@ -49,5 +49,5 @@
|
|
49
49
|
- role.to_hash.each_pair do |section, rules|
|
50
50
|
%option{ :value => section }= section
|
51
51
|
|
52
|
-
= text_field_tag :rule_name, '', :class => 'input-large', :placeholder =>
|
53
|
-
= submit_tag '
|
52
|
+
= text_field_tag :rule_name, '', :class => 'input-large', :placeholder => t('.new_rule_placeholder')
|
53
|
+
= submit_tag t('.create_rule'), :class => :btn
|
@@ -3,6 +3,6 @@
|
|
3
3
|
- (@roles || Role.all).each do |role|
|
4
4
|
%p
|
5
5
|
= link_to role.title, edit_admin_role_url(role)
|
6
|
-
= link_to raw('×'), admin_role_url(role), :method => :delete, :title => role.title, :confirm => t('
|
6
|
+
= link_to raw('×'), admin_role_url(role), :method => :delete, :title => role.title, :confirm => t('.delete_role_confirm'), :class => :delete
|
7
7
|
|
8
8
|
%p.new= link_to t('.new_role'), new_admin_role_path
|
@@ -13,12 +13,13 @@
|
|
13
13
|
\|
|
14
14
|
Role system for Rails Apps
|
15
15
|
\|
|
16
|
-
|
16
|
+
- u = current_user
|
17
|
+
User: #{u.try(:name) || u.try(:username) || u.try(:login)|| u.try(:email) || u.id}
|
17
18
|
.crusty
|
18
19
|
.container
|
19
20
|
|
20
21
|
- if flash[:notice]
|
21
|
-
.alert.alert-
|
22
|
+
.alert.alert-success
|
22
23
|
%a.close{:href => '#', 'data-dismiss' => :alert } ×
|
23
24
|
= flash[:notice]
|
24
25
|
|
data/config/locales/en.yml
CHANGED
@@ -1,44 +1,41 @@
|
|
1
|
-
# Sample localization file for English. Add more files in this directory for other locales.
|
2
|
-
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
|
3
1
|
en:
|
4
2
|
the_role:
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
3
|
+
role_created: Role created
|
4
|
+
role_updated: Role updated
|
5
|
+
role_deleted: Role deleted
|
6
|
+
section_created: Section created
|
7
|
+
section_not_created: Section not created
|
8
|
+
section_rule_created: "Section's rule created"
|
9
|
+
section_rule_not_created: "Section's rule not created"
|
10
|
+
section_rule_on: "Section's rule is enable"
|
11
|
+
section_rule_off: "Section's rule is disable"
|
12
|
+
state_not_changed: "Section's rule not changed"
|
13
|
+
section_deleted: Section deleted
|
14
|
+
section_not_deleted: Section not deleted
|
15
|
+
section_rule_deleted: "Section's rule deleted"
|
16
|
+
section_rule_not_deleted: "Section's rule not deleted"
|
17
|
+
|
19
18
|
admin:
|
20
19
|
roles:
|
21
|
-
index:
|
22
|
-
list: list of roles
|
23
|
-
delete: 'Delete Role'
|
24
|
-
new: Create a new role
|
25
|
-
edit:
|
26
|
-
title: Editing role
|
27
|
-
back: '← To the list of roles'
|
28
|
-
name: 'Name of role -'
|
29
|
-
create_section: Create a Section
|
30
|
-
create_access_rule: Create an access rule
|
31
|
-
create_rule: New Rule
|
32
|
-
section_needs: Create at least one Section
|
33
|
-
update: Update
|
34
|
-
form:
|
35
|
-
destroy_section_confirm: Remove a role section?
|
36
|
-
empty: There is no role section
|
37
|
-
delete_rule_confirm: Remove the access rule?
|
38
|
-
delete: Delete
|
39
20
|
new:
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
21
|
+
create: Create new Role
|
22
|
+
name: Name of role (underscored latin string)
|
23
|
+
title: Title of role (text)
|
24
|
+
description: Description of role (text)
|
25
|
+
role:
|
26
|
+
role_name: 'Role name:'
|
27
|
+
title: 'Title:'
|
28
|
+
role_description: 'Description of role:'
|
29
|
+
delete_section: Delete section
|
30
|
+
section_delete_confirm: 'Do you want to delete section?'
|
31
|
+
rule_delete_confirm: 'Do you want to delete rule?'
|
32
|
+
enable: Enable
|
33
|
+
disable: Disable
|
34
|
+
delete_rule: Delete rule
|
35
|
+
new_section_placeholder: New section name
|
36
|
+
create_section: Create new section
|
37
|
+
new_rule_placeholder: New rule name
|
38
|
+
create_rule: Create new rule
|
39
|
+
sidebar:
|
40
|
+
new_role: Create new role
|
41
|
+
delete_role_confirm: 'Are you sure? It can dangerous!'
|
data/lib/the_role/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: the_role
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: haml
|
16
|
-
requirement: &
|
16
|
+
requirement: &15825160 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *15825160
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: sass
|
27
|
-
requirement: &
|
27
|
+
requirement: &15824720 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *15824720
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: sass-rails
|
38
|
-
requirement: &
|
38
|
+
requirement: &15824280 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *15824280
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: coffee-rails
|
49
|
-
requirement: &
|
49
|
+
requirement: &15823820 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *15823820
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: therubyracer
|
60
|
-
requirement: &
|
60
|
+
requirement: &15823380 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *15823380
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: less-rails
|
71
|
-
requirement: &
|
71
|
+
requirement: &15822820 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *15822820
|
80
80
|
description: Authorization lib for Rails 3 with Web Interface, aka CanCan killer
|
81
81
|
email:
|
82
82
|
- zykin-ilya@ya.ru
|