models: Extract zerver.models.constants.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2023-12-05 10:32:36 -08:00 committed by Tim Abbott
parent e601d0ae7c
commit 37a9c4501f
8 changed files with 10 additions and 9 deletions

View File

@ -68,7 +68,6 @@ from zerver.lib.users import (
max_message_id_for_user, max_message_id_for_user,
) )
from zerver.models import ( from zerver.models import (
MAX_TOPIC_NAME_LENGTH,
Client, Client,
CustomProfileField, CustomProfileField,
Draft, Draft,
@ -87,6 +86,7 @@ from zerver.models import (
get_realm_playgrounds, get_realm_playgrounds,
linkifiers_for_realm, linkifiers_for_realm,
) )
from zerver.models.constants import MAX_TOPIC_NAME_LENGTH
from zerver.tornado.django_api import get_user_events, request_event_queue from zerver.tornado.django_api import get_user_events, request_event_queue
from zproject.backends import email_auth_enabled, password_auth_enabled from zproject.backends import email_auth_enabled, password_auth_enabled

View File

@ -63,7 +63,6 @@ from zerver.lib.user_groups import is_user_in_group
from zerver.lib.user_topics import build_get_topic_visibility_policy, get_topic_visibility_policy from zerver.lib.user_topics import build_get_topic_visibility_policy, get_topic_visibility_policy
from zerver.lib.users import get_inaccessible_user_ids from zerver.lib.users import get_inaccessible_user_ids
from zerver.models import ( from zerver.models import (
MAX_TOPIC_NAME_LENGTH,
Message, Message,
Reaction, Reaction,
Realm, Realm,
@ -80,6 +79,7 @@ from zerver.models import (
get_usermessage_by_message_id, get_usermessage_by_message_id,
query_for_ids, query_for_ids,
) )
from zerver.models.constants import MAX_TOPIC_NAME_LENGTH
class MessageDetailsDict(TypedDict, total=False): class MessageDetailsDict(TypedDict, total=False):

View File

@ -118,9 +118,7 @@ from zerver.lib.validator import (
check_url, check_url,
validate_select_field, validate_select_field,
) )
from zerver.models.constants import MAX_LANGUAGE_ID_LENGTH, MAX_TOPIC_NAME_LENGTH
MAX_TOPIC_NAME_LENGTH = 60
MAX_LANGUAGE_ID_LENGTH: int = 50
SECONDS_PER_DAY = 86400 SECONDS_PER_DAY = 86400

View File

@ -0,0 +1,2 @@
MAX_TOPIC_NAME_LENGTH = 60
MAX_LANGUAGE_ID_LENGTH: int = 50

View File

@ -31,7 +31,6 @@ from zerver.lib.user_topics import (
) )
from zerver.lib.utils import assert_is_not_none from zerver.lib.utils import assert_is_not_none
from zerver.models import ( from zerver.models import (
MAX_TOPIC_NAME_LENGTH,
Message, Message,
Realm, Realm,
Stream, Stream,
@ -43,6 +42,7 @@ from zerver.models import (
get_realm, get_realm,
get_stream, get_stream,
) )
from zerver.models.constants import MAX_TOPIC_NAME_LENGTH
if TYPE_CHECKING: if TYPE_CHECKING:
from django.test.client import _MonkeyPatchedWSGIResponse as TestHttpResponse from django.test.client import _MonkeyPatchedWSGIResponse as TestHttpResponse

View File

@ -47,7 +47,6 @@ from zerver.lib.test_helpers import (
) )
from zerver.lib.timestamp import datetime_to_timestamp from zerver.lib.timestamp import datetime_to_timestamp
from zerver.models import ( from zerver.models import (
MAX_TOPIC_NAME_LENGTH,
Message, Message,
Realm, Realm,
RealmDomain, RealmDomain,
@ -64,6 +63,7 @@ from zerver.models import (
get_system_bot, get_system_bot,
get_user, get_user,
) )
from zerver.models.constants import MAX_TOPIC_NAME_LENGTH
from zerver.views.message_send import InvalidMirrorInputError from zerver.views.message_send import InvalidMirrorInputError

View File

@ -73,7 +73,6 @@ from zerver.lib.validator import (
) )
from zerver.lib.zephyr import compute_mit_user_fullname from zerver.lib.zephyr import compute_mit_user_fullname
from zerver.models import ( from zerver.models import (
MAX_LANGUAGE_ID_LENGTH,
DisposableEmailError, DisposableEmailError,
DomainNotAllowedForRealmError, DomainNotAllowedForRealmError,
EmailContainsPlusError, EmailContainsPlusError,
@ -91,6 +90,7 @@ from zerver.models import (
get_user_by_delivery_email, get_user_by_delivery_email,
name_changes_disabled, name_changes_disabled,
) )
from zerver.models.constants import MAX_LANGUAGE_ID_LENGTH
from zerver.views.auth import ( from zerver.views.auth import (
create_preregistration_realm, create_preregistration_realm,
create_preregistration_user, create_preregistration_user,

View File

@ -6,7 +6,8 @@ from zerver.lib.response import json_success
from zerver.lib.typed_endpoint import JsonBodyPayload, typed_endpoint from zerver.lib.typed_endpoint import JsonBodyPayload, typed_endpoint
from zerver.lib.validator import WildValue, check_string from zerver.lib.validator import WildValue, check_string
from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.models import MAX_TOPIC_NAME_LENGTH, UserProfile from zerver.models import UserProfile
from zerver.models.constants import MAX_TOPIC_NAME_LENGTH
MESSAGE_TEMPLATE = """ MESSAGE_TEMPLATE = """
Splunk alert from saved search: Splunk alert from saved search: