eco-helpers 2.0.2 → 2.0.3
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44dd3a1b4d94cef2da5fc8c4618c6898bf0310f48778be120cd83503913af297
|
4
|
+
data.tar.gz: 128f7c6d4a4112636089c82ec61a127914263553af0fe4d54aad563d73088532
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d14f77e2cf74584eafc8c9834a71d52d1e399767352d27167ef5cbf05266c2a77777f866e64c482e610c8ca2a600aea3640256ed16ee1c6855a6b2db30af2c76
|
7
|
+
data.tar.gz: 1db0afa72df07479f22eca03553b3ac3c51f0228a7d726422a2f6e313565c960554be778c8b36515f1b14dc1085d8378d5d1ec859e96ef26cd116b36ccc738cf
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,16 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
-
## [2.0.
|
4
|
+
## [2.0.3] - 2021-02-23
|
5
|
+
|
6
|
+
### Added
|
7
|
+
- `Eco::API::UseCases::OozeSamples::OozeUpdateCase`: added integration to update page instances (non-templates)
|
8
|
+
|
9
|
+
### Changed
|
10
|
+
### Fixed
|
11
|
+
- `Eco::API::Policies::DefaultPolicies::UserAccess` complete default policy code.
|
12
|
+
|
13
|
+
## [2.0.2] - 2021-02-22
|
5
14
|
|
6
15
|
### Added
|
7
16
|
### Changed
|
@@ -1,18 +1,18 @@
|
|
1
1
|
class Eco::API::Policies::DefaultPolicies::UserAccess < Eco::API::Common::Loaders::Policy
|
2
2
|
name "default-user-access"
|
3
3
|
|
4
|
-
attr_reader
|
4
|
+
attr_reader :session, :options, :job
|
5
5
|
attr_accessor :account_removed_count
|
6
6
|
|
7
7
|
def main(people, session, options, policy, job)
|
8
|
-
@session = session; @options = options
|
8
|
+
@session = session; @options = options; @job = job
|
9
9
|
|
10
10
|
self.account_removed_count = 0
|
11
11
|
|
12
12
|
people.each do |person|
|
13
|
-
remove_account_when_no_email!(person)
|
14
|
-
person.account.policy_group_ids =
|
15
|
-
refresh_abilities!(person
|
13
|
+
remove_account_when_no_email!(person) if person.email.to_s.empty?
|
14
|
+
person.account.policy_group_ids = defid if no_policy_group_ids?(person)
|
15
|
+
refresh_abilities!(person)
|
16
16
|
end
|
17
17
|
|
18
18
|
warn_account_removal!
|
@@ -22,14 +22,14 @@ class Eco::API::Policies::DefaultPolicies::UserAccess < Eco::API::Common::Loader
|
|
22
22
|
|
23
23
|
def warn_account_removal!
|
24
24
|
if account_removed_count > 0
|
25
|
-
msg = "Removed account to #{account_removed_count} people"
|
25
|
+
msg = "(DefaultPolicy on job '#{job.name}') Removed account to #{account_removed_count} people"
|
26
26
|
session.logger.warn(msg)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
def remove_account_when_no_email!(person)
|
31
31
|
if person.account
|
32
|
-
account_removed_count += 1 if had_account?(person)
|
32
|
+
self.account_removed_count += 1 if had_account?(person)
|
33
33
|
person.account = nil
|
34
34
|
end
|
35
35
|
end
|
@@ -40,23 +40,11 @@ class Eco::API::Policies::DefaultPolicies::UserAccess < Eco::API::Common::Loader
|
|
40
40
|
return !!person.original_doc["account"]
|
41
41
|
end
|
42
42
|
|
43
|
-
def
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
if no_abilities?(person)
|
50
|
-
account.permissions_custom = min_abilities
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def refresh_abilities!(account)
|
58
|
-
return nil unless account
|
59
|
-
|
43
|
+
def refresh_abilities!(person)
|
44
|
+
return nil if options.dig(:exclude, :abilities)
|
45
|
+
return nil unless account = person.account
|
46
|
+
account.permissions_custom = session.new_preset(person)
|
47
|
+
account.permissions_custom = min_abilities if no_abilities?(person)
|
60
48
|
end
|
61
49
|
|
62
50
|
def no_policy_group_ids?(person)
|
@@ -64,8 +52,8 @@ class Eco::API::Policies::DefaultPolicies::UserAccess < Eco::API::Common::Loader
|
|
64
52
|
end
|
65
53
|
|
66
54
|
def no_abilities?(person)
|
67
|
-
person.account
|
68
|
-
|
55
|
+
return true unless account = person.account
|
56
|
+
account.permissions_custom && account.permissions_custom.values.all?(&:nil?)
|
69
57
|
end
|
70
58
|
|
71
59
|
def min_abilities
|
@@ -86,7 +74,7 @@ class Eco::API::Policies::DefaultPolicies::UserAccess < Eco::API::Common::Loader
|
|
86
74
|
end
|
87
75
|
|
88
76
|
def defid
|
89
|
-
@defid ||= policy_groups.to_id(default_group)
|
77
|
+
@defid ||= policy_groups.to_id([default_group]).compact
|
90
78
|
end
|
91
79
|
|
92
80
|
def default_group
|
@@ -195,6 +195,7 @@ module Eco
|
|
195
195
|
# @yieldreturn [Eco::API::UseCases::BaseIO] the `io` input/output object carried througout all the _workflow_
|
196
196
|
# @return [Eco::API::Session::Config::Workflow] the current stage object (to ease chainig).
|
197
197
|
def run(key = nil, io:, &block)
|
198
|
+
raise "Missing BaseIO object" unless io.is_a?(Eco::API::UseCases::BaseIO)
|
198
199
|
begin
|
199
200
|
if key
|
200
201
|
io = stage(key).run(io: io, &block)
|
@@ -25,10 +25,30 @@ class Eco::API::UseCases::OozeSamples::OozeUpdateCase < Eco::API::Common::Loader
|
|
25
25
|
options.dig(:source, :ooze_id)
|
26
26
|
end
|
27
27
|
|
28
|
+
def stage_id
|
29
|
+
options.dig(:source, :stage_id)
|
30
|
+
end
|
31
|
+
|
32
|
+
def stage(id_name = stage_id)
|
33
|
+
if stg = ooze.stages[id_name] || ooze.stages.get_by_name(id_name)
|
34
|
+
return apiv2.pages.get(ooze_id, stage_id: stg.id).tap do |stage|
|
35
|
+
if stage
|
36
|
+
new_target(stage)
|
37
|
+
logger.info("Got #{object_reference(stage)} from #{object_reference(ooze)}")
|
38
|
+
else
|
39
|
+
logger.error("Could not get stage '#{id_name}' in ooze '#{ooze_id}'")
|
40
|
+
exit(1)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
raise "Stage '#{id_name}' doesn't exist in ooze '#{ooze_id}'"
|
45
|
+
end
|
46
|
+
|
28
47
|
def ooze
|
29
48
|
@ooze ||= apiv2.pages.get(ooze_id).tap do |ooze|
|
30
49
|
if ooze
|
31
|
-
|
50
|
+
new_target(ooze)
|
51
|
+
logger.info("Got #{object_reference(ooze)}")
|
32
52
|
else
|
33
53
|
logger.error("Could not get ooze '#{ooze_id}'")
|
34
54
|
exit(1)
|
@@ -39,7 +59,7 @@ class Eco::API::UseCases::OozeSamples::OozeUpdateCase < Eco::API::Common::Loader
|
|
39
59
|
def launch_request
|
40
60
|
prompt_to_confirm!
|
41
61
|
|
42
|
-
apiv2.pages.update(
|
62
|
+
apiv2.pages.update(target).tap do |response|
|
43
63
|
if response.success?
|
44
64
|
logger.info("All went OK")
|
45
65
|
else
|
@@ -59,9 +79,35 @@ class Eco::API::UseCases::OozeSamples::OozeUpdateCase < Eco::API::Common::Loader
|
|
59
79
|
@apiv2 ||= session.api(version: :oozes)
|
60
80
|
end
|
61
81
|
|
62
|
-
def
|
63
|
-
|
64
|
-
|
82
|
+
def target
|
83
|
+
@target
|
84
|
+
end
|
85
|
+
|
86
|
+
def new_target(object)
|
87
|
+
if @target && patch_doc["page"]
|
88
|
+
logger.warn "You you are switching to a new target #{object_reference(object)} after doing unsaved changes to #{object_reference(@target)}"
|
89
|
+
end
|
90
|
+
@target = object
|
91
|
+
end
|
92
|
+
|
93
|
+
def object_reference(obj)
|
94
|
+
return "No reference" unless obj
|
95
|
+
"".tap do |ref|
|
96
|
+
case obj
|
97
|
+
when Ecoportal::API::V2::Page::Stage
|
98
|
+
ref << "Stage "
|
99
|
+
when Ecoportal::API::V2::Pages::PageStage
|
100
|
+
ref << "StagePage "
|
101
|
+
when Ecoportal::API::V2::Page
|
102
|
+
ref << "Page "
|
103
|
+
end
|
104
|
+
ref << "'#{obj.name}' " if obj.respond_to?(:name)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
|
109
|
+
def patch_doc
|
110
|
+
apiv2.pages.get_body(target)
|
65
111
|
end
|
66
112
|
|
67
113
|
def backup_patch!
|
data/lib/eco/version.rb
CHANGED