mirror of https://github.com/zulip/zulip.git
Rename do_[rd]activate to do_[rd]activate_user.
For similarity with do_activate_user. (imported from commit 2874af84dbe1ce666de10e0d8ffe2daa8bad9731)
This commit is contained in:
parent
6497f330ea
commit
f3fa78d30c
|
@ -135,7 +135,7 @@ def delete_all_user_sessions():
|
|||
for session in Session.objects.all():
|
||||
delete_session(session)
|
||||
|
||||
def do_deactivate(user_profile, log=True, _cascade=True):
|
||||
def do_deactivate_user(user_profile, log=True, _cascade=True):
|
||||
if not user_profile.is_active:
|
||||
return
|
||||
|
||||
|
@ -160,7 +160,7 @@ def do_deactivate(user_profile, log=True, _cascade=True):
|
|||
bot_profiles = UserProfile.objects.filter(is_bot=True, is_active=True,
|
||||
bot_owner=user_profile)
|
||||
for profile in bot_profiles:
|
||||
do_deactivate(profile, _cascade=False)
|
||||
do_deactivate_user(profile, _cascade=False)
|
||||
|
||||
def do_change_user_email(user_profile, new_email):
|
||||
old_email = user_profile.email
|
||||
|
@ -1055,7 +1055,7 @@ def do_activate_user(user_profile, log=True, join_date=timezone.now()):
|
|||
|
||||
notify_created_user(user_profile)
|
||||
|
||||
def do_reactivate(user_profile):
|
||||
def do_reactivate_user(user_profile):
|
||||
# Unlike do_activate_user, this is meant for re-activating existing users,
|
||||
# so it doesn't reset their password, etc.
|
||||
user_profile.is_active = True
|
||||
|
|
|
@ -4,7 +4,7 @@ from optparse import make_option
|
|||
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from zerver.lib.actions import do_deactivate, user_sessions
|
||||
from zerver.lib.actions import do_deactivate_user, user_sessions
|
||||
from zerver.models import get_user_profile_by_email, UserProfile
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
@ -43,5 +43,5 @@ class Command(BaseCommand):
|
|||
print "This was a dry run. Pass -f to actually deactivate."
|
||||
exit(1)
|
||||
|
||||
do_deactivate(user_profile)
|
||||
do_deactivate_user(user_profile)
|
||||
print "Sessions deleted, user deactivated."
|
||||
|
|
|
@ -20,7 +20,7 @@ from zerver.lib.actions import check_send_message, gather_subscriptions, \
|
|||
create_stream_if_needed, do_add_subscription, compute_mit_user_fullname, \
|
||||
do_add_realm_emoji, do_remove_realm_emoji, check_message, do_create_user, \
|
||||
set_default_streams, get_emails_from_user_ids, \
|
||||
do_deactivate, do_reactivate
|
||||
do_deactivate_user, do_reactivate_user
|
||||
from zerver.lib.rate_limiter import add_ratelimit_rule, remove_ratelimit_rule
|
||||
from zerver.lib import bugdown
|
||||
from zerver.lib import cache
|
||||
|
@ -841,9 +841,9 @@ class UserChangesTest(AuthedTestCase):
|
|||
class ActivateTest(AuthedTestCase):
|
||||
def test_basics(self):
|
||||
user = get_user_profile_by_email('hamlet@zulip.com')
|
||||
do_deactivate(user)
|
||||
do_deactivate_user(user)
|
||||
self.assertFalse(user.is_active)
|
||||
do_reactivate(user)
|
||||
do_reactivate_user(user)
|
||||
self.assertTrue(user.is_active)
|
||||
|
||||
def test_api(self):
|
||||
|
|
|
@ -35,7 +35,7 @@ from zerver.lib.actions import bulk_remove_subscriptions, \
|
|||
recipient_for_emails, extract_recipients, do_events_register, \
|
||||
get_status_dict, do_change_enable_offline_email_notifications, \
|
||||
do_update_message, internal_prep_message, \
|
||||
do_send_messages, get_default_subs, do_deactivate, do_reactivate, \
|
||||
do_send_messages, get_default_subs, do_deactivate_user, do_reactivate_user, \
|
||||
user_email_is_unique, do_invite_users, do_refer_friend, compute_mit_user_fullname, \
|
||||
do_add_alert_words, do_remove_alert_words, do_set_alert_words, get_subscriber_emails, \
|
||||
do_set_muted_topics, do_rename_stream, \
|
||||
|
@ -2028,7 +2028,7 @@ def deactivate_user_backend(request, user_profile, email):
|
|||
if not user_profile.can_admin_user(target):
|
||||
return json_error('Insufficient permission')
|
||||
|
||||
do_deactivate(target)
|
||||
do_deactivate_user(target)
|
||||
return json_success({})
|
||||
|
||||
def reactivate_user_backend(request, user_profile, email):
|
||||
|
@ -2040,7 +2040,7 @@ def reactivate_user_backend(request, user_profile, email):
|
|||
if not user_profile.can_admin_user(target):
|
||||
return json_error('Insufficient permission')
|
||||
|
||||
do_reactivate(target)
|
||||
do_reactivate_user(target)
|
||||
return json_success({})
|
||||
|
||||
def avatar(request, email):
|
||||
|
|
|
@ -9,7 +9,7 @@ from zerver.models import Message, UserProfile, Stream, Recipient, Client, \
|
|||
get_huddle_hash, clear_database, get_client, get_user_profile_by_id, \
|
||||
email_to_domain, email_to_username
|
||||
from zerver.lib.actions import do_send_message, set_default_streams, \
|
||||
do_activate_user, do_deactivate, do_change_password
|
||||
do_activate_user, do_deactivate_user, do_change_password
|
||||
from zerver.lib.parallel import run_parallel
|
||||
from django.db.models import Count
|
||||
from django.conf import settings
|
||||
|
@ -560,7 +560,7 @@ def restore_saved_messages():
|
|||
continue
|
||||
elif message_type == "user_deactivated":
|
||||
user_profile = users[old_message["user"]]
|
||||
do_deactivate(user_profile, log=False)
|
||||
do_deactivate_user(user_profile, log=False)
|
||||
continue
|
||||
elif message_type == "user_change_password":
|
||||
# Just handle these the slow way
|
||||
|
|
Loading…
Reference in New Issue