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 # Posgresql JSONB columns should NOT be declared as serialized, Rails 5
16 # already know how to properly treat them.
17 attribute :properties, :jsonbHash, default: {}
19 after_create :invalidate_permissions_cache
20 after_update :maybe_invalidate_permissions_cache
21 before_create :assign_name
23 api_accessible :user, extend: :common do |t|
34 def maybe_invalidate_permissions_cache
35 if uuid_changed? or owner_uuid_changed? or is_trashed_changed?
36 # This can change users' permissions on other groups as well as
38 invalidate_permissions_cache
42 def invalidate_permissions_cache
43 # Ensure a new group can be accessed by the appropriate users
44 # immediately after being created.
45 User.invalidate_permissions_cache self.async_permissions_update
49 if self.new_record? and (self.name.nil? or self.name.empty?)