Class: GroupMember

Inherits:
Member show all
Includes:
CreatedAtFilterable, FromUnion
Defined in:
app/models/members/group_member.rb

Constant Summary collapse

SOURCE_TYPE =
'Namespace'
SOURCE_TYPE_FORMAT =
/\ANamespace\z/

Constants inherited from Member

Member::ACCESS_REQUEST_APPROVERS_TO_BE_NOTIFIED_LIMIT, Member::AVATAR_SIZE, Member::STATE_ACTIVE, Member::STATE_AWAITING

Constants included from UpdateHighestRole

UpdateHighestRole::HIGHEST_ROLE_JOB_DELAY, UpdateHighestRole::HIGHEST_ROLE_LEASE_TIMEOUT

Constants included from Gitlab::Access

Gitlab::Access::ADMIN, Gitlab::Access::AccessDeniedError, Gitlab::Access::DEVELOPER, Gitlab::Access::DEVELOPER_MAINTAINER_PROJECT_ACCESS, Gitlab::Access::GUEST, Gitlab::Access::MAINTAINER, Gitlab::Access::MAINTAINER_PROJECT_ACCESS, Gitlab::Access::MAINTAINER_SUBGROUP_ACCESS, Gitlab::Access::MINIMAL_ACCESS, Gitlab::Access::NO_ACCESS, Gitlab::Access::NO_ONE_PROJECT_ACCESS, Gitlab::Access::OWNER, Gitlab::Access::OWNER_SUBGROUP_ACCESS, Gitlab::Access::PROTECTION_DEV_CAN_INITIAL_PUSH, Gitlab::Access::PROTECTION_DEV_CAN_MERGE, Gitlab::Access::PROTECTION_DEV_CAN_PUSH, Gitlab::Access::PROTECTION_FULL, Gitlab::Access::PROTECTION_NONE, Gitlab::Access::REPORTER

Constants included from Expirable

Expirable::DAYS_TO_EXPIRE

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Constants included from ResetOnUnionError

ResetOnUnionError::MAX_RESET_PERIOD

Instance Attribute Summary collapse

Attributes inherited from Member

#raw_invite_token

Attributes included from Importable

#imported, #importing

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Member

#accept_invite!, #accept_request, #access_field, access_for_user_ids, #create_notification_setting, #created_by_name, #decline_invite!, #destroy_notification_setting, filter_by_2fa, filter_by_user_type, find_by_invite_token, #generate_invite_token, #generate_invite_token!, #highest_group_member, #hook_prerequisites_met?, #invite?, #invite_to_unknown_user?, left_join_users, #notifiable?, #notification_setting, #pending?, pluck_user_ids, #request?, #resend_invite, search, search_invite_email, #send_invitation_reminder, sort_by_attribute, valid_email?

Methods included from Gitlab::Utils::Override

#extended, extensions, #included, #method_added, #override, #prepended, #queue_verification, verify!

Methods included from Presentable

#present

Methods included from Gitlab::Access

all_values, human_access, #human_access, #human_access_with_none, human_access_with_none, options, options_with_none, options_with_owner, #owner?, project_creation_level_name, project_creation_options, project_creation_string_options, project_creation_string_values, project_creation_values, protection_options, protection_values, subgroup_creation_options, subgroup_creation_string_options, subgroup_creation_string_values, subgroup_creation_values, sym_options, sym_options_with_owner

Methods included from Expirable

#expired?, #expires?, #expires_soon?

Methods included from AfterCommitQueue

#run_after_commit, #run_after_commit_or_now

Methods inherited from ApplicationRecord

cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order

Methods included from SensitiveSerializableHash

#serializable_hash

Instance Attribute Details

#last_ownerObject

Returns the value of attribute last_owner.



26
27
28
# File 'app/models/members/group_member.rb', line 26

def last_owner
  @last_owner
end

Class Method Details

.access_level_rolesObject



44
45
46
# File 'app/models/members/group_member.rb', line 44

def self.access_level_roles
  Gitlab::Access.options_with_owner
end

.permissible_access_level_roles(_, _) ⇒ Object

For those who get to see a modal with a role dropdown, here are the options presented



39
40
41
42
# File 'app/models/members/group_member.rb', line 39

def self.permissible_access_level_roles(_, _)
  # This method is a stopgap in preparation for https://gitlab.com/gitlab-org/gitlab/-/issues/364087
  access_level_roles
end

Instance Method Details

#groupObject



48
49
50
# File 'app/models/members/group_member.rb', line 48

def group
  source
end

#last_owner_of_the_group?Boolean

Returns:

  • (Boolean)


61
62
63
64
65
66
67
68
# File 'app/models/members/group_member.rb', line 61

def last_owner_of_the_group?
  return false unless access_level == Gitlab::Access::OWNER
  return last_owner unless last_owner.nil?

  group.member_owners_excluding_project_bots.where.not(
    group: group, user_id: user_id
  ).empty?
end

#notifiable_optionsObject



57
58
59
# File 'app/models/members/group_member.rb', line 57

def notifiable_options
  { group: group }
end

#real_source_typeObject

Because source_type is ‘Namespace`…



53
54
55
# File 'app/models/members/group_member.rb', line 53

def real_source_type
  Group.sti_name
end

#update_two_factor_requirementObject



28
29
30
31
32
33
34
35
36
# File 'app/models/members/group_member.rb', line 28

def update_two_factor_requirement
  return unless user

  Gitlab::Database::QueryAnalyzers::PreventCrossDatabaseModification.temporary_ignore_tables_in_transaction(
    %w[users user_details user_preferences], url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/424288'
  ) do
    user.update_two_factor_requirement
  end
end