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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d1173e8678a9f824eeb145c6a2c1db29bcb3be5f
4
- data.tar.gz: d87ee0a6e201f8dfe26fa3d80e9d401f7f2bc284
3
+ metadata.gz: 09f93a7d69fcc398bd27bc9d5f213719a83f6856
4
+ data.tar.gz: cbdbf37abcaa9473a6ef8f932e72f6c3d5c55194
5
5
  SHA512:
6
- metadata.gz: 2122ff7a5ab921a04e999369f4e9b93c1ebe933964303f946e8c40ec35076b8b4533bd2bbcb45c46dbd098cf9c4b501edb03811a9a18b1940f92a1992ed4b5b6
7
- data.tar.gz: eba2a13a48ad2cd2fd1cab3cd5397c617099782d521c3ef227a2e3b3396f84f7e6f1ac568797836129c530cc6c5a9bba21e4f039cf112b8c232aa6c967bb4329
6
+ metadata.gz: ac9dd05e563f4f875c4523d69818a277d51e545a4bba616193cd81cc0ccbdf950f24a9cd823c8240db0129f45cb7b8fa4b28cbccef7defe56452da0ff5c512a5
7
+ data.tar.gz: 9b3ff46d9376958374cdd10417c9f792f93fe2d50707787bb0f6bfa9619a1ec429cdccb5c7ae797d5df87af19d6dbb930a5692a2066d46a3c5cd8c556b437350
@@ -0,0 +1 @@
1
+ rails_admin_user_abilities
@@ -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/enjoycreative/rails_admin_user_abilities.
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
@@ -12,3 +12,6 @@
12
12
  height: 20px
13
13
  label
14
14
  font-size: 18px
15
+
16
+ .json_block
17
+ margin-bottom: 50px
@@ -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:
@@ -1,5 +1,4 @@
1
-
2
- require "rails_admin_comments/version"
1
+ require "rails_admin_user_abilities/version"
3
2
 
4
3
  require 'mongoid'
5
4
  require 'mongoid_userstamp'
@@ -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
- _model = model_name.constantize
12
- rules.each_pair do |act, meth|
13
- ability_object.send(meth, act.to_sym, _model)
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
- _model = model_name.constantize
19
- ids_rules.each_pair do |obj_id, rules|
20
- rules.each_pair do |act, meth|
21
- ability_object.send(meth, act.to_sym, _model, {id: BSON::ObjectId.from_string(obj_id)})
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
@@ -1,3 +1,3 @@
1
1
  module RailsAdminUserAbilities
2
- VERSION = "0.1.0.1"
2
+ VERSION = "0.1.0.2".freeze
3
3
  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@enjoycreate.ru"]
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
@@ -2,6 +2,5 @@
2
2
  bundle update
3
3
  git add --all .
4
4
  git commit -am "${*:1}"
5
- git push
6
- git push gh master
5
+ git push -u origin master
7
6
  rake release
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.1
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-07-18 00:00:00.000000000 Z
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@enjoycreate.ru
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