X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/99887d1312315a5efb4d888251f90880846c073c..cf0171de6e0f875748cc80026c9ea8a11147c750:/services/api/app/models/group.rb diff --git a/services/api/app/models/group.rb b/services/api/app/models/group.rb index 7a7f0a3a60..1f2b0d8b77 100644 --- a/services/api/app/models/group.rb +++ b/services/api/app/models/group.rb @@ -12,8 +12,11 @@ class Group < ArvadosModel include CanBeAnOwner include Trashable - serialize :properties, Hash + # Posgresql JSONB columns should NOT be declared as serialized, Rails 5 + # already know how to properly treat them. + attribute :properties, :jsonbHash, default: {} + validate :ensure_filesystem_compatible_name after_create :invalidate_permissions_cache after_update :maybe_invalidate_permissions_cache before_create :assign_name @@ -29,6 +32,12 @@ class Group < ArvadosModel t.add :properties end + def ensure_filesystem_compatible_name + # project groups need filesystem-compatible names, but others + # don't. + super if group_class == 'project' + end + def maybe_invalidate_permissions_cache if uuid_changed? or owner_uuid_changed? or is_trashed_changed? # This can change users' permissions on other groups as well as @@ -40,7 +49,7 @@ class Group < ArvadosModel def invalidate_permissions_cache # Ensure a new group can be accessed by the appropriate users # immediately after being created. - User.invalidate_permissions_cache db_current_time.to_i + User.invalidate_permissions_cache self.async_permissions_update end def assign_name @@ -49,5 +58,4 @@ class Group < ArvadosModel end true end - end