lib/eco/api/microcases/fix_default_group.rb in eco-helpers-2.7.24 vs lib/eco/api/microcases/fix_default_group.rb in eco-helpers-2.7.25
- old
+ new
@@ -4,31 +4,30 @@
# If defined, it sets the default usergroup, only when the `policy_group_ids` was not part of the input data.
# @param entry [PersonEntry] the input entry with the data we should set on person.
# @param person [Ecoportal::API::V1::Person] the person we want to update, carrying the changes to be done.
# @param options [Hash] the options.
def fix_default_group(entry, person, options)
- unless options.dig(:exclude, :account)
- unless options.dig(:exclude, :policy_groups) && !person.new?
- end_pg_ids = person.account.policy_group_ids
+ return if options.dig(:exclude, :account)
+ return if options.dig(:exclude, :policy_groups) && !person.new?
- if person.account_added? && __def_usergroup_id && !entry.policy_group_ids?
- # on account creation, if missing policy_group_ids column in the input
- # use default_usergroup, if it's defined
- end_pg_ids = [__def_usergroup_id]
- end
+ end_pg_ids = person.account.policy_group_ids
- person.account.policy_group_ids = end_pg_ids
- end
+ if person.account_added? && __def_usergroup_id && !entry.policy_group_ids?
+ # on account creation, if missing policy_group_ids column in the input
+ # use default_usergroup, if it's defined
+ end_pg_ids = [__def_usergroup_id]
end
+
+ person.account.policy_group_ids = end_pg_ids
end
private
def __def_usergroup_id
- @def_usergroup_id ||= if session.config.people.default_usergroup?
- session.policy_groups.to_id(session.config.people.default_usergroup)
- end
+ @__def_usergroup_id ||=
+ if session.config.people.default_usergroup?
+ session.policy_groups.to_id(session.config.people.default_usergroup)
+ end
end
-
end
end
end