1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
5 require 'can_be_an_owner'
8 class Group < ArvadosModel
11 include CommonApiTemplate
15 after_create :invalidate_permissions_cache
16 after_update :maybe_invalidate_permissions_cache
17 before_create :assign_name
19 api_accessible :user, extend: :common do |t|
29 def maybe_invalidate_permissions_cache
30 if uuid_changed? or owner_uuid_changed?
31 # This can change users' permissions on other groups as well as
33 invalidate_permissions_cache
37 def invalidate_permissions_cache
38 # Ensure a new group can be accessed by the appropriate users
39 # immediately after being created.
40 User.invalidate_permissions_cache db_current_time.to_i
44 if self.new_record? and (self.name.nil? or self.name.empty?)