rails_admin_user_abilities 0.1.0.1 → 0.1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/README.md +1 -1
- data/app/assets/stylesheets/rails_admin/rails_admin_user_abilities.sass +3 -0
- data/app/views/rails_admin/main/model_accesses.html.slim +9 -9
- data/app/views/rails_admin/main/user_abilities.html.slim +9 -9
- data/lib/rails_admin_user_abilities.rb +1 -2
- data/lib/rails_admin_user_abilities/models/user_ability.rb +11 -7
- data/lib/rails_admin_user_abilities/version.rb +1 -1
- data/rails_admin_user_abilities.gemspec +1 -1
- data/release.sh +1 -2
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 09f93a7d69fcc398bd27bc9d5f213719a83f6856
|
4
|
+
data.tar.gz: cbdbf37abcaa9473a6ef8f932e72f6c3d5c55194
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac9dd05e563f4f875c4523d69818a277d51e545a4bba616193cd81cc0ccbdf950f24a9cd823c8240db0129f45cb7b8fa4b28cbccef7defe56452da0ff5c512a5
|
7
|
+
data.tar.gz: 9b3ff46d9376958374cdd10417c9f792f93fe2d50707787bb0f6bfa9619a1ec429cdccb5c7ae797d5df87af19d6dbb930a5692a2066d46a3c5cd8c556b437350
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rails_admin_user_abilities
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.2.2
|
data/README.md
CHANGED
@@ -71,7 +71,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
71
71
|
|
72
72
|
## Contributing
|
73
73
|
|
74
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
74
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/red-rocks/rails_admin_user_abilities.
|
75
75
|
|
76
76
|
|
77
77
|
## License
|
@@ -10,7 +10,7 @@
|
|
10
10
|
.col-md-3
|
11
11
|
ul.nav.nav-pills.nav-stacked
|
12
12
|
- @users.each do |u|
|
13
|
-
li= link_to u.email, "#user_abilities_#{u._id}", title: u._id, "data-toggle" => "tab"
|
13
|
+
li= link_to u.email, "#user_abilities_#{u._id}".freeze, title: u._id, "data-toggle" => "tab".freeze
|
14
14
|
.cf
|
15
15
|
|
16
16
|
.tab-content.col-md-9
|
@@ -18,14 +18,14 @@
|
|
18
18
|
ruby:
|
19
19
|
url = model_accesses_path(model_name: @abstract_model, id: @object.id, user_id: u._id)
|
20
20
|
user_abilities = ::Ability.new(u)
|
21
|
-
_id = "user_abilities_#{u._id}"
|
21
|
+
_id = "user_abilities_#{u._id}".freeze
|
22
22
|
.tab-pane{id=_id data-url=url}
|
23
23
|
.row-fluid
|
24
24
|
.controls
|
25
25
|
- [:manage, :read].each do |_action_str|
|
26
26
|
div
|
27
|
-
= check_box "model_accesses[][#{u._id}]#{_model_str}", _action_str, {checked: user_abilities.can?(_action_str, @object), class: "model_accesses_trigger"}, "can", "cannot"
|
28
|
-
= label("model_accesses[][#{u._id}]#{_model_str}", _action_str, "#{I18n.t("admin.user_abilities.global_actions.#{_action_str}")} (#{_action_str})")
|
27
|
+
= check_box "model_accesses[][#{u._id}]#{_model_str}".freeze, _action_str, {checked: user_abilities.can?(_action_str, @object), class: "model_accesses_trigger".freeze}, "can".freeze, "cannot".freeze
|
28
|
+
= label("model_accesses[][#{u._id}]#{_model_str}".freeze, _action_str, "#{I18n.t("admin.user_abilities.global_actions.#{_action_str}")} (#{_action_str})")
|
29
29
|
hr
|
30
30
|
ruby:
|
31
31
|
_bindings = {
|
@@ -39,18 +39,18 @@
|
|
39
39
|
- next unless a.visible
|
40
40
|
|
41
41
|
div
|
42
|
-
= check_box "model_accesses[][#{u._id}]#{_model_str}", _action_str, {checked: user_abilities.can?(_action_str.to_sym, @object), class: "model_accesses_trigger"}, "can", "cannot"
|
43
|
-
= label("model_accesses[][#{u._id}]#{_model_str}", _action_str, "#{wording_for(:menu, a, @abstract_model)} (#{_action_str})")
|
42
|
+
= check_box "model_accesses[][#{u._id}]#{_model_str}".freeze, _action_str, {checked: user_abilities.can?(_action_str.to_sym, @object), class: "model_accesses_trigger".freeze}, "can".freeze, "cannot".freeze
|
43
|
+
= label("model_accesses[][#{u._id}]#{_model_str}".freeze, _action_str, "#{wording_for(:menu, a, @abstract_model)} (#{_action_str})")
|
44
44
|
|
45
45
|
- if u.ability
|
46
|
-
.col-md-12
|
46
|
+
.json_block.col-md-12
|
47
47
|
hr
|
48
|
-
button(data-toggle="collapse" data-target="#model_accesses_hash_#{u.id}")= "Чистый код"
|
48
|
+
button(data-toggle="collapse" data-target="#model_accesses_hash_#{u.id}")= "Чистый код".freeze
|
49
49
|
.collapse(id="model_accesses_hash_#{u.id}")
|
50
50
|
pre= JSON.pretty_generate({"#{_model.name}": (u.ability.accesses[_model.name] || {}) })
|
51
51
|
|
52
52
|
- elsif request.post?
|
53
|
-
- uniq_id = "rails_admin_model_accesses_#{(Time.new.to_f * 1000).to_i}"
|
53
|
+
- uniq_id = "rails_admin_model_accesses_#{(Time.new.to_f * 1000).to_i}".freeze
|
54
54
|
span(class="message #{@_class}" id=uniq_id)
|
55
55
|
= @message
|
56
56
|
javascript:
|
@@ -13,7 +13,7 @@
|
|
13
13
|
_model = m.abstract_model.model
|
14
14
|
_content = m.abstract_model.config.label
|
15
15
|
_title = m.abstract_model.config.label
|
16
|
-
_link = "#user_abilities_#{_model.name.gsub("::", "").underscore}"
|
16
|
+
_link = "#user_abilities_#{_model.name.gsub("::", "").underscore}".freeze
|
17
17
|
li= link_to _content, _link, title: _title, "data-toggle" => "tab"
|
18
18
|
.cf
|
19
19
|
|
@@ -24,21 +24,21 @@
|
|
24
24
|
_model_str = _model.name.underscore
|
25
25
|
_content = m.abstract_model.config.label
|
26
26
|
_title = m.abstract_model.config.label
|
27
|
-
_id = "user_abilities_#{_model.name.gsub("::", "").underscore}"
|
27
|
+
_id = "user_abilities_#{_model.name.gsub("::", "").underscore}".freeze
|
28
28
|
|
29
29
|
.tab-pane{id=_id}
|
30
30
|
.row-fluid
|
31
31
|
.controls
|
32
32
|
- [:manage, :read].each do |_action_str|
|
33
33
|
div
|
34
|
-
= check_box "user_abilities[]#{_model_str}", _action_str, {checked: @user_abilities.can?(_action_str, _model), class: "user_abilities_trigger"}, "can", "cannot"
|
35
|
-
= label("user_abilities[]#{_model_str}", _action_str, "#{I18n.t("admin.user_abilities.global_actions.#{_action_str}")} (#{_action_str})")
|
34
|
+
= check_box "user_abilities[]#{_model_str}".freeze, _action_str, {checked: @user_abilities.can?(_action_str, _model), class: "user_abilities_trigger".freeze}, "can".freeze, "cannot".freeze
|
35
|
+
= label("user_abilities[]#{_model_str}".freeze, _action_str, "#{I18n.t("admin.user_abilities.global_actions.#{_action_str}")} (#{_action_str})")
|
36
36
|
hr
|
37
37
|
ruby:
|
38
38
|
_bindings = {
|
39
39
|
abstract_model: m.abstract_model,
|
40
40
|
view: self
|
41
|
-
}
|
41
|
+
}
|
42
42
|
- RailsAdmin::Config::Actions.all(:all, _bindings).select { |a| a.http_methods.include?(:get) }.map do |a|
|
43
43
|
- _action = a.class.name.demodulize
|
44
44
|
- _action_str = _action.underscore
|
@@ -46,18 +46,18 @@
|
|
46
46
|
- next unless a.visible
|
47
47
|
|
48
48
|
div
|
49
|
-
= check_box "user_abilities[]#{_model_str}", _action_str, {checked: @user_abilities.can?(_action_str.to_sym, _model), class: "user_abilities_trigger"}, "can", "cannot"
|
50
|
-
= label("user_abilities[]#{_model_str}", _action_str, "#{wording_for(:menu, a, m.abstract_model)} (#{_action_str})")
|
49
|
+
= check_box "user_abilities[]#{_model_str}".freeze, _action_str, {checked: @user_abilities.can?(_action_str.to_sym, _model), class: "user_abilities_trigger".freeze}, "can".freeze, "cannot".freeze
|
50
|
+
= label("user_abilities[]#{_model_str}".freeze, _action_str, "#{wording_for(:menu, a, m.abstract_model)} (#{_action_str})")
|
51
51
|
|
52
52
|
- if @object.ability
|
53
53
|
.col-md-12
|
54
54
|
hr
|
55
|
-
button(data-toggle="collapse" data-target="#abilities_hash")= "Чистый код"
|
55
|
+
button(data-toggle="collapse" data-target="#abilities_hash")= "Чистый код".freeze
|
56
56
|
#abilities_hash.collapse
|
57
57
|
pre= JSON.pretty_generate @object.ability.abilities
|
58
58
|
|
59
59
|
- elsif request.post?
|
60
|
-
- uniq_id = "rails_admin_user_abilities_#{(Time.new.to_f * 1000).to_i}"
|
60
|
+
- uniq_id = "rails_admin_user_abilities_#{(Time.new.to_f * 1000).to_i}".freeze
|
61
61
|
span(class="message #{@_class}" id=uniq_id)
|
62
62
|
= @message
|
63
63
|
javascript:
|
@@ -8,17 +8,21 @@ module RailsAdminUserAbilities
|
|
8
8
|
|
9
9
|
def to_cancancan(ability_object)
|
10
10
|
abilities.each_pair do |model_name, rules|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
if Kernel.const_defined?(model_name)
|
12
|
+
_model = model_name.constantize
|
13
|
+
rules.each_pair do |act, meth|
|
14
|
+
ability_object.send(meth, act.to_sym, _model)
|
15
|
+
end
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
17
19
|
accesses.each_pair do |model_name, ids_rules|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
if Kernel.const_defined?(model_name)
|
21
|
+
_model = model_name.constantize
|
22
|
+
ids_rules.each_pair do |obj_id, rules|
|
23
|
+
rules.each_pair do |act, meth|
|
24
|
+
ability_object.send(meth, act.to_sym, _model, {id: BSON::ObjectId.from_string(obj_id)})
|
25
|
+
end
|
22
26
|
end
|
23
27
|
end
|
24
28
|
end
|
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = "rails_admin_user_abilities"
|
8
8
|
spec.version = RailsAdminUserAbilities::VERSION
|
9
9
|
spec.authors = ["Alexander Kiseliev"]
|
10
|
-
spec.email = ["dev@
|
10
|
+
spec.email = ["dev@redrocks.pro"]
|
11
11
|
|
12
12
|
spec.summary = %q{CanCanCan fields for rails_admin}
|
13
13
|
spec.description = %q{CanCanCan fields for rails_admin}
|
data/release.sh
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_admin_user_abilities
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Kiseliev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -54,12 +54,14 @@ dependencies:
|
|
54
54
|
version: 0.8.1
|
55
55
|
description: CanCanCan fields for rails_admin
|
56
56
|
email:
|
57
|
-
- dev@
|
57
|
+
- dev@redrocks.pro
|
58
58
|
executables: []
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
62
|
- ".gitignore"
|
63
|
+
- ".ruby-gemset"
|
64
|
+
- ".ruby-version"
|
63
65
|
- ".travis.yml"
|
64
66
|
- Gemfile
|
65
67
|
- LICENSE.txt
|