1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
5 require 'can_be_an_owner'
7 class Group < ArvadosModel
10 include CommonApiTemplate
12 after_create :invalidate_permissions_cache
13 after_update :maybe_invalidate_permissions_cache
14 before_create :assign_name
16 api_accessible :user, extend: :common do |t|
23 def maybe_invalidate_permissions_cache
24 if uuid_changed? or owner_uuid_changed?
25 # This can change users' permissions on other groups as well as
27 invalidate_permissions_cache
31 def invalidate_permissions_cache
32 # Ensure a new group can be accessed by the appropriate users
33 # immediately after being created.
34 User.invalidate_permissions_cache db_current_time.to_i
38 if self.new_record? and (self.name.nil? or self.name.empty?)