Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

database: Remove short_name from UserProfile.

Steve Howellc44500175d81
diff --git a/analytics/management/commands/populate_analytics_db.py b/analytics/management/commands/populate_analytics_db.py
index dfc9afbd6bb..4c9e83570b3 100644
--- a/analytics/management/commands/populate_analytics_db.py
+++ b/analytics/management/commands/populate_analytics_db.py
@@ -61,9 +61,13 @@ class Command(BaseCommand):
realm = Realm.objects.create(
string_id='analytics', name='Analytics', date_created=installation_time)
with mock.patch("zerver.lib.create_user.timezone_now", return_value=installation_time):
- shylock = create_user('[email protected]', 'Shylock', realm,
- full_name='Shylock', short_name='shylock',
- role=UserProfile.ROLE_REALM_ADMINISTRATOR)
+ shylock = create_user(
+ 'Shylock',
+ realm,
+ full_name='Shylock',
+ role=UserProfile.ROLE_REALM_ADMINISTRATOR
+ )
do_change_user_role(shylock, UserProfile.ROLE_REALM_ADMINISTRATOR, acting_user=None)
stream = Stream.objects.create(
name='all', realm=realm, date_created=installation_time)
diff --git a/analytics/tests/test_counts.py b/analytics/tests/test_counts.py
index 6822ef2da16..f911891d06e 100644
--- a/analytics/tests/test_counts.py
+++ b/analytics/tests/test_counts.py
@@ -89,7 +89,6 @@ class AnalyticsTestCase(ZulipTestCase):
'email': f'user{self.name_counter}@domain.tld',
'date_joined': self.TIME_LAST_HOUR,
'full_name': 'full_name',
- 'short_name': 'short_name',
'is_active': True,
'is_bot': False,
'realm': self.default_realm}
@@ -101,10 +100,15 @@ class AnalyticsTestCase(ZulipTestCase):
if kwargs['is_bot']:
pass_kwargs['bot_type'] = UserProfile.DEFAULT_BOT
pass_kwargs['bot_owner'] = None
- return create_user(kwargs['email'], 'password', kwargs['realm'],
- active=kwargs['is_active'],
- full_name=kwargs['full_name'], short_name=kwargs['short_name'],
- role=UserProfile.ROLE_REALM_ADMINISTRATOR, **pass_kwargs)
+ return create_user(
+ kwargs['email'],
+ 'password',
+ kwargs['realm'],
+ active=kwargs['is_active'],
+ full_name=kwargs['full_name'],
+ role=UserProfile.ROLE_REALM_ADMINISTRATOR,
+ **pass_kwargs
+ )
def create_stream_with_recipient(self, **kwargs: Any) -> Tuple[Stream, Recipient]:
self.name_counter += 1
@@ -1099,7 +1103,7 @@ class TestLoggingCountStats(AnalyticsTestCase):
def test_active_users_log_by_is_bot(self) -> None:
property = 'active_users_log:is_bot:day'
- user = do_create_user('email', 'password', self.default_realm, 'full_name', 'short_name')
+ user = do_create_user('email', 'password', self.default_realm, 'full_name')
self.assertEqual(1, RealmCount.objects.filter(property=property, subgroup=False)
.aggregate(Sum('value'))['value__sum'])
do_deactivate_user(user)
@@ -1363,10 +1367,10 @@ class TestActiveUsersAudit(AnalyticsTestCase):
[[user1, 'false'], [user2, 'false']])
def test_end_to_end_with_actions_dot_py(self) -> None:
- user1 = do_create_user('email1', 'password', self.default_realm, 'full_name', 'short_name')
- user2 = do_create_user('email2', 'password', self.default_realm, 'full_name', 'short_name')
- user3 = do_create_user('email3', 'password', self.default_realm, 'full_name', 'short_name')
- user4 = do_create_user('email4', 'password', self.default_realm, 'full_name', 'short_name')
+ user1 = do_create_user('email1', 'password', self.default_realm, 'full_name')
+ user2 = do_create_user('email2', 'password', self.default_realm, 'full_name')
+ user3 = do_create_user('email3', 'password', self.default_realm, 'full_name')
+ user4 = do_create_user('email4', 'password', self.default_realm, 'full_name')
do_deactivate_user(user2)
do_activate_user(user3)
do_reactivate_user(user4)
@@ -1458,9 +1462,9 @@ class TestRealmActiveHumans(AnalyticsTestCase):
[2, second_realm, self.TIME_ZERO - self.DAY]])
def test_end_to_end(self) -> None:
- user1 = do_create_user('email1', 'password', self.default_realm, 'full_name', 'short_name')
- user2 = do_create_user('email2', 'password', self.default_realm, 'full_name', 'short_name')
- do_create_user('email3', 'password', self.default_realm, 'full_name', 'short_name')
+ user1 = do_create_user('email1', 'password', self.default_realm, 'full_name')
+ user2 = do_create_user('email2', 'password', self.default_realm, 'full_name')
+ do_create_user('email3', 'password', self.default_realm, 'full_name')
time_zero = floor_to_day(timezone_now()) + self.DAY
update_user_activity_interval(user1, time_zero)
update_user_activity_interval(user2, time_zero)
diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.py
index 107a07d453e..9d00f36870a 100644
--- a/corporate/tests/test_stripe.py
+++ b/corporate/tests/test_stripe.py
@@ -2084,7 +2084,7 @@ class LicenseLedgerTest(StripeTestCase):
def test_user_changes(self) -> None:
self.local_upgrade(self.seat_count, True, CustomerPlan.ANNUAL, 'token')
- user = do_create_user('email', 'password', get_realm('zulip'), 'name', 'name')
+ user = do_create_user('email', 'password', get_realm('zulip'), 'name')
do_deactivate_user(user)
do_reactivate_user(user)
# Not a proper use of do_activate_user, but fine for this test
diff --git a/tools/generate-integration-docs-screenshot b/tools/generate-integration-docs-screenshot
index 7c06334d65f..1c3e5d12e82 100755
--- a/tools/generate-integration-docs-screenshot
+++ b/tools/generate-integration-docs-screenshot
@@ -67,7 +67,6 @@ def create_integration_bot(integration: WebhookIntegration, bot_name: Optional[s
password="123",
realm=owner.realm,
full_name=bot_name,
- short_name=bot_name,
bot_type=UserProfile.INCOMING_WEBHOOK_BOT,
bot_owner=owner,
acting_user=owner,
diff --git a/tools/test-api b/tools/test-api
index ef61dbbc565..9b4b2192ab2 100755
--- a/tools/test-api
+++ b/tools/test-api
@@ -68,8 +68,12 @@ with test_server_running(force=options.force, external_host='zulipdev.com:9981')
# Prepare the non-admin client
email = '[email protected]' # guest is not an admin
- guest_user = do_create_user('[email protected]', 'secret',
- get_realm('zulip'), 'Mr. Guest', 'guest')
+ guest_user = do_create_user(
+ 'secret',
+ get_realm('zulip'),
+ 'Mr. Guest',
+ )
api_key = get_api_key(guest_user)
nonadmin_client = Client(
email=email,
diff --git a/zerver/data_import/gitter.py b/zerver/data_import/gitter.py
index c407985cf9b..0ca081c3fc0 100644
--- a/zerver/data_import/gitter.py
+++ b/zerver/data_import/gitter.py
@@ -89,7 +89,6 @@ def build_userprofile(timestamp: Any, domain_name: str,
# Build userprofile object
userprofile = UserProfile(
full_name=user_data['displayName'],
- short_name=user_data['username'],
id=user_id,
email=email,
delivery_email=email,
@@ -100,6 +99,11 @@ def build_userprofile(timestamp: Any, domain_name: str,
# Set realm id separately as the corresponding realm is not yet a Realm model
# instance
userprofile_dict['realm'] = realm_id
+
+ # We use this later, even though Zulip doesn't
+ # support short_name
+ userprofile_dict['short_name'] = user_data['username']
+
zerver_userprofile.append(userprofile_dict)
user_id += 1
logging.info('######### IMPORTING USERS FINISHED #########\n')
diff --git a/zerver/data_import/import_util.py b/zerver/data_import/import_util.py
index 1352e485657..df1e00e62ce 100644
--- a/zerver/data_import/import_util.py
+++ b/zerver/data_import/import_util.py
@@ -99,10 +99,16 @@ def build_user_profile(avatar_source: str,
is_active=is_active,
role=role,
realm_id=realm_id,
- short_name=short_name,
timezone=timezone,
)
dct = model_to_dict(obj)
+
+ '''
+ Even though short_name is no longer in the Zulip
+ UserProfile, it's helpful to have it in our import
+ dictionaries for legacy reasons.
+ '''
+ dct['short_name'] = short_name
return dct
def build_avatar(zulip_user_id: int, realm_id: int, email: str, avatar_url: str,
diff --git a/zerver/data_import/slack.py b/zerver/data_import/slack.py
index 5cf2186f730..56736e55072 100755
--- a/zerver/data_import/slack.py
+++ b/zerver/data_import/slack.py
@@ -206,7 +206,6 @@ def users_to_zerver_userprofile(slack_data_dir: str, users: List[ZerverFieldsT],
userprofile = UserProfile(
full_name=get_user_full_name(user),
- short_name=user['name'],
is_active=not user.get('deleted', False) and not user["is_mirror_dummy"],
is_mirror_dummy=user["is_mirror_dummy"],
id=user_id,
diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py
index 43e062224d6..790aa405529 100644
--- a/zerver/lib/actions.py
+++ b/zerver/lib/actions.py
@@ -209,7 +209,6 @@ from zerver.models import (
active_non_guest_user_ids,
active_user_ids,
custom_profile_fields_for_realm,
- email_to_username,
filter_to_valid_prereg_users,
get_active_streams,
get_bot_dicts_in_realm,
@@ -566,12 +565,11 @@ def notify_created_bot(user_profile: UserProfile) -> None:
def create_users(realm: Realm, name_list: Iterable[Tuple[str, str]], bot_type: Optional[int]=None) -> None:
user_set = set()
for full_name, email in name_list:
- short_name = email_to_username(email)
- user_set.add((email, full_name, short_name, True))
+ user_set.add((email, full_name, True))
bulk_create_users(realm, user_set, bot_type)
def do_create_user(email: str, password: Optional[str], realm: Realm, full_name: str,
- short_name: str, bot_type: Optional[int]=None, role: Optional[int]=None,
+ bot_type: Optional[int]=None, role: Optional[int]=None,
bot_owner: Optional[UserProfile]=None, tos_version: Optional[str]=None,
timezone: str="", avatar_source: str=UserProfile.AVATAR_FROM_GRAVATAR,
default_sending_stream: Optional[Stream]=None,
@@ -585,7 +583,7 @@ def do_create_user(email: str, password: Optional[str], realm: Realm, full_name:
acting_user: Optional[UserProfile]=None) -> UserProfile:
user_profile = create_user(email=email, password=password, realm=realm,
- full_name=full_name, short_name=short_name,
+ full_name=full_name,
role=role, bot_type=bot_type, bot_owner=bot_owner,
tos_version=tos_version, timezone=timezone, avatar_source=avatar_source,
default_sending_stream=default_sending_stream,
@@ -1044,7 +1042,6 @@ def create_mirror_user_if_needed(realm: Realm, email: str,
password=None,
realm=realm,
full_name=email_to_fullname(email),
- short_name=email_to_username(email),
active=False,
is_mirror_dummy=True,
)
diff --git a/zerver/lib/bulk_create.py b/zerver/lib/bulk_create.py
index c9881978271..eb37044502d 100644
--- a/zerver/lib/bulk_create.py
+++ b/zerver/lib/bulk_create.py
@@ -9,7 +9,7 @@ from zerver.models import Realm, RealmAuditLog, Recipient, Stream, Subscription,
def bulk_create_users(realm: Realm,
- users_raw: Set[Tuple[str, str, str, bool]],
+ users_raw: Set[Tuple[str, str, bool]],
bot_type: Optional[int]=None,
bot_owner: Optional[UserProfile]=None,
tos_version: Optional[str]=None,
@@ -24,10 +24,10 @@ def bulk_create_users(realm: Realm,
# Now create user_profiles
profiles_to_create: List[UserProfile] = []
- for (email, full_name, short_name, active) in users:
+ for (email, full_name, active) in users:
profile = create_user_profile(realm, email,
initial_password(email), active, bot_type,
- full_name, short_name, bot_owner, False, tos_version,
+ full_name, bot_owner, False, tos_version,
timezone, tutorial_status=UserProfile.TUTORIAL_FINISHED,
enter_sends=True)
profiles_to_create.append(profile)
diff --git a/zerver/lib/cache.py b/zerver/lib/cache.py
index b3d175362b8..204f4788bf5 100644
--- a/zerver/lib/cache.py
+++ b/zerver/lib/cache.py
@@ -472,7 +472,7 @@ def user_profile_by_api_key_cache_key(api_key: str) -> str:
return f"user_profile_by_api_key:{api_key}"
realm_user_dict_fields: List[str] = [
- 'id', 'full_name', 'short_name', 'email',
+ 'id', 'full_name', 'email',
'avatar_source', 'avatar_version', 'is_active',
'role', 'is_bot', 'realm_id', 'timezone',
'date_joined', 'bot_owner_id', 'delivery_email',
@@ -505,7 +505,6 @@ bot_dict_fields: List[str] = [
'id',
'is_active',
'realm_id',
- 'short_name',
]
def bot_dicts_in_realm_cache_key(realm: 'Realm') -> str:
@@ -569,7 +568,7 @@ def flush_user_profile(sender: Any, **kwargs: Any) -> None:
if changed(kwargs, ['role']):
cache_delete(active_non_guest_user_ids_cache_key(user_profile.realm_id))
- if changed(kwargs, ['email', 'full_name', 'short_name', 'id', 'is_mirror_dummy']):
+ if changed(kwargs, ['email', 'full_name', 'id', 'is_mirror_dummy']):
delete_display_recipient_cache(user_profile)
# Invalidate our bots_in_realm info dict if any bot has
diff --git a/zerver/lib/create_user.py b/zerver/lib/create_user.py
index 41618a6001a..93e2644ce3f 100644
--- a/zerver/lib/create_user.py
+++ b/zerver/lib/create_user.py
@@ -68,7 +68,7 @@ def get_role_for_new_user(invited_as: int, realm_creation: bool=False) -> int:
# Recipient objects
def create_user_profile(realm: Realm, email: str, password: Optional[str],
active: bool, bot_type: Optional[int], full_name: str,
- short_name: str, bot_owner: Optional[UserProfile],
+ bot_owner: Optional[UserProfile],
is_mirror_dummy: bool, tos_version: Optional[str],
timezone: Optional[str],
tutorial_status: str = UserProfile.TUTORIAL_WAITING,
@@ -77,7 +77,7 @@ def create_user_profile(realm: Realm, email: str, password: Optional[str],
email = UserManager.normalize_email(email)
user_profile = UserProfile(is_staff=False, is_active=active,
- full_name=full_name, short_name=short_name,
+ full_name=full_name,
last_login=now, date_joined=now, realm=realm,
is_bot=bool(bot_type), bot_type=bot_type,
bot_owner=bot_owner, is_mirror_dummy=is_mirror_dummy,
@@ -97,21 +97,34 @@ def create_user_profile(realm: Realm, email: str, password: Optional[str],
user_profile.api_key = generate_api_key()
return user_profile
-def create_user(email: str, password: Optional[str], realm: Realm,
- full_name: str, short_name: str, active: bool = True,
+def create_user(email: str,
+ password: Optional[str],
+ realm: Realm,
+ full_name: str,
+ active: bool = True,
role: Optional[int] = None,
bot_type: Optional[int] = None,
bot_owner: Optional[UserProfile] = None,
- tos_version: Optional[str] = None, timezone: str = "",
+ tos_version: Optional[str] = None,
+ timezone: str = "",
avatar_source: str = UserProfile.AVATAR_FROM_GRAVATAR,
is_mirror_dummy: bool = False,
default_sending_stream: Optional[Stream] = None,
default_events_register_stream: Optional[Stream] = None,
default_all_public_streams: Optional[bool] = None,
source_profile: Optional[UserProfile] = None) -> UserProfile:
- user_profile = create_user_profile(realm, email, password, active, bot_type,
- full_name, short_name, bot_owner,
- is_mirror_dummy, tos_version, timezone)
+ user_profile = create_user_profile(
+ realm,
+ email,
+ password,
+ active,
+ bot_type,
+ full_name,
+ bot_owner,
+ is_mirror_dummy,
+ tos_version,
+ timezone
+ )
user_profile.avatar_source = avatar_source
user_profile.timezone = timezone
user_profile.default_sending_stream = default_sending_stream
diff --git a/zerver/lib/import_realm.py b/zerver/lib/import_realm.py
index 4f3cf5b4fe5..3e77e3e555d 100644
--- a/zerver/lib/import_realm.py
+++ b/zerver/lib/import_realm.py
@@ -62,7 +62,6 @@ from zerver.models import (
UserMessage,
UserPresence,
UserProfile,
- email_to_username,
get_huddle_hash,
get_system_bot,
get_user_profile_by_id,
@@ -880,6 +879,10 @@ def do_import_realm(import_dir: Path, subdomain: str, processes: int=1) -> Realm
# Since Zulip doesn't use these permissions, drop them
del user_profile_dict['user_permissions']
del user_profile_dict['groups']
+ # The short_name field is obsolete in Zulip, but it's
+ # convenient for third party exports to populate it.
+ if 'short_name' in user_profile_dict:
+ del user_profile_dict['short_name']
user_profiles = [UserProfile(**item) for item in data['zerver_userprofile']]
for user_profile in user_profiles:
@@ -1097,9 +1100,8 @@ def create_users(realm: Realm, name_list: Iterable[Tuple[str, str]],
bot_type: Optional[int]=None) -> None:
user_set = set()
for full_name, email in name_list:
- short_name = email_to_username(email)
if not UserProfile.objects.filter(email=email):
- user_set.add((email, full_name, short_name, True))
+ user_set.add((email, full_name, True))
bulk_create_users(realm, user_set, bot_type)
def update_message_foreign_keys(import_dir: Path,
diff --git a/zerver/lib/server_initialization.py b/zerver/lib/server_initialization.py
index cdf01857608..8d69b3b793e 100644
--- a/zerver/lib/server_initialization.py
+++ b/zerver/lib/server_initialization.py
@@ -3,7 +3,7 @@ from typing import Iterable, Optional, Tuple
from django.conf import settings
from zerver.lib.bulk_create import bulk_create_users
-from zerver.models import Realm, UserProfile, email_to_username, get_client, get_system_bot
+from zerver.models import Realm, UserProfile, get_client, get_system_bot
def server_initialized() -> bool:
@@ -41,6 +41,5 @@ def create_users(realm: Realm, name_list: Iterable[Tuple[str, str]],
bot_owner: Optional[UserProfile]=None) -> None:
user_set = set()
for full_name, email in name_list:
- short_name = email_to_username(email)
- user_set.add((email, full_name, short_name, True))
+ user_set.add((email, full_name, True))
bulk_create_users(realm, user_set, bot_type=bot_type, bot_owner=bot_owner, tos_version=tos_version)
diff --git a/zerver/management/commands/create_user.py b/zerver/management/commands/create_user.py
index 5ca7f3559aa..d1f6a129d70 100644
--- a/zerver/management/commands/create_user.py
+++ b/zerver/management/commands/create_user.py
@@ -10,7 +10,6 @@ from django.db.utils import IntegrityError
from zerver.lib.actions import do_create_user
from zerver.lib.initial_password import initial_password
from zerver.lib.management import ZulipBaseCommand
-from zerver.models import email_to_username
class Command(ZulipBaseCommand):
@@ -87,6 +86,12 @@ parameters, or specify no parameters for interactive user creation.""")
if user_initial_password is None:
raise CommandError("Password is unusable.")
pw = user_initial_password
- do_create_user(email, pw, realm, full_name, email_to_username(email), acting_user=None)
+ do_create_user(
+ email,
+ pw,
+ realm,
+ full_name,
+ acting_user=None,
+ )
except IntegrityError:
raise CommandError("User already exists.")
diff --git a/zerver/migrations/0296_remove_userprofile_short_name.py b/zerver/migrations/0296_remove_userprofile_short_name.py
new file mode 100644
index 00000000000..cbdaeb2ec53
--- /dev/null
+++ b/zerver/migrations/0296_remove_userprofile_short_name.py
@@ -0,0 +1,17 @@
+# Generated by Django 2.2.14 on 2020-07-16 11:06
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('zerver', '0295_case_insensitive_email_indexes'),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name='userprofile',
+ name='short_name',
+ ),
+ ]
diff --git a/zerver/models.py b/zerver/models.py
index 24db7aabb61..bc72efbe8b6 100644
--- a/zerver/models.py
+++ b/zerver/models.py
@@ -885,16 +885,13 @@ class UserProfile(AbstractBaseUser, PermissionsMixin):
# Foreign key to the Recipient object for PERSONAL type messages to this user.
recipient = models.ForeignKey(Recipient, null=True, on_delete=models.SET_NULL)
- # The user's name. We prefer the model of a full_name and
- # short_name over first+last because cultures vary on how many
+ # The user's name. We prefer the model of a full_name
+ # over first+last because cultures vary on how many
# names one has, whether the family name is first or last, etc.
# It also allows organizations to encode a bit of non-name data in
# the "name" attribute if desired, like gender pronouns,
- # graduation year, etc. The short_name attribute is currently not
- # used anywhere, but the intent is that it would be used as the
- # shorter familiar name for addressing the user in the UI.
+ # graduation year, etc.
full_name: str = models.CharField(max_length=MAX_NAME_LENGTH)
- short_name: str = models.CharField(max_length=MAX_NAME_LENGTH)
date_joined: datetime.datetime = models.DateTimeField(default=timezone_now)
tos_version: Optional[str] = models.CharField(null=True, max_length=10)
diff --git a/zerver/tests/test_audit_log.py b/zerver/tests/test_audit_log.py
index 6052d4c9407..14774e8d565 100644
--- a/zerver/tests/test_audit_log.py
+++ b/zerver/tests/test_audit_log.py
@@ -46,7 +46,7 @@ class TestRealmAuditLog(ZulipTestCase):
def test_user_activation(self) -> None:
realm = get_realm('zulip')
now = timezone_now()
- user = do_create_user('email', 'password', realm, 'full_name', 'short_name', acting_user=None)
+ user = do_create_user('email', 'password', realm, 'full_name', acting_user=None)
do_deactivate_user(user, acting_user=user)
do_activate_user(user, acting_user=user)
do_deactivate_user(user, acting_user=user)
diff --git a/zerver/tests/test_auth_backends.py b/zerver/tests/test_auth_backends.py
index d9357be0249..9049216ef29 100644
--- a/zerver/tests/test_auth_backends.py
+++ b/zerver/tests/test_auth_backends.py
@@ -4491,7 +4491,7 @@ class TestZulipLDAPUserPopulator(ZulipLDAPTestCase):
None,
test_realm,
hamlet.full_name,
- hamlet.short_name)
+ )
self.change_ldap_user_attr('hamlet', 'cn', 'Second Hamlet')
expected_call_args = [hamlet2, 'Second Hamlet', None]
diff --git a/zerver/tests/test_digest.py b/zerver/tests/test_digest.py
index cc3d3fb124d..5fff68ca0ee 100644
--- a/zerver/tests/test_digest.py
+++ b/zerver/tests/test_digest.py
@@ -254,8 +254,13 @@ class TestDigestEmailMessages(ZulipTestCase):
cutoff = timezone_now()
# A Tuesday
mock_django_timezone.return_value = datetime.datetime(year=2016, month=1, day=5)
- bot = do_create_user('[email protected]', 'password', get_realm('zulip'), 'some_bot', '',
- bot_type=UserProfile.DEFAULT_BOT)
+ bot = do_create_user(
+ 'password',
+ get_realm('zulip'),
+ 'some_bot',
+ bot_type=UserProfile.DEFAULT_BOT,
+ )
UserActivity.objects.create(
last_visit=cutoff - datetime.timedelta(days=1),
user_profile=bot,
diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py
index fa49af6a060..bae18bd02bd 100644
--- a/zerver/tests/test_events.py
+++ b/zerver/tests/test_events.py
@@ -749,8 +749,13 @@ class NormalActionsTest(BaseAction):
prereg_user = PreregistrationUser.objects.get(email="[email protected]")
events = self.verify_action(
- lambda: do_create_user('[email protected]', 'password', self.user_profile.realm,
- 'full name', 'short name', prereg_user=prereg_user),
+ lambda: do_create_user(
+ 'password',
+ self.user_profile.realm,
+ 'full name',
+ prereg_user=prereg_user,
+ ),
state_change_expected=True,
num_events=5,
)
diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.py
index 5fb329e26ae..637f4324a93 100644
--- a/zerver/tests/test_home.py
+++ b/zerver/tests/test_home.py
@@ -477,7 +477,6 @@ class HomeTest(ZulipTestCase):
password='123',
realm=owner.realm,
full_name=bot_name,
- short_name=bot_name,
bot_type=UserProfile.DEFAULT_BOT,
bot_owner=owner,
)
@@ -489,7 +488,6 @@ class HomeTest(ZulipTestCase):
password='123',
realm=realm,
full_name=name,
- short_name=name,
)
# Doing a full-stack deactivation would be expensive here,
diff --git a/zerver/tests/test_hotspots.py b/zerver/tests/test_hotspots.py
index 59123353b4d..13dec9866b5 100644
--- a/zerver/tests/test_hotspots.py
+++ b/zerver/tests/test_hotspots.py
@@ -12,7 +12,11 @@ class TestGetNextHotspots(ZulipTestCase):
def setUp(self) -> None:
super().setUp()
self.user = do_create_user(
- '[email protected]', 'password', get_realm('zulip'), 'user', 'user')
+ 'password',
+ get_realm('zulip'),
+ 'user',
+ )
def test_first_hotspot(self) -> None:
hotspots = get_next_hotspots(self.user)
diff --git a/zerver/tests/test_import_export.py b/zerver/tests/test_import_export.py
index eafa0f07b62..6f19a764a95 100644
--- a/zerver/tests/test_import_export.py
+++ b/zerver/tests/test_import_export.py
@@ -720,7 +720,6 @@ class ImportExportTest(ZulipTestCase):
password="test",
realm=original_realm,
full_name="bot",
- short_name="bot",
bot_type=UserProfile.EMBEDDED_BOT,
bot_owner=sample_user)
storage = StateHandler(bot_profile)
diff --git a/zerver/tests/test_management_commands.py b/zerver/tests/test_management_commands.py
index 3d9e2452458..ac3672ba26d 100644
--- a/zerver/tests/test_management_commands.py
+++ b/zerver/tests/test_management_commands.py
@@ -74,7 +74,7 @@ class TestZulipBaseCommand(ZulipTestCase):
with self.assertRaisesRegex(CommandError, "server does not contain a user with email"):
self.command.get_user('[email protected]', None)
- do_create_user(email, 'password', mit_realm, 'full_name', 'short_name')
+ do_create_user(email, 'password', mit_realm, 'full_name')
with self.assertRaisesRegex(CommandError, "server contains multiple users with that email"):
self.command.get_user(email, None)
diff --git a/zerver/tests/test_markdown.py b/zerver/tests/test_markdown.py
index b952708a486..f5f4c7e6c7e 100644
--- a/zerver/tests/test_markdown.py
+++ b/zerver/tests/test_markdown.py
@@ -208,7 +208,6 @@ class MarkdownMiscTest(ZulipTestCase):
password='whatever',
realm=realm,
full_name=full_name,
- short_name='whatever',
)
fred1 = make_user('[email protected]', 'Fred Flintstone')
@@ -1576,7 +1575,6 @@ class MarkdownTest(ZulipTestCase):
password='whatever',
realm=realm,
full_name=full_name,
- short_name='whatever',
)
sender_user_profile = self.example_user('othello')
@@ -1622,11 +1620,12 @@ class MarkdownTest(ZulipTestCase):
'<RealmFilter(zulip): #(?P<id>[0-9]{2,8})'
' https://trac.example.com/ticket/%(id)s>')
# Create a user that potentially interferes with the pattern.
- test_user = create_user(email='[email protected]',
- password='whatever',
- realm=realm,
- full_name='Atomic #123',
- short_name='whatever')
+ test_user = create_user(
+ password='whatever',
+ realm=realm,
+ full_name='Atomic #123',
+ )
content = "@**Atomic #123**"
self.assertEqual(render_markdown(msg, content),
'<p><span class="user-mention" '
diff --git a/zerver/tests/test_message_send.py b/zerver/tests/test_message_send.py
index 0bf2d974ab4..3ffe7ac91a2 100644
--- a/zerver/tests/test_message_send.py
+++ b/zerver/tests/test_message_send.py
@@ -183,7 +183,6 @@ class MessagePOSTTest(ZulipTestCase):
password='',
realm=non_admin_profile.realm,
full_name='freebot',
- short_name='freebot',
bot_type=UserProfile.DEFAULT_BOT,
)
self._send_and_verify_message(bot_without_owner, stream_name,
@@ -248,7 +247,6 @@ class MessagePOSTTest(ZulipTestCase):
password='',
realm=non_admin_profile.realm,
full_name='freebot',
- short_name='freebot',
bot_type=UserProfile.DEFAULT_BOT,
)
self._send_and_verify_message(bot_without_owner, stream_name,
@@ -1302,7 +1300,6 @@ class StreamMessagesTest(ZulipTestCase):
password='',
realm=realm,
full_name='Normal Bot',
- short_name='',
bot_type=UserProfile.DEFAULT_BOT,
bot_owner=cordelia,
)
@@ -1903,7 +1900,6 @@ class CheckMessageTest(ZulipTestCase):
password='',
realm=parent.realm,
full_name='',
- short_name='',
bot_type=UserProfile.DEFAULT_BOT,
bot_owner=parent,
)
diff --git a/zerver/tests/test_outgoing_webhook_system.py b/zerver/tests/test_outgoing_webhook_system.py
index 72bf0368053..ad97376e7e4 100644
--- a/zerver/tests/test_outgoing_webhook_system.py
+++ b/zerver/tests/test_outgoing_webhook_system.py
@@ -165,7 +165,6 @@ class TestOutgoingWebhookMessaging(ZulipTestCase):
full_name='Outgoing Webhook Bot',
email='whatever',
realm=bot_owner.realm,
- short_name='',
password=None,
)
diff --git a/zerver/tests/test_realm_emoji.py b/zerver/tests/test_realm_emoji.py
index e73f18c2661..69483a9bfae 100644
--- a/zerver/tests/test_realm_emoji.py
+++ b/zerver/tests/test_realm_emoji.py
@@ -269,11 +269,12 @@ class RealmEmojiTest(ZulipTestCase):
# Test that two different realm emojis in two different realms but
# having same name can be administered independently.
realm_1 = do_create_realm('test_realm', 'test_realm')
- emoji_author_1 = do_create_user('[email protected]',
- password='abc',
- realm=realm_1,
- full_name='abc',
- short_name='abc')
+ emoji_author_1 = do_create_user(
+ password='abc',
+ realm=realm_1,
+ full_name='abc',
+ )
self.create_test_emoji('test_emoji', emoji_author_1)
emoji_author_2 = self.example_user('othello')
diff --git a/zerver/tests/test_service_bot_system.py b/zerver/tests/test_service_bot_system.py
index 0881da53864..2cf0d3a5887 100644
--- a/zerver/tests/test_service_bot_system.py
+++ b/zerver/tests/test_service_bot_system.py
@@ -25,7 +25,6 @@ class TestServiceBotBasics(ZulipTestCase):
password="test",
realm=get_realm("zulip"),
full_name="BarBot",
- short_name='bb',
bot_type=UserProfile.OUTGOING_WEBHOOK_BOT,
bot_owner=self.example_user('cordelia'),
)
@@ -170,14 +169,12 @@ class TestServiceBotStateHandler(ZulipTestCase):
password="test",
realm=get_realm("zulip"),
full_name="EmbeddedBo1",
- short_name="embedded-bot-1",
bot_type=UserProfile.EMBEDDED_BOT,
bot_owner=self.user_profile)
self.second_bot_profile = do_create_user(email="[email protected]",
password="test",
realm=get_realm("zulip"),
full_name="EmbeddedBot2",
- short_name="embedded-bot-2",
bot_type=UserProfile.EMBEDDED_BOT,
bot_owner=self.user_profile)
@@ -397,14 +394,12 @@ class TestServiceBotEventTriggers(ZulipTestCase):
password="test",
realm=get_realm("zulip"),
full_name="FooBot",
- short_name="foo-bot",
bot_type=UserProfile.OUTGOING_WEBHOOK_BOT,
bot_owner=self.user_profile)
self.second_bot_profile = do_create_user(email="[email protected]",
password="test",
realm=get_realm("zulip"),
full_name="BarBot",
- short_name="bar-bot",
bot_type=UserProfile.OUTGOING_WEBHOOK_BOT,
bot_owner=self.user_profile)
diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.py
index 0065204a6da..a259aae713a 100644
--- a/zerver/tests/test_signup.py
+++ b/zerver/tests/test_signup.py
@@ -1579,7 +1579,7 @@ so we didn't send them an invitation. We did send invitations to everyone else!"
'password',
self.user_profile.realm,
- 'full name', 'short name',
+ 'full name',
prereg_user=prereg_user,
)
@@ -3392,8 +3392,6 @@ class UserSignUpTest(InviteUserBase):
user_profile = UserProfile.objects.get(delivery_email=email)
# Name comes from form which was set by LDAP.
self.assertEqual(user_profile.full_name, full_name)
- # Short name comes from LDAP.
- self.assertEqual(user_profile.short_name, "shortname")
@override_settings(AUTHENTICATION_BACKENDS=('zproject.backends.ZulipLDAPAuthBackend',
'zproject.backends.ZulipDummyBackend'))
@@ -3435,8 +3433,6 @@ class UserSignUpTest(InviteUserBase):
user_profile = UserProfile.objects.get(delivery_email=email)
# Name comes from form which was set by LDAP.
self.assertEqual(user_profile.full_name, "First Last")
- # Short name comes from LDAP.
- self.assertEqual(user_profile.short_name, "First")
@override_settings(AUTHENTICATION_BACKENDS=('zproject.backends.ZulipLDAPAuthBackend',
'zproject.backends.ZulipDummyBackend'))
@@ -3472,7 +3468,6 @@ class UserSignUpTest(InviteUserBase):
user_profile = UserProfile.objects.get(delivery_email=email)
# Name comes from form which was set by LDAP.
self.assertEqual(user_profile.full_name, full_name)
- self.assertEqual(user_profile.short_name, 'shortname')
# Test custom profile fields are properly synced.
phone_number_field = CustomProfileField.objects.get(realm=user_profile.realm, name='Phone number')
diff --git a/zerver/tests/test_slack_importer.py b/zerver/tests/test_slack_importer.py
index 52c86560782..c9e9ee2d399 100644
--- a/zerver/tests/test_slack_importer.py
+++ b/zerver/tests/test_slack_importer.py
@@ -356,7 +356,6 @@ class SlackImporter(ZulipTestCase):
self.assertEqual(zerver_userprofile[3]['email'], '[email protected]')
self.assertEqual(zerver_userprofile[3]['realm'], 1)
self.assertEqual(zerver_userprofile[3]['full_name'], 'Matt Perry')
- self.assertEqual(zerver_userprofile[3]['short_name'], 'matt.perry')
self.assertEqual(zerver_userprofile[3]['is_mirror_dummy'], True)
self.assertEqual(zerver_userprofile[3]['is_api_super_user'], False)
diff --git a/zerver/tests/test_users.py b/zerver/tests/test_users.py
index 76d0ad898e6..234134d6fc0 100644
--- a/zerver/tests/test_users.py
+++ b/zerver/tests/test_users.py
@@ -824,7 +824,6 @@ class AdminCreateUserTest(ZulipTestCase):
# Romeo is a newly registered user
new_user = get_user_by_delivery_email('[email protected]', get_realm('zulip'))
self.assertEqual(new_user.full_name, 'Romeo Montague')
- self.assertEqual(new_user.short_name, 'deprecated')
# Make sure the recipient field is set correctly.
self.assertEqual(new_user.recipient, Recipient.objects.get(type=Recipient.PERSONAL,
@@ -1442,7 +1441,6 @@ class RecipientInfoTest(ZulipTestCase):
password='',
realm=realm,
full_name='',
- short_name='',
bot_type=UserProfile.EMBEDDED_BOT,
)
@@ -1462,7 +1460,6 @@ class RecipientInfoTest(ZulipTestCase):
password='',
realm=realm,
full_name='',
- short_name='',
bot_type=UserProfile.DEFAULT_BOT,
)
diff --git a/zerver/views/registration.py b/zerver/views/registration.py
index 2364ae49061..2b6b9cec9fb 100644
--- a/zerver/views/registration.py
+++ b/zerver/views/registration.py
@@ -61,7 +61,6 @@ from zerver.models import (
Realm,
Stream,
UserProfile,
- email_to_username,
get_default_stream_groups,
get_realm,
get_source_profile,
@@ -286,7 +285,6 @@ def accounts_register(request: HttpRequest) -> HttpResponse:
assert(realm is not None)
full_name = form.cleaned_data['full_name']
- short_name = email_to_username(email)
default_stream_group_names = request.POST.getlist('default_stream_group')
default_stream_groups = lookup_default_stream_groups(default_stream_group_names, realm)
@@ -374,7 +372,7 @@ def accounts_register(request: HttpRequest) -> HttpResponse:
# make it respect invited_as_admin / is_realm_admin.
if user_profile is None:
- user_profile = do_create_user(email, password, realm, full_name, short_name,
+ user_profile = do_create_user(email, password, realm, full_name,
prereg_user=prereg_user,
role=role,
tos_version=settings.TOS_VERSION,
diff --git a/zerver/views/users.py b/zerver/views/users.py
index d3c4bb3af20..bab1d6730e2 100644
--- a/zerver/views/users.py
+++ b/zerver/views/users.py
@@ -382,7 +382,6 @@ def add_bot_backend(
bot_profile = do_create_user(email=email, password=None,
realm=user_profile.realm, full_name=full_name,
- short_name=short_name,
bot_type=bot_type,
bot_owner=user_profile,
avatar_source=avatar_source,
@@ -522,9 +521,7 @@ def create_user_backend(
if not check_password_strength(password):
return json_error(PASSWORD_TOO_WEAK_ERROR)
- short_name = 'deprecated'
-
- do_create_user(email, password, realm, full_name, short_name, acting_user=user_profile)
+ do_create_user(email, password, realm, full_name, acting_user=user_profile)
return json_success()
def get_profile_backend(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
diff --git a/zilencer/management/commands/add_mock_conversation.py b/zilencer/management/commands/add_mock_conversation.py
index e9dd5152180..1be57f98829 100644
--- a/zilencer/management/commands/add_mock_conversation.py
+++ b/zilencer/management/commands/add_mock_conversation.py
@@ -45,11 +45,11 @@ From image editing program:
stream = ensure_stream(realm, 'zulip features', acting_user=None)
UserProfile.objects.filter(email__contains='stage').delete()
- starr = do_create_user('[email protected]', 'password', realm, 'Ada Starr', '', acting_user=None)
+ starr = do_create_user('[email protected]', 'password', realm, 'Ada Starr', acting_user=None)
self.set_avatar(starr, 'static/images/characters/starr.png')
- fisher = do_create_user('[email protected]', 'password', realm, 'Bel Fisher', '', acting_user=None)
+ fisher = do_create_user('[email protected]', 'password', realm, 'Bel Fisher', acting_user=None)
self.set_avatar(fisher, 'static/images/characters/fisher.png')
- twitter_bot = do_create_user('[email protected]', 'password', realm, 'Twitter Bot', '',
+ twitter_bot = do_create_user('[email protected]', 'password', realm, 'Twitter Bot',
bot_type=UserProfile.DEFAULT_BOT, acting_user=None)
self.set_avatar(twitter_bot, 'static/images/features/twitter.png')
diff --git a/zilencer/management/commands/add_new_realm.py b/zilencer/management/commands/add_new_realm.py
index 5a7b1074cac..6f20a445135 100644
--- a/zilencer/management/commands/add_new_realm.py
+++ b/zilencer/management/commands/add_new_realm.py
@@ -16,8 +16,14 @@ class Command(ZulipBaseCommand):
name = '{:02}-user'.format(
UserProfile.objects.filter(email__contains='user@').count())
- user = do_create_user(f'{name}@{string_id}.zulip.com',
- 'password', realm, name, name, role=UserProfile.ROLE_REALM_ADMINISTRATOR, acting_user=None)
+ user = do_create_user(
+ f'{name}@{string_id}.zulip.com',
+ 'password',
+ realm,
+ name,
+ role=UserProfile.ROLE_REALM_ADMINISTRATOR,
+ acting_user=None,
+ )
assert realm.signup_notifications_stream is not None
bulk_add_subscriptions([realm.signup_notifications_stream], [user])
diff --git a/zilencer/management/commands/add_new_user.py b/zilencer/management/commands/add_new_user.py
index b34fa09a05d..22eed000f6b 100644
--- a/zilencer/management/commands/add_new_user.py
+++ b/zilencer/management/commands/add_new_user.py
@@ -30,4 +30,4 @@ and will otherwise fall back to the zulip realm."""
domain = realm.string_id + '.zulip.com'
name = '{:02}-user'.format(UserProfile.objects.filter(email__contains='user@').count())
- do_create_user(f'{name}@{domain}', 'password', valid_realm, name, name, acting_user=None)
+ do_create_user(f'{name}@{domain}', 'password', valid_realm, name, acting_user=None)
diff --git a/zproject/backends.py b/zproject/backends.py
index 3684e434f89..edea432b17a 100644
--- a/zproject/backends.py
+++ b/zproject/backends.py
@@ -749,7 +749,7 @@ class ZulipLDAPAuthBackend(ZulipLDAPAuthBackendBase):
# the LDAP flow.
opts['default_stream_groups'] = []
- user_profile = do_create_user(username, None, self._realm, full_name, short_name, acting_user=None, **opts)
+ user_profile = do_create_user(username, None, self._realm, full_name, acting_user=None, **opts)
self.sync_avatar_from_ldap(user_profile, ldap_user)
self.sync_custom_profile_fields_from_ldap(user_profile, ldap_user)