Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

exceptions: Move InvitationError to zerver/lib/exceptions.

Vishnu KS8c055107d903
diff --git a/analytics/tests/test_counts.py b/analytics/tests/test_counts.py
index cb498c2720b..c265c38fb95 100644
--- a/analytics/tests/test_counts.py
+++ b/analytics/tests/test_counts.py
@@ -33,7 +33,6 @@ from analytics.models import (
installation_epoch,
)
from zerver.lib.actions import (
- InvitationError,
do_activate_user,
do_create_realm,
do_create_user,
@@ -48,6 +47,7 @@ from zerver.lib.actions import (
update_user_activity_interval,
)
from zerver.lib.create_user import create_user
+from zerver.lib.exceptions import InvitationError
from zerver.lib.test_classes import ZulipTestCase
from zerver.lib.timestamp import TimezoneNotUTCException, floor_to_day
from zerver.lib.topic import DB_TOPIC_NAME
diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py
index f99158aa2c0..891394bb6b6 100644
--- a/zerver/lib/actions.py
+++ b/zerver/lib/actions.py
@@ -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.exceptions import (
- ErrorCode,
+ InvitationError,
JsonableError,
MarkdownRenderingException,
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:
"""An upper bound on the number of invites sent in the last `days` days"""
recent_invites = RealmCount.objects.filter(
diff --git a/zerver/lib/exceptions.py b/zerver/lib/exceptions.py
index 5a50c9f7426..2aa090442da 100644
--- a/zerver/lib/exceptions.py
+++ b/zerver/lib/exceptions.py
@@ -1,5 +1,5 @@
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 _
@@ -358,3 +358,15 @@ class InvalidSubdomainError(JsonableError):
class ZephyrMessageAlreadySentException(Exception):
def __init__(self, message_id: int) -> None:
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