Class: Labimotion::GenericKlassEntity

Inherits:
ApplicationEntity
  • Object
show all
Defined in:
lib/labimotion/entities/generic_klass_entity.rb

Instance Method Summary collapse

Instance Method Details

#current_user_permissionObject

The level label, or nil when the user has no row at all. Note the fourth answer: 'requested' — a level-0 row is a standing access request, not access, so a client must compare the level rather than test this string for truthiness.



75
76
77
78
# File 'lib/labimotion/entities/generic_klass_entity.rb', line 75

def current_user_permission
  level = share_context[:levels][Labimotion::KlassShare.key_of(object)]
  level && Labimotion::KlassShare::LEVELS.key(level)&.to_s
end

#ownerObject

state is what the grid badges on: a template whose owner left the institute has nobody to ask, which is the case ownership transfer exists to resolve.

With a share context the owner is the permission_level=30 share row — the transferable right — and created_by stays exposed above as immutable provenance; the two diverge permanently after the first transfer. Without a context (host not migrated, or an endpoint that predates shares) the Phase 0 behaviour stands: created_by is the owner.



66
67
68
69
70
# File 'lib/labimotion/entities/generic_klass_entity.rb', line 66

def owner
  return owner_from_share if share_context

  owner_from_created_by
end