actions: Move part into zerver.lib.users.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit ab04068294)
This commit is contained in:
Anders Kaseorg
2022-04-14 14:43:58 -07:00
committed by Tim Abbott
parent b8567d8d8f
commit b60ba10351
4 changed files with 9 additions and 6 deletions

View File

@@ -187,6 +187,7 @@ from zerver.lib.users import (
check_bot_name_available,
check_full_name,
format_user_row,
get_active_bots_owned_by_user,
get_api_key,
user_profile_to_user_row,
)
@@ -1239,10 +1240,6 @@ def change_user_is_active(user_profile: UserProfile, value: bool) -> None:
Subscription.objects.filter(user_profile=user_profile).update(is_user_active=value)
def get_active_bots_owned_by_user(user_profile: UserProfile) -> QuerySet:
return UserProfile.objects.filter(is_bot=True, is_active=True, bot_owner=user_profile)
def do_deactivate_user(
user_profile: UserProfile, _cascade: bool = True, *, acting_user: Optional[UserProfile]
) -> None:

View File

@@ -611,3 +611,7 @@ def get_raw_user_data(
custom_profile_field_data=custom_profile_field_data,
)
return result
def get_active_bots_owned_by_user(user_profile: UserProfile) -> QuerySet:
return UserProfile.objects.filter(is_bot=True, is_active=True, bot_owner=user_profile)

View File

@@ -3,9 +3,10 @@ from typing import Any
from django.core.management.base import CommandError
from zerver.lib.actions import do_deactivate_user, get_active_bots_owned_by_user
from zerver.lib.actions import do_deactivate_user
from zerver.lib.management import ZulipBaseCommand
from zerver.lib.sessions import user_sessions
from zerver.lib.users import get_active_bots_owned_by_user
class Command(ZulipBaseCommand):

View File

@@ -3,8 +3,9 @@ from typing import Any
from django.core.management.base import CommandError
from zerver.lib.actions import do_delete_user, get_active_bots_owned_by_user
from zerver.lib.actions import do_delete_user
from zerver.lib.management import ZulipBaseCommand
from zerver.lib.users import get_active_bots_owned_by_user
class Command(ZulipBaseCommand):