Method: Organizations::GroupsController#destroy

Defined in:
app/controllers/organizations/groups_controller.rb

#destroyObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'app/controllers/organizations/groups_controller.rb', line 30

def destroy
  if group.self_deletion_scheduled? &&
      ::Gitlab::Utils.to_boolean(params.permit(:permanently_remove)[:permanently_remove])

    if Gitlab::CurrentSettings.allow_immediate_namespaces_deletion_for_user?(current_user)
      return destroy_immediately
    end

    return access_denied!
  end

  result = ::Groups::MarkForDeletionService.new(group, current_user).execute

  if result.success?
    render json: {
      message: format(
        _("'%{group_name}' has been scheduled for deletion and will be deleted on %{date}."),
        group_name: group.name,
        date: helpers.permanent_deletion_date_formatted(group)
      )
    }
  else
    render json: { message: result.message }, status: :unprocessable_entity
  end
end