faalis 0.11.0 → 0.11.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51c65def59ed76316939971e4a3ea8f73aa9bcdc
|
4
|
+
data.tar.gz: 3ff82b9fa6aab48e7c09a889dc6c27a8d846762c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 353e68754e80ee0079e9ec5b816ef51bb46592054e4df572dedf95b2cbc72201749e12917a192759d4af4171fe826481c164fccdf2a70b35123b71a66947ad54
|
7
|
+
data.tar.gz: 686429d477d1e789649dad65b864f2dcb42c204a11b7c6f7ff43e71b1b71555d869f0da874c270153cffcc5bfd38ce761838e8acf1d85f32379de09c900ef83d
|
@@ -12,11 +12,22 @@ module Faalis
|
|
12
12
|
def index
|
13
13
|
@permissions = []
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
::ApplicationModels.all.each do |m|
|
16
|
+
|
17
|
+
model = m.model.constantize
|
18
|
+
if model.respond_to? :permission_strings
|
19
|
+
@permissions.concat(model.permission_strings(model))
|
20
|
+
end
|
18
21
|
end
|
19
|
-
|
22
|
+
|
23
|
+
Faalis::Engine.models_with_permission.each do |m|
|
24
|
+
model = m.constantize
|
25
|
+
if model.respond_to? :permission_strings
|
26
|
+
@permissions.concat(model.permission_strings(model))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
respond_with(@permissions.uniq)
|
20
31
|
end
|
21
32
|
|
22
33
|
# @api GET permissions/user
|
@@ -26,14 +37,23 @@ module Faalis
|
|
26
37
|
perms = []
|
27
38
|
if current_user.group_id == 1
|
28
39
|
# Generate all possible permissions for admin group
|
29
|
-
|
30
|
-
|
40
|
+
::ApplicationModels.all.each do |model|
|
41
|
+
model.model.constantize.possible_permissions.each do |p|
|
42
|
+
perm = DummyPerm.new
|
43
|
+
perm.model = model.model
|
44
|
+
perm.permission_type = p
|
45
|
+
perms << perm
|
46
|
+
end
|
47
|
+
end
|
48
|
+
Faalis::Engine.models_with_permission.each do |m|
|
49
|
+
m.constantize.possible_permissions.each do |p|
|
31
50
|
perm = DummyPerm.new
|
32
|
-
perm.model =
|
51
|
+
perm.model = m
|
33
52
|
perm.permission_type = p
|
34
53
|
perms << perm
|
35
54
|
end
|
36
55
|
end
|
56
|
+
perms.uniq!
|
37
57
|
else
|
38
58
|
perms = current_user.group.permissions
|
39
59
|
end
|
data/lib/faalis/engine.rb
CHANGED
data/lib/faalis/permissions.rb
CHANGED
@@ -2,7 +2,9 @@ module Faalis
|
|
2
2
|
module Permissions
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
|
+
|
5
6
|
module ClassMethods
|
7
|
+
|
6
8
|
# Default permission hash
|
7
9
|
@@permissions = {
|
8
10
|
:read => nil,
|
@@ -16,10 +18,16 @@ module Faalis
|
|
16
18
|
# @return an array of strings representation of permissions
|
17
19
|
def permission_strings(model)
|
18
20
|
strings = []
|
21
|
+
model_name = model.to_s
|
22
|
+
humanize_name = ActiveModel::Name.new(model).human
|
23
|
+
if model.respond_to? :model_name
|
24
|
+
model_name = model.model_name
|
25
|
+
humanize_name = model_name.human
|
26
|
+
end
|
19
27
|
@@permissions.each do |key, value|
|
20
28
|
strings << {
|
21
|
-
:name => "#{key}|#{
|
22
|
-
:string => _("can %s %s") % [_(key.to_s),
|
29
|
+
:name => "#{key}|#{model_name}",
|
30
|
+
:string => _("can %s %s") % [_(key.to_s), humanize_name]
|
23
31
|
}
|
24
32
|
end
|
25
33
|
strings
|
@@ -61,5 +69,4 @@ module Faalis
|
|
61
69
|
|
62
70
|
end
|
63
71
|
end
|
64
|
-
|
65
72
|
end
|
data/lib/faalis/version.rb
CHANGED