card-mod-permissions 0.17.0 → 0.18.1
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.
- checksums.yaml +4 -4
- data/set/all/permissions.rb +45 -52
- data/set/right/read.rb +13 -14
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e83fede179035588ffd94b0fcd6b2f5294b2c4048fe566e84a79127aeccaeb82
|
4
|
+
data.tar.gz: 8a05b6acde33608837107921152944d7f31a4580ce258f7e1387f9bb1cab8d34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2d3fe3c58a93f8d38a59a098f84318f50d0ff5f23fb740c45956f8709a9875d99d15b05ef836793a5ea93880c23e45ace64bc740e747a1554befaacb97cf7c9
|
7
|
+
data.tar.gz: df3b064a25f5e8c75210ad0c5acc309496b89f46eb07c3439b06ddb6f788f0c310d8759b07e5821e489a2a279283582e69dd64870767b5608234be3f5d039eb2
|
data/set/all/permissions.rb
CHANGED
@@ -1,16 +1,28 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
event :set_read_rule, :store, on: :save, changed: %i[type_id name] do
|
2
|
+
read_rule_id, read_rule_class = permission_rule_id_and_class(:read)
|
3
|
+
self.read_rule_id = read_rule_id
|
4
|
+
self.read_rule_class = read_rule_class
|
5
|
+
end
|
6
|
+
|
7
|
+
event :set_field_read_rules, after: :set_read_rule, on: :update, changed: :type_id do
|
8
|
+
each_field_as_bot(&:update_read_rule)
|
9
|
+
end
|
10
|
+
|
11
|
+
event :update_read_rule do
|
12
|
+
without_timestamps do
|
13
|
+
reset_patterns # why is this needed?
|
14
|
+
set_read_rule
|
15
|
+
Card.where(id: id).update_all read_rule_id: read_rule_id,
|
16
|
+
read_rule_class: read_rule_class
|
17
|
+
expire :shared
|
18
|
+
update_field_read_rules
|
8
19
|
end
|
9
20
|
end
|
10
21
|
|
11
|
-
|
12
|
-
|
13
|
-
|
22
|
+
event :check_permissions, :validate do
|
23
|
+
track_permission_errors do
|
24
|
+
ok? action_for_permission_check
|
25
|
+
end
|
14
26
|
end
|
15
27
|
|
16
28
|
# ok? and ok! are public facing methods to approve one action at a time
|
@@ -21,8 +33,6 @@ end
|
|
21
33
|
# trait: :account would fetch this card plus a tag codenamed :account
|
22
34
|
# trait: :roles, new: {} would initialize a new card with default ({})
|
23
35
|
# options.
|
24
|
-
#
|
25
|
-
#
|
26
36
|
|
27
37
|
def ok? action
|
28
38
|
@ok ||= {}
|
@@ -42,12 +52,6 @@ def anyone_can? action
|
|
42
52
|
who_can(action).include? AnyoneID
|
43
53
|
end
|
44
54
|
|
45
|
-
def direct_rule_card action
|
46
|
-
direct_rule_id = rule_card_id action
|
47
|
-
require_permission_rule! direct_rule_id, action
|
48
|
-
Card.quick_fetch direct_rule_id
|
49
|
-
end
|
50
|
-
|
51
55
|
def permission_rule_id action
|
52
56
|
if compound? && rule(action).match?(/^\[?\[?_left\]?\]?$/)
|
53
57
|
left_permission_rule_id action
|
@@ -159,16 +163,6 @@ end
|
|
159
163
|
# self.read_rule_id = self.read_rule_class = nil
|
160
164
|
# end
|
161
165
|
|
162
|
-
event :set_read_rule, :store, on: :save, changed: %i[type_id name] do
|
163
|
-
read_rule_id, read_rule_class = permission_rule_id_and_class(:read)
|
164
|
-
self.read_rule_id = read_rule_id
|
165
|
-
self.read_rule_class = read_rule_class
|
166
|
-
end
|
167
|
-
|
168
|
-
event :set_field_read_rules, after: :set_read_rule, on: :update, changed: :type_id do
|
169
|
-
each_field_as_bot(&:update_read_rule)
|
170
|
-
end
|
171
|
-
|
172
166
|
def update_field_read_rules
|
173
167
|
return unless type_id_changed? || read_rule_id_changed?
|
174
168
|
|
@@ -186,6 +180,13 @@ def each_field_as_bot &block
|
|
186
180
|
end
|
187
181
|
end
|
188
182
|
|
183
|
+
def repair_permissions!
|
184
|
+
rule_id, rule_class = permission_rule_id_and_class :read
|
185
|
+
update_columns read_rule_id: rule_id, read_rule_class: rule_class
|
186
|
+
end
|
187
|
+
|
188
|
+
private
|
189
|
+
|
189
190
|
def without_timestamps
|
190
191
|
Card.record_timestamps = false
|
191
192
|
yield
|
@@ -193,30 +194,6 @@ ensure
|
|
193
194
|
Card.record_timestamps = true
|
194
195
|
end
|
195
196
|
|
196
|
-
event :update_read_rule do
|
197
|
-
without_timestamps do
|
198
|
-
reset_patterns # why is this needed?
|
199
|
-
rcard_id, rclass = permission_rule_id_and_class :read
|
200
|
-
# these two are just to make sure vals are correct on current object
|
201
|
-
self.read_rule_id = rcard_id
|
202
|
-
self.read_rule_class = rclass
|
203
|
-
Card.where(id: id).update_all read_rule_id: rcard_id, read_rule_class: rclass
|
204
|
-
expire :hard
|
205
|
-
# binding.pry if field_cards.include? nil
|
206
|
-
update_field_read_rules
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
def add_to_read_rule_update_queue updates
|
211
|
-
@read_rule_update_queue = Array.wrap(@read_rule_update_queue).concat updates
|
212
|
-
end
|
213
|
-
|
214
|
-
event :check_permissions, :validate do
|
215
|
-
track_permission_errors do
|
216
|
-
ok? action_for_permission_check
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
197
|
def action_for_permission_check
|
221
198
|
commenting? ? :update : action
|
222
199
|
end
|
@@ -228,3 +205,19 @@ def track_permission_errors
|
|
228
205
|
@permission_errors = nil
|
229
206
|
result
|
230
207
|
end
|
208
|
+
|
209
|
+
def direct_rule_card action
|
210
|
+
direct_rule_id = rule_card_id action
|
211
|
+
require_permission_rule! direct_rule_id, action
|
212
|
+
Card.quick_fetch direct_rule_id
|
213
|
+
end
|
214
|
+
|
215
|
+
module ClassMethods
|
216
|
+
def repair_all_permissions
|
217
|
+
Card.where("(read_rule_class is null or read_rule_id is null) and trash is false")
|
218
|
+
.each do |broken_card|
|
219
|
+
broken_card.include_set_modules
|
220
|
+
broken_card.repair_permissions!
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
data/set/right/read.rb
CHANGED
@@ -5,11 +5,24 @@ assign_type :list
|
|
5
5
|
format :html do include Abstract::Permission::HtmlFormat end
|
6
6
|
|
7
7
|
event :cascade_read_rule, :finalize, after: :update_rule_cache, when: :rule? do
|
8
|
+
# left&.update_lexicon
|
8
9
|
return unless name_is_changing? || trash_is_changing?
|
9
10
|
|
10
11
|
update_read_ruled_cards
|
11
12
|
end
|
12
13
|
|
14
|
+
def rule_pattern_index
|
15
|
+
return if trash
|
16
|
+
|
17
|
+
@rule_pattern_index ||= pattern_index rule_set&.tag&.id
|
18
|
+
end
|
19
|
+
|
20
|
+
def pattern_index pattern_id
|
21
|
+
Pattern.ids.index(pattern_id) || invalid_pattern_id(pattern_id)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
13
26
|
def update_read_ruled_cards
|
14
27
|
Card::Rule.clear_read_rule_cache
|
15
28
|
Card.cache.reset # maybe be more surgical, just Auth.user related
|
@@ -57,20 +70,6 @@ def all_members
|
|
57
70
|
rule_set.item_cards limit: 0
|
58
71
|
end
|
59
72
|
|
60
|
-
def rule_pattern_index
|
61
|
-
return if trash
|
62
|
-
|
63
|
-
@rule_pattern_index ||= pattern_index rule_set&.tag&.id
|
64
|
-
end
|
65
|
-
|
66
|
-
def pattern_index pattern_id
|
67
|
-
Pattern.ids.index(pattern_id) || invalid_pattern_id(pattern_id)
|
68
|
-
end
|
69
|
-
|
70
73
|
def invalid_pattern_id pattern_id
|
71
74
|
Rails.logger.info "invalid pattern id for read rule: #{pattern_id}"
|
72
75
|
end
|
73
|
-
|
74
|
-
event :process_read_rule_update_queue, :finalize do
|
75
|
-
left&.update_read_rule
|
76
|
-
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: card-mod-permissions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.18.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ethan McCutchen
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2024-
|
13
|
+
date: 2024-11-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: card
|
@@ -18,14 +18,14 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.
|
21
|
+
version: 1.108.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - '='
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: 1.
|
28
|
+
version: 1.108.1
|
29
29
|
description: ''
|
30
30
|
email:
|
31
31
|
- info@decko.org
|
@@ -55,7 +55,7 @@ files:
|
|
55
55
|
- set/self/update.rb
|
56
56
|
homepage: https://decko.org
|
57
57
|
licenses:
|
58
|
-
- GPL-3.0
|
58
|
+
- GPL-3.0-or-later
|
59
59
|
metadata:
|
60
60
|
source_code_uri: https://github.com/decko-commons/decko
|
61
61
|
homepage_uri: https://decko.org
|