lib/eco/api/usecases/default_cases/update_case.rb in eco-helpers-0.6.17 vs lib/eco/api/usecases/default_cases/update_case.rb in eco-helpers-0.7.1
- old
+ new
@@ -3,17 +3,28 @@
module UseCases
class DefaultCases
class UpdateCase < BaseCase
def process
+ #opts = CLI::Options.new do |p|
+ # p.option :exclude, "Allows to exclude certain options"
+ # p.suboption :exclude, :core, "Excludes core details from the update.", optional: true
+ # p.suboption :exclude, :details, "Excludes schema details from the update.", optional: true
+ # p.suboption :exclude, :account, "Excludes account details from the update.", optional: true
+ # p.suboption :exclude, :email, "Excludes core email from the update.", optional: true
+ # p.suboption :exclude, :supervisor, "Excludes supervisor_id from the update.", optional: true
+ # p.suboption :exclude, :abilities, "Excludes the abilities from the update.", optional: true
+ #end
+
@cases.define("update", type: :sync) do |entries, people, session, options|
update = session.job_group("main").new("update", type: :update, sets: [:core, :details, :account])
+ strict_search = session.config.people.strict_search? || options.dig(:search, :strict)
pgs = session.policy_groups
entries.each.with_index do |entry, i|
- if person = people.find(entry)
+ if person = people.find(entry, strict: strict_search)
core_excluded = ["supervisor_id"]
core_excluded.push("email") if options.dig(:exclude, :email)
entry.set_core(person, exclude: core_excluded) unless options.dig(:exclude, :core)
entry.set_details(person) unless options.dig(:exclude, :details)
@@ -25,11 +36,11 @@
person.account.policy_group_ids = pgs.user_pg_ids(
initial: ini_pg_ids,
final: person.account.policy_group_ids
)
- person.account.permissions_custom = session.new_preset(person) unless options.dig(:exclude, :abilities)
+ person.account.permissions_custom = session.new_preset(person) unless !create && options.dig(:exclude, :abilities)
if session.tagtree
person.account.filter_tags = session.tagtree.user_tags(
initial: ini_tags,
final: person.account.filter_tags,
@@ -39,9 +50,12 @@
person.account.default_tag = session.tagtree.default_tag(*person.account.filter_tags)
else
tags = person.account.filter_tags
person.account.default_tag = tags.first unless tags.length > 1
end
+
+ person.account&.send_invites = options[:send_invites] if options.key?(:send_invites)
+
end
update.add(person)
else
session.logger.error("Entry(#{i}) - this person does not exist: #{entry.to_s(:identify)}")
end