mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 00:46:03 +00:00
Access the UserProfile's new is_active field rather than User's.
(imported from commit ed5bdaf3e3d6d20bfb741efdac48d30482ab9ef7)
This commit is contained in:
@@ -17,7 +17,7 @@ def is_unique(value):
|
||||
|
||||
def is_inactive(value):
|
||||
try:
|
||||
if get_user_profile_by_email(value).user.is_active:
|
||||
if get_user_profile_by_email(value).is_active:
|
||||
raise ValidationError(u'%s is already active' % value)
|
||||
except UserProfile.DoesNotExist:
|
||||
pass
|
||||
|
||||
@@ -68,7 +68,7 @@ def do_create_user(email, password, realm, full_name, short_name,
|
||||
full_name=user_profile.full_name)),
|
||||
users=[up.id for up in
|
||||
UserProfile.objects.select_related().filter(realm=user_profile.realm,
|
||||
user__is_active=True)])
|
||||
is_active=True)])
|
||||
tornado_callbacks.send_notification(notice)
|
||||
return user_profile
|
||||
|
||||
@@ -115,7 +115,7 @@ def do_deactivate(user_profile):
|
||||
full_name=user_profile.full_name)),
|
||||
users=[up.id for up in
|
||||
UserProfile.objects.select_related().filter(realm=user_profile.realm,
|
||||
user__is_active=True)])
|
||||
is_active=True)])
|
||||
tornado_callbacks.send_notification(notice)
|
||||
|
||||
|
||||
@@ -203,7 +203,7 @@ def do_send_message(message, rendered_content=None, no_log=False,
|
||||
message.save()
|
||||
ums_to_create = [UserMessage(user_profile=user_profile, message=message)
|
||||
for user_profile in recipients
|
||||
if user_profile.user.is_active]
|
||||
if user_profile.is_active]
|
||||
for um in ums_to_create:
|
||||
sent_by_human = message.sending_client.name.lower() in \
|
||||
['website', 'iphone', 'android']
|
||||
@@ -784,7 +784,7 @@ def do_events_register(user_profile, apply_markdown=True, event_types=None):
|
||||
'full_name' : profile.full_name}
|
||||
for profile in
|
||||
UserProfile.objects.select_related().filter(realm=user_profile.realm,
|
||||
user__is_active=True)]
|
||||
is_active=True)]
|
||||
if event_types is None or "subscription" in event_types:
|
||||
ret['subscriptions'] = gather_subscriptions(user_profile)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ from zephyr.models import Realm, UserProfile
|
||||
# Helper to be used with manage.py shell to get rid of bad users on prod.
|
||||
def banish_busted_users(change=False):
|
||||
for u in UserProfile.objects.select_related().all():
|
||||
if (u.user.is_active or u.realm.domain != "mit.edu"):
|
||||
if (u.is_active or u.realm.domain != "mit.edu"):
|
||||
continue
|
||||
(banished_realm, _) = Realm.objects.get_or_create(domain="mit.deleted")
|
||||
if "|mit.edu@mit.edu" in u.email.lower():
|
||||
|
||||
@@ -582,7 +582,7 @@ def restore_saved_messages():
|
||||
recipient_user_ids.add(message.sender_id)
|
||||
|
||||
for user_profile_id in recipient_user_ids:
|
||||
if users_by_id[user_profile_id].user.is_active:
|
||||
if users_by_id[user_profile_id].is_active:
|
||||
um = UserMessage(user_profile_id=user_profile_id,
|
||||
message=message)
|
||||
user_messages_to_create.append(um)
|
||||
|
||||
@@ -7,7 +7,7 @@ from zephyr.lib.actions import compute_mit_user_fullname
|
||||
# Helper to be used with manage.py shell to fix bad names on prod.
|
||||
def update_mit_fullnames(change=False):
|
||||
for u in UserProfile.objects.select_related().all():
|
||||
if (u.user.is_active or u.realm.domain != "mit.edu"):
|
||||
if (u.is_active or u.realm.domain != "mit.edu"):
|
||||
# Don't change fullnames for non-MIT users or users who
|
||||
# actually have an account (is_active) and thus have
|
||||
# presumably set their fullname how they like it.
|
||||
|
||||
@@ -24,7 +24,7 @@ class Command(BaseCommand):
|
||||
|
||||
for realm in realms:
|
||||
print realm.domain
|
||||
user_profiles = UserProfile.objects.filter(realm=realm, user__is_active=True)
|
||||
user_profiles = UserProfile.objects.filter(realm=realm, is_active=True)
|
||||
print "%d users" % (len(user_profiles),)
|
||||
print "%d streams" % (len(Stream.objects.filter(realm=realm)),)
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ def send_signup_message(sender, signups_stream, user_profile, internal=False):
|
||||
user_profile.email,
|
||||
internal_blurb,
|
||||
UserProfile.objects.filter(realm=user_profile.realm,
|
||||
user__is_active=True).count(),
|
||||
is_active=True).count(),
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user