eco-helpers 2.0.14 → 2.0.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +90 -2
- data/eco-helpers.gemspec +6 -4
- data/lib/eco-helpers.rb +2 -0
- data/lib/eco/api/common/base_loader.rb +14 -0
- data/lib/eco/api/common/people/default_parsers/date_parser.rb +11 -1
- data/lib/eco/api/common/people/default_parsers/login_providers_parser.rb +1 -1
- data/lib/eco/api/common/people/default_parsers/policy_groups_parser.rb +11 -11
- data/lib/eco/api/common/people/entry_factory.rb +26 -9
- data/lib/eco/api/common/people/person_entry.rb +5 -2
- data/lib/eco/api/common/people/supervisor_helpers.rb +27 -0
- data/lib/eco/api/common/session.rb +1 -0
- data/lib/eco/api/common/session/base_session.rb +2 -0
- data/lib/eco/api/common/session/file_manager.rb +2 -2
- data/lib/eco/api/common/session/helpers.rb +30 -0
- data/lib/eco/api/common/session/helpers/prompt_user.rb +34 -0
- data/lib/eco/api/common/session/mailer.rb +0 -1
- data/lib/eco/api/common/session/s3_uploader.rb +0 -1
- data/lib/eco/api/common/session/sftp.rb +0 -1
- data/lib/eco/api/common/version_patches/ecoportal_api/external_person.rb +1 -1
- data/lib/eco/api/common/version_patches/ecoportal_api/internal_person.rb +7 -4
- data/lib/eco/api/common/version_patches/exception.rb +8 -4
- data/lib/eco/api/microcases.rb +3 -1
- data/lib/eco/api/microcases/append_usergroups.rb +0 -1
- data/lib/eco/api/microcases/people_cache.rb +2 -2
- data/lib/eco/api/microcases/people_load.rb +2 -2
- data/lib/eco/api/microcases/people_refresh.rb +2 -2
- data/lib/eco/api/microcases/people_search.rb +6 -6
- data/lib/eco/api/microcases/preserve_default_tag.rb +23 -0
- data/lib/eco/api/microcases/preserve_filter_tags.rb +28 -0
- data/lib/eco/api/microcases/preserve_policy_groups.rb +30 -0
- data/lib/eco/api/microcases/set_account.rb +0 -1
- data/lib/eco/api/microcases/with_each.rb +67 -6
- data/lib/eco/api/microcases/with_each_present.rb +4 -2
- data/lib/eco/api/microcases/with_each_starter.rb +4 -2
- data/lib/eco/api/organization.rb +1 -0
- data/lib/eco/api/organization/people.rb +98 -22
- data/lib/eco/api/organization/people_similarity.rb +112 -0
- data/lib/eco/api/organization/person_schemas.rb +5 -1
- data/lib/eco/api/organization/policy_groups.rb +5 -1
- data/lib/eco/api/organization/presets_factory.rb +40 -80
- data/lib/eco/api/organization/presets_integrity.json +6 -0
- data/lib/eco/api/organization/presets_values.json +5 -4
- data/lib/eco/api/policies/default_policies/99_user_access_policy.rb +0 -30
- data/lib/eco/api/session.rb +6 -22
- data/lib/eco/api/session/batch.rb +25 -7
- data/lib/eco/api/session/config.rb +16 -15
- data/lib/eco/api/session/config/api.rb +4 -0
- data/lib/eco/api/session/config/apis.rb +80 -0
- data/lib/eco/api/session/config/files.rb +7 -0
- data/lib/eco/api/session/config/people.rb +3 -19
- data/lib/eco/api/usecases/default_cases.rb +4 -1
- data/lib/eco/api/usecases/default_cases/abstract_policygroup_abilities_case.rb +161 -0
- data/lib/eco/api/usecases/default_cases/analyse_people_case.rb +53 -0
- data/lib/eco/api/usecases/default_cases/codes_to_tags_case.rb +2 -3
- data/lib/eco/api/usecases/default_cases/reset_landing_page_case.rb +11 -1
- data/lib/eco/api/usecases/default_cases/restore_db_case.rb +1 -2
- data/lib/eco/api/usecases/default_cases/supers_cyclic_identify_case.rb +72 -0
- data/lib/eco/api/usecases/default_cases/supers_hierarchy_case.rb +59 -0
- data/lib/eco/api/usecases/default_cases/to_csv_case.rb +132 -29
- data/lib/eco/api/usecases/default_cases/to_csv_detailed_case.rb +61 -36
- data/lib/eco/api/usecases/ooze_samples/ooze_update_case.rb +3 -2
- data/lib/eco/cli.rb +0 -10
- data/lib/eco/cli/config/default/options.rb +20 -17
- data/lib/eco/cli/config/default/people_filters.rb +3 -3
- data/lib/eco/cli/config/default/usecases.rb +80 -26
- data/lib/eco/cli/config/default/workflow.rb +16 -4
- data/lib/eco/cli/config/help.rb +1 -0
- data/lib/eco/cli/config/options_set.rb +106 -13
- data/lib/eco/cli/config/use_cases.rb +33 -33
- data/lib/eco/cli/scripting/args_helpers.rb +30 -3
- data/lib/eco/csv.rb +4 -2
- data/lib/eco/data.rb +1 -0
- data/lib/eco/data/crypto/encryption.rb +3 -3
- data/lib/eco/data/files/directory.rb +28 -20
- data/lib/eco/data/files/helpers.rb +6 -4
- data/lib/eco/data/fuzzy_match.rb +161 -0
- data/lib/eco/data/fuzzy_match/array_helpers.rb +75 -0
- data/lib/eco/data/fuzzy_match/chars_position_score.rb +37 -0
- data/lib/eco/data/fuzzy_match/ngrams_score.rb +78 -0
- data/lib/eco/data/fuzzy_match/pairing.rb +101 -0
- data/lib/eco/data/fuzzy_match/result.rb +73 -0
- data/lib/eco/data/fuzzy_match/results.rb +59 -0
- data/lib/eco/data/fuzzy_match/score.rb +44 -0
- data/lib/eco/data/fuzzy_match/stop_words.rb +35 -0
- data/lib/eco/data/fuzzy_match/string_helpers.rb +69 -0
- data/lib/eco/version.rb +1 -1
- metadata +87 -10
- data/lib/eco/api/microcases/refresh_abilities.rb +0 -19
- data/lib/eco/api/organization/presets_reference.json +0 -59
- data/lib/eco/api/usecases/default_cases/refresh_abilities_case.rb +0 -30
@@ -16,10 +16,9 @@ class Eco::API::UseCases::DefaultCases::CodesToTagsCase < Eco::API::Common::Load
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def main(session, options, usecase)
|
19
|
-
|
20
|
-
@options = options
|
19
|
+
options[:end_get] = false
|
20
|
+
@session = session; @options = options
|
21
21
|
codes_to_tags
|
22
|
-
exit
|
23
22
|
end
|
24
23
|
|
25
24
|
private
|
@@ -2,13 +2,23 @@ class Eco::API::UseCases::DefaultCases::ResetLandingPageCase < Eco::API::Common:
|
|
2
2
|
name "reset-landing-page"
|
3
3
|
type :transform
|
4
4
|
|
5
|
+
attr_reader :session, :options
|
6
|
+
|
5
7
|
def main(people, session, options, usecase)
|
8
|
+
@session = session; @options = options
|
6
9
|
update = session.new_job("main", "update", :update, usecase, :core)
|
7
10
|
|
8
11
|
people.users.each do |user|
|
9
|
-
user.account.landing_page_id =
|
12
|
+
user.account.landing_page_id = page_id
|
10
13
|
update.add(user)
|
11
14
|
end
|
12
15
|
end
|
13
16
|
|
17
|
+
private
|
18
|
+
|
19
|
+
def page_id
|
20
|
+
options[:page_id]
|
21
|
+
end
|
22
|
+
|
23
|
+
|
14
24
|
end
|
@@ -59,7 +59,6 @@ class Eco::API::UseCases::DefaultCases::RestoreDBCase < Eco::API::Common::Loader
|
|
59
59
|
dst.policy_group_ids = src.policy_group_ids unless options.dig(:exclude, :policy_groups)
|
60
60
|
|
61
61
|
unless options.dig(:exclude, :abilities)
|
62
|
-
dst.permissions_preset = src.permissions_preset
|
63
62
|
dst.permissions_custom = src.permissions_custom
|
64
63
|
end
|
65
64
|
|
@@ -75,7 +74,7 @@ class Eco::API::UseCases::DefaultCases::RestoreDBCase < Eco::API::Common::Loader
|
|
75
74
|
dst.starred_ids = src.starred_ids
|
76
75
|
dst.landing_page_id = src.landing_page_id
|
77
76
|
end
|
78
|
-
|
77
|
+
|
79
78
|
dst&.send_invites = options[:send_invites] if options.key?(:send_invites)
|
80
79
|
end
|
81
80
|
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
class Eco::API::UseCases::DefaultCases::SupersCyclicIdentify < Eco::API::Common::Loaders::UseCase
|
2
|
+
name "identify-cyclic-supers"
|
3
|
+
type :export
|
4
|
+
|
5
|
+
attr_reader :session, :people, :options
|
6
|
+
|
7
|
+
def main(people, session, options, usecase)
|
8
|
+
options[:end_get] = false
|
9
|
+
@session = session; @options = options; @people = people
|
10
|
+
|
11
|
+
save!(cyclic_sets)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def cyclic_sets
|
17
|
+
Eco::API::Common::People::SupervisorHelpers.identify_cyclic_chains(people)
|
18
|
+
end
|
19
|
+
|
20
|
+
def file
|
21
|
+
@file ||= options.dig(:output, :file) || "cyclic_supers.txt"
|
22
|
+
end
|
23
|
+
|
24
|
+
def save!(data)
|
25
|
+
if data.empty?
|
26
|
+
session.logger.info("There were no cyclic supervisors identified!!")
|
27
|
+
return
|
28
|
+
end
|
29
|
+
|
30
|
+
ext = File.extname(file).downcase.delete(".")
|
31
|
+
|
32
|
+
File.open(file, "w") do |fd|
|
33
|
+
if ext == "txt"
|
34
|
+
create_file(data, file: file, format: :txt)
|
35
|
+
elsif ext == "html"
|
36
|
+
puts "html is still not supported"
|
37
|
+
exit(1)
|
38
|
+
create_file(data, file: file, format: :html)
|
39
|
+
elsif ext == "json"
|
40
|
+
puts "json is still not supported"
|
41
|
+
exit(1)
|
42
|
+
create_file(data, file: file, format: :json)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def create_file(sets, file:, format: :txt)
|
48
|
+
File.open(file, "w") do |fd|
|
49
|
+
fd << sets_to_str(sets, format: format)
|
50
|
+
end
|
51
|
+
puts "Generated file #{file}"
|
52
|
+
end
|
53
|
+
|
54
|
+
def sets_to_str(sets, format: :txt)
|
55
|
+
raise "Required Array. Given: #{sets.class}" unless sets.is_a?(Array)
|
56
|
+
"".tap do |str|
|
57
|
+
sets.each do |set|
|
58
|
+
str << set_to_str(set, format: format)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def set_to_str(set, lev: 0, format: :txt)
|
64
|
+
raise "Required Array. Given: #{set.class}" unless set.is_a?(Array)
|
65
|
+
"".tap do |str|
|
66
|
+
entry = set.shift
|
67
|
+
str << "#{" " * lev}#{(lev > 0)? "+-#{lev}- " : ""}#{entry.name} (#{entry.external_id}|#{entry.email}|#{entry.id})\n"
|
68
|
+
str << set_to_str(set, lev: lev + 1, format: format) unless !set || set.empty?
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
class Eco::API::UseCases::DefaultCases::SupersHierarchy < Eco::API::Common::Loaders::UseCase
|
2
|
+
name "supers-hierarchy"
|
3
|
+
type :export
|
4
|
+
|
5
|
+
attr_reader :session, :people, :options
|
6
|
+
|
7
|
+
def main(people, session, options, usecase)
|
8
|
+
options[:end_get] = false
|
9
|
+
@session = session; @options = options; @people = people
|
10
|
+
|
11
|
+
save!(hierarchy)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def hierarchy
|
17
|
+
Eco::API::Common::People::SupervisorHelpers.supervisors_tree(people)
|
18
|
+
end
|
19
|
+
|
20
|
+
def file
|
21
|
+
@file ||= options.dig(:output, :file) || "supers_hierarchy.txt"
|
22
|
+
end
|
23
|
+
|
24
|
+
def save!(data)
|
25
|
+
ext = File.extname(file).downcase.delete(".")
|
26
|
+
|
27
|
+
File.open(file, "w") do |fd|
|
28
|
+
if ext == "txt"
|
29
|
+
create_file(data, file: file, format: :txt)
|
30
|
+
elsif ext == "html"
|
31
|
+
puts "html is still not supported"
|
32
|
+
exit(1)
|
33
|
+
create_file(data, file: file, format: :html)
|
34
|
+
elsif ext == "json"
|
35
|
+
puts "json is still not supported"
|
36
|
+
exit(1)
|
37
|
+
create_file(data, file: file, format: :json)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def create_file(tree, file:, format: :txt)
|
43
|
+
File.open(file, "w") do |fd|
|
44
|
+
fd << tree_to_str(tree, format: format)
|
45
|
+
end
|
46
|
+
puts "Generated file #{file}"
|
47
|
+
end
|
48
|
+
|
49
|
+
def tree_to_str(tree, lev: 0, format: :txt)
|
50
|
+
raise "Required Hash tree structure. Given: #{tree.class}" unless tree.is_a?(Hash)
|
51
|
+
"".tap do |str|
|
52
|
+
tree.each do |entry, subtree|
|
53
|
+
str << "#{" " * lev}#{(lev > 0)? "+-#{lev}- " : ""}#{entry.name} (#{entry.external_id}|#{entry.email}|#{entry.id})\n"
|
54
|
+
str << tree_to_str(subtree, lev: lev + 1, format: format) unless !subtree || subtree.empty?
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -5,6 +5,7 @@ class Eco::API::UseCases::DefaultCases::ToCsvCase < Eco::API::Common::Loaders::U
|
|
5
5
|
attr_reader :session, :options, :people
|
6
6
|
|
7
7
|
def main(people, session, options, usecase)
|
8
|
+
options[:end_get] = false
|
8
9
|
@session = session; @options = options; @people = people
|
9
10
|
|
10
11
|
unless people && !people.empty?
|
@@ -12,25 +13,62 @@ class Eco::API::UseCases::DefaultCases::ToCsvCase < Eco::API::Common::Loaders::U
|
|
12
13
|
return false
|
13
14
|
end
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
if options.dig(:export, :options, :split_schemas)
|
17
|
+
by_schema.each do |id, people|
|
18
|
+
sch_name = schemas.to_name(id)
|
19
|
+
prefix = sch_name ? sch_name.gsub(" ", "_") : "No_Schema"
|
20
|
+
create_file!("#{prefix}_#{file}", people)
|
21
|
+
end
|
22
|
+
else
|
23
|
+
create_file!(file, people)
|
18
24
|
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
19
28
|
|
20
|
-
|
29
|
+
def create_file!(filename = file, data = people)
|
30
|
+
session.logger.info("going to create file: #{filename}")
|
21
31
|
|
22
|
-
CSV.open(
|
23
|
-
csv << spot_header
|
24
|
-
|
25
|
-
csv <<
|
32
|
+
CSV.open(filename, "w") do |csv|
|
33
|
+
csv << spot_header(data.first)
|
34
|
+
data.each do |person|
|
35
|
+
csv << to_row(person)
|
26
36
|
end
|
27
37
|
end
|
28
|
-
exit(0)
|
29
38
|
end
|
30
39
|
|
31
|
-
|
40
|
+
def to_row(person)
|
41
|
+
entry = to_entry_type(person)
|
42
|
+
entry.values_at(*keys(entry)).tap do |row|
|
43
|
+
row << schemas.to_name(person.details&.schema_id) || "No Schema"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def spot_header(person = people.first)
|
48
|
+
header = keys(to_entry_type(person))
|
49
|
+
header << "Schema"
|
50
|
+
header = yield(header) if block_given?
|
51
|
+
header = nice_header_names(header, schema: schema(person.details)) if nice_header_names?
|
52
|
+
header
|
53
|
+
end
|
54
|
+
|
55
|
+
def keys(entry)
|
56
|
+
entry.keys - ["freemium", "send_invites"]
|
57
|
+
end
|
58
|
+
|
59
|
+
def nice_header_names?
|
60
|
+
options.dig(:nice_header) || options.dig(:export, :options, :nice_header)
|
61
|
+
end
|
32
62
|
|
33
|
-
def
|
63
|
+
def nice_header_names(header, schema: nil)
|
64
|
+
schema ||= session.schema
|
65
|
+
name_maps = schema.fields_by_alt_id.each_with_object({}) do |(alt_id, fld), mappings|
|
66
|
+
mappings[alt_id] = fld.name
|
67
|
+
end.merge(nice_header_maps)
|
68
|
+
header.map {|name| name_maps[name] ? name_maps[name] : name}
|
69
|
+
end
|
70
|
+
|
71
|
+
def to_entry_type(person)
|
34
72
|
session.new_entry(person, dependencies: deps).yield_self do |person_entry|
|
35
73
|
options.dig(:export, :options, :internal_names) ? person_entry.mapped_entry : person_entry.external_entry
|
36
74
|
end
|
@@ -40,26 +78,91 @@ class Eco::API::UseCases::DefaultCases::ToCsvCase < Eco::API::Common::Loaders::U
|
|
40
78
|
@deps ||= {"supervisor_id" => {people: people}}
|
41
79
|
end
|
42
80
|
|
43
|
-
def
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
81
|
+
def file
|
82
|
+
@file ||= (options[:file] || options.dig(:export, :file, :name)).tap do |filename|
|
83
|
+
unless filename
|
84
|
+
session.logger.error("Destination file not specified")
|
85
|
+
return false
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def by_schema
|
91
|
+
people.group_by do |person|
|
92
|
+
if details = person.details
|
93
|
+
details.schema_id
|
94
|
+
end
|
95
|
+
end.transform_values do |persons|
|
96
|
+
people.newFrom persons
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def schema(value)
|
101
|
+
case value
|
102
|
+
when Ecoportal::API::V1::Person
|
103
|
+
schema(value.details&.schema_id)
|
104
|
+
when String
|
105
|
+
schemas[value]
|
106
|
+
when Ecoportal::API::V1::PersonDetails
|
107
|
+
schema(value.schema_id)
|
108
|
+
when Ecoportal::API::V1::PersonSchema
|
109
|
+
value
|
60
110
|
end
|
61
|
-
header
|
62
111
|
end
|
63
112
|
|
113
|
+
def schemas
|
114
|
+
session.schemas
|
115
|
+
end
|
116
|
+
|
117
|
+
def nice_header_maps
|
118
|
+
@nice_header_maps ||= {
|
119
|
+
"policy_group_ids" => "User Group(s)",
|
120
|
+
"email" => "Email",
|
121
|
+
"name" => "Name",
|
122
|
+
"supervisor_id" => "Manager ID",
|
123
|
+
"filter_tags" => "Locations",
|
124
|
+
"default_tag" => "Default Location",
|
125
|
+
"id" => "ecoPortal ID",
|
126
|
+
"external_id" => "Reference ID (ext_id)",
|
127
|
+
"login_provider_ids" => "Login Methods",
|
128
|
+
"landing_page_id" => "Landing Page ID",
|
129
|
+
"show_sidebar" => "(pref) Sidebar Open?",
|
130
|
+
"show_shortcuts" => "(pref) Link to Registers?",
|
131
|
+
"show_coming_soon" => "(pref) Coming Soon List?",
|
132
|
+
"show_recently_visited_forms" => "(pref) Recently Visited Forms List?",
|
133
|
+
"show_tasks" => "(pref) Tasks List?",
|
134
|
+
"show_task_bubbles" => "(pref) Task Count Bubbles",
|
135
|
+
"kiosk_enabled" => "Kiosk User?",
|
136
|
+
"freemium" => "Freemium User?",
|
137
|
+
"files" => "(able) on Files",
|
138
|
+
"reports" => "(able) on Report Structures",
|
139
|
+
"data" => "(able) on Data (hours, datasets)",
|
140
|
+
"organization" => "(able) on Organization Config",
|
141
|
+
"pages" => "(able) on Page/Entries",
|
142
|
+
"page_editor" => "(able) page Editor Level",
|
143
|
+
"registers" => "(able) on Registers",
|
144
|
+
"tasks" => "(able) on Tasks",
|
145
|
+
"person_core" => "(able) on People",
|
146
|
+
"person_core_create" => "(able) Create People?",
|
147
|
+
"person_core_edit" => "(able) Edit People?",
|
148
|
+
"person_details" => "(able) on People Schema Details",
|
149
|
+
"person_account" => "(able) on Users",
|
150
|
+
"person_abilities" => "(able) on Users' Abilities",
|
151
|
+
"custom_files" => "(min) on Files",
|
152
|
+
"custom_reports" => "(min) on Report Structures",
|
153
|
+
"custom_data" => "(min) on Data (hours, datasets)",
|
154
|
+
"custom_organization" => "(min) on Organization Config",
|
155
|
+
"custom_pages" => "(min) on Page/Entries",
|
156
|
+
"custom_page_editor" => "(min) page Editor Level",
|
157
|
+
"custom_registers" => "(min) on Registers",
|
158
|
+
"custom_tasks" => "(min) on Tasks",
|
159
|
+
"custom_person_core" => "(min) on People",
|
160
|
+
"custom_person_core_create" => "(min) Create People?",
|
161
|
+
"custom_person_core_edit" => "(min) Edit People?",
|
162
|
+
"custom_person_details" => "(min) on People Schema Details",
|
163
|
+
"custom_person_account" => "(min) on Users",
|
164
|
+
"custom_person_abilities" => "(min) on Users' Abilities"
|
165
|
+
}
|
166
|
+
end
|
64
167
|
|
65
168
|
end
|
@@ -1,53 +1,78 @@
|
|
1
|
-
class Eco::API::UseCases::DefaultCases::ToCsvDetailedCase < Eco::API::
|
1
|
+
class Eco::API::UseCases::DefaultCases::ToCsvDetailedCase < Eco::API::UseCases::DefaultCases::ToCsvCase
|
2
2
|
name "to-csv-detailed"
|
3
3
|
type :export
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
private
|
6
|
+
|
7
|
+
def to_row(person)
|
8
|
+
data = super(person)
|
9
|
+
data << person.subordinates
|
10
|
+
data << person_supervisor(person)
|
11
|
+
data += user_abilities(person)
|
12
|
+
data += user_permissions_custom(person) if options.dig(:export, :options, :permissions_custom)
|
13
|
+
account = person.account
|
14
|
+
data << account&.landing_page_id
|
15
|
+
data += user_preferences(person)
|
16
|
+
data
|
17
|
+
end
|
10
18
|
|
11
|
-
|
12
|
-
|
13
|
-
return
|
19
|
+
def person_supervisor(person)
|
20
|
+
session.micro.with_supervisor(person.supervisor_id, people) do |supervisor|
|
21
|
+
return supervisor ? supervisor.name : ""
|
14
22
|
end
|
23
|
+
end
|
15
24
|
|
16
|
-
|
17
|
-
|
25
|
+
def user_abilities(person)
|
26
|
+
account_abilities = (person.account && person.account.permissions_merged) || {}
|
27
|
+
abilities.map {|key| account_abilities[key] || "no access"}
|
28
|
+
end
|
18
29
|
|
19
|
-
|
20
|
-
|
21
|
-
|
30
|
+
def user_permissions_custom(person)
|
31
|
+
account_abilities = (person.account && person.account.permissions_custom) || {}
|
32
|
+
abilities.map {|key| account_abilities[key] || "no access"}
|
33
|
+
end
|
22
34
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
header += ["Supervisor Name"]
|
28
|
-
header += abilities
|
29
|
-
header += ["Landing Page"]
|
35
|
+
def user_preferences(person)
|
36
|
+
user_preferences = (person.account && person.account.preferences&.doc) || {}
|
37
|
+
preferences.map {|key| user_preferences[key] || false}
|
38
|
+
end
|
30
39
|
|
31
|
-
|
32
|
-
|
33
|
-
|
40
|
+
def spot_header(person = people.first)
|
41
|
+
super(person) do |header|
|
42
|
+
header << "Subordinates"
|
43
|
+
header << "Supervisor Name"
|
44
|
+
header += abilities_header
|
45
|
+
header += abilities_header("custom") if options.dig(:export, :options, :permissions_custom)
|
46
|
+
header << "Landing Page"
|
47
|
+
header += preferences
|
48
|
+
header
|
49
|
+
end
|
50
|
+
end
|
34
51
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
52
|
+
def keys(entry)
|
53
|
+
super(entry) + ["freemium"]
|
54
|
+
end
|
39
55
|
|
40
|
-
|
41
|
-
|
56
|
+
def login_providers
|
57
|
+
session.login_providers
|
58
|
+
end
|
42
59
|
|
43
|
-
|
44
|
-
|
45
|
-
|
60
|
+
def abilities
|
61
|
+
@abilities ||= session.presets_factory.keys
|
62
|
+
end
|
46
63
|
|
47
|
-
|
48
|
-
|
64
|
+
def abilities_header(prefix = nil)
|
65
|
+
abilities.map do |key|
|
66
|
+
prefix ? "#{prefix}_#{key}" : key
|
49
67
|
end
|
50
|
-
|
68
|
+
end
|
69
|
+
|
70
|
+
def preferences
|
71
|
+
@preferences ||= [
|
72
|
+
"show_sidebar", "show_shortcuts", "show_coming_soon", "show_recently_visited_forms",
|
73
|
+
"show_tasks", "show_task_bubbles",
|
74
|
+
"kiosk_enabled"
|
75
|
+
]
|
51
76
|
end
|
52
77
|
|
53
78
|
end
|