exceptions: Move InvitationError to zerver/lib/exceptions.

This commit is contained in:
Vishnu KS 2021-06-07 21:41:26 +05:30 committed by Tim Abbott
parent 7197c8ae89
commit 8c055107d9
3 changed files with 15 additions and 15 deletions

View File

@ -33,7 +33,6 @@ from analytics.models import (
installation_epoch, installation_epoch,
) )
from zerver.lib.actions import ( from zerver.lib.actions import (
InvitationError,
do_activate_user, do_activate_user,
do_create_realm, do_create_realm,
do_create_user, do_create_user,
@ -48,6 +47,7 @@ from zerver.lib.actions import (
update_user_activity_interval, update_user_activity_interval,
) )
from zerver.lib.create_user import create_user from zerver.lib.create_user import create_user
from zerver.lib.exceptions import InvitationError
from zerver.lib.test_classes import ZulipTestCase from zerver.lib.test_classes import ZulipTestCase
from zerver.lib.timestamp import TimezoneNotUTCException, floor_to_day from zerver.lib.timestamp import TimezoneNotUTCException, floor_to_day
from zerver.lib.topic import DB_TOPIC_NAME from zerver.lib.topic import DB_TOPIC_NAME

View File

@ -85,7 +85,7 @@ from zerver.lib.email_validation import (
) )
from zerver.lib.emoji import check_emoji_request, emoji_name_to_emoji_code, get_emoji_file_name from zerver.lib.emoji import check_emoji_request, emoji_name_to_emoji_code, get_emoji_file_name
from zerver.lib.exceptions import ( from zerver.lib.exceptions import (
ErrorCode, InvitationError,
JsonableError, JsonableError,
MarkdownRenderingException, MarkdownRenderingException,
StreamDoesNotExistError, StreamDoesNotExistError,
@ -6581,18 +6581,6 @@ def email_not_system_bot(email: str) -> None:
) )
class InvitationError(JsonableError):
code = ErrorCode.INVITATION_FAILED
data_fields = ["errors", "sent_invitations"]
def __init__(
self, msg: str, errors: List[Tuple[str, str, bool]], sent_invitations: bool
) -> None:
self._msg: str = msg
self.errors: List[Tuple[str, str, bool]] = errors
self.sent_invitations: bool = sent_invitations
def estimate_recent_invites(realms: Collection[Realm], *, days: int) -> int: def estimate_recent_invites(realms: Collection[Realm], *, days: int) -> int:
"""An upper bound on the number of invites sent in the last `days` days""" """An upper bound on the number of invites sent in the last `days` days"""
recent_invites = RealmCount.objects.filter( recent_invites = RealmCount.objects.filter(

View File

@ -1,5 +1,5 @@
from enum import Enum from enum import Enum
from typing import Any, Dict, List, NoReturn, Optional, Type, TypeVar from typing import Any, Dict, List, NoReturn, Optional, Tuple, Type, TypeVar
from django.utils.translation import gettext as _ from django.utils.translation import gettext as _
@ -358,3 +358,15 @@ class InvalidSubdomainError(JsonableError):
class ZephyrMessageAlreadySentException(Exception): class ZephyrMessageAlreadySentException(Exception):
def __init__(self, message_id: int) -> None: def __init__(self, message_id: int) -> None:
self.message_id = message_id self.message_id = message_id
class InvitationError(JsonableError):
code = ErrorCode.INVITATION_FAILED
data_fields = ["errors", "sent_invitations"]
def __init__(
self, msg: str, errors: List[Tuple[str, str, bool]], sent_invitations: bool
) -> None:
self._msg: str = msg
self.errors: List[Tuple[str, str, bool]] = errors
self.sent_invitations: bool = sent_invitations