decorator: Extract OrganizationAdministratorRequired common exception.

This eliminates significant code duplication of error messages for
situations where an organization administrator is required.
This commit is contained in:
Matheus Melo
2019-11-16 11:53:56 -03:00
committed by Tim Abbott
parent 08103544cc
commit 21ed834101
5 changed files with 23 additions and 7 deletions

View File

@@ -190,6 +190,18 @@ class InvalidJSONError(JsonableError):
def msg_format() -> str:
return _("Malformed JSON")
class OrganizationAdministratorRequired(JsonableError):
code = ErrorCode.UNAUTHORIZED_PRINCIPAL # type: ErrorCode
ADMIN_REQUIRED_MESSAGE = _("Must be an organization administrator")
def __init__(self) -> None:
super().__init__(self.ADMIN_REQUIRED_MESSAGE)
@staticmethod
def msg_format() -> str:
return OrganizationAdministratorRequired.ADMIN_REQUIRED_MESSAGE
class BugdownRenderingException(Exception):
pass