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 serialize :properties, Hash
17 after_create :invalidate_permissions_cache
18 after_update :maybe_invalidate_permissions_cache
19 before_create :assign_name
21 api_accessible :user, extend: :common do |t|
32 def maybe_invalidate_permissions_cache
33 if uuid_changed? or owner_uuid_changed? or is_trashed_changed?
34 # This can change users' permissions on other groups as well as
36 invalidate_permissions_cache
40 def invalidate_permissions_cache
41 # Ensure a new group can be accessed by the appropriate users
42 # immediately after being created.
43 User.invalidate_permissions_cache db_current_time.to_i
47 if self.new_record? and (self.name.nil? or self.name.empty?)