Class: Gitlab::GitAccessWiki

Inherits:
GitAccess show all
Extended by:
Utils::Override
Defined in:
lib/gitlab/git_access_wiki.rb

Constant Summary collapse

ERROR_MESSAGES =
{
  download: 'You are not allowed to download files from this wiki.',
  not_found: 'The wiki you were looking for could not be found.',
  no_repo: 'A repository for this wiki does not exist yet.',
  read_only: "You can't push code to a read-only GitLab instance.",
  write_to_wiki: "You are not allowed to write to this project's wiki."
}.freeze

Constants inherited from GitAccess

Gitlab::GitAccess::ALL_COMMANDS, Gitlab::GitAccess::ANY, Gitlab::GitAccess::DOWNLOAD_COMMANDS, Gitlab::GitAccess::ForbiddenError, Gitlab::GitAccess::INTERNAL_TIMEOUT, Gitlab::GitAccess::LOG_HEADER, Gitlab::GitAccess::NotFoundError, Gitlab::GitAccess::PUSH_COMMANDS, Gitlab::GitAccess::ProjectMovedError, Gitlab::GitAccess::TimeoutError

Instance Attribute Summary

Attributes inherited from GitAccess

#actor, #auth_result_type, #authentication_abilities, #changes, #cmd, #container, #namespace_path, #protocol, #redirected_path

Instance Method Summary collapse

Methods included from Utils::Override

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

Methods inherited from GitAccess

#build_can_download_code?, #check, #deploy_key_can_download_code?, #guest_can_download_code?, #initialize, #logger, #protocol_allowed?, #repository_path, #request_from_ci_build?, #user_can_download_code?

Methods included from Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

This class inherits a constructor from Gitlab::GitAccess

Instance Method Details

#check_change_access!Object

Raises:


26
27
28
29
30
# File 'lib/gitlab/git_access_wiki.rb', line 26

def check_change_access!
  raise ForbiddenError, write_to_wiki_message unless user_can_push?

  true
end

#download_abilityObject


16
17
18
# File 'lib/gitlab/git_access_wiki.rb', line 16

def download_ability
  :download_wiki_code
end

#not_found_messageObject


40
41
42
# File 'lib/gitlab/git_access_wiki.rb', line 40

def not_found_message
  error_message(:not_found)
end

#push_abilityObject


21
22
23
# File 'lib/gitlab/git_access_wiki.rb', line 21

def push_ability
  :create_wiki
end

#push_to_read_only_messageObject


32
33
34
# File 'lib/gitlab/git_access_wiki.rb', line 32

def push_to_read_only_message
  error_message(:read_only)
end

#repositoryObject


45
46
47
# File 'lib/gitlab/git_access_wiki.rb', line 45

def repository
  container.wiki.repository
end

#write_to_wiki_messageObject


36
37
38
# File 'lib/gitlab/git_access_wiki.rb', line 36

def write_to_wiki_message
  error_message(:write_to_wiki)
end