From 4621ca76fcde02d8b1e9d0a7b816492ec7f55a53 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Fri, 15 Dec 2023 11:51:58 -0800 Subject: [PATCH] models: Extract zerver.models.onboarding_steps. Signed-off-by: Anders Kaseorg --- zerver/models/__init__.py | 11 +---------- zerver/models/onboarding_steps.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 10 deletions(-) create mode 100644 zerver/models/onboarding_steps.py diff --git a/zerver/models/__init__.py b/zerver/models/__init__.py index a1f463067a..41d198ee4f 100644 --- a/zerver/models/__init__.py +++ b/zerver/models/__init__.py @@ -7,7 +7,6 @@ from django.db.backends.base.base import BaseDatabaseWrapper from django.db.models import CASCADE, QuerySet from django.db.models.signals import post_delete, post_save from django.db.models.sql.compiler import SQLCompiler -from django.utils.timezone import now as timezone_now from django.utils.translation import gettext as _ from django.utils.translation import gettext_lazy from django_stubs_ext import StrPromise, ValuesQuerySet @@ -61,6 +60,7 @@ from zerver.models.messages import Reaction as Reaction from zerver.models.messages import SubMessage as SubMessage from zerver.models.messages import UserMessage as UserMessage from zerver.models.muted_users import MutedUser as MutedUser +from zerver.models.onboarding_steps import OnboardingStep as OnboardingStep from zerver.models.prereg_users import EmailChangeStatus as EmailChangeStatus from zerver.models.prereg_users import MultiuseInvite as MultiuseInvite from zerver.models.prereg_users import PreregistrationRealm as PreregistrationRealm @@ -152,15 +152,6 @@ def query_for_ids( return query -class OnboardingStep(models.Model): - user = models.ForeignKey(UserProfile, on_delete=CASCADE) - onboarding_step = models.CharField(max_length=30) - timestamp = models.DateTimeField(default=timezone_now) - - class Meta: - unique_together = ("user", "onboarding_step") - - def check_valid_user_ids(realm_id: int, val: object, allow_deactivated: bool = False) -> List[int]: user_ids = check_list(check_int)("User IDs", val) realm = Realm.objects.get(id=realm_id) diff --git a/zerver/models/onboarding_steps.py b/zerver/models/onboarding_steps.py new file mode 100644 index 0000000000..565fb13572 --- /dev/null +++ b/zerver/models/onboarding_steps.py @@ -0,0 +1,14 @@ +from django.db import models +from django.db.models import CASCADE +from django.utils.timezone import now as timezone_now + +from zerver.models.users import UserProfile + + +class OnboardingStep(models.Model): + user = models.ForeignKey(UserProfile, on_delete=CASCADE) + onboarding_step = models.CharField(max_length=30) + timestamp = models.DateTimeField(default=timezone_now) + + class Meta: + unique_together = ("user", "onboarding_step")