database: Remove short_name from UserProfile.

A few major themes here:

    - We remove short_name from UserProfile
      and add the appropriate migration.

    - We remove short_name from various
      cache-related lists of fields.

    - We allow import tools to continue to
      write short_name to their export files,
      and then we simply ignore the field
      at import time.

    - We change functions like do_create_user,
      create_user_profile, etc.

    - We keep short_name in the /json/bots
      API.  (It actually gets turned into
      an email.)

    - We don't modify our LDAP code much
      here.
This commit is contained in:
Steve Howell
2020-07-16 12:10:43 +00:00
committed by Tim Abbott
parent c60f4236a9
commit c44500175d
39 changed files with 156 additions and 114 deletions

View File

@@ -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('1@stage.example.com', 'password', realm, 'Ada Starr', '', acting_user=None)
starr = do_create_user('1@stage.example.com', 'password', realm, 'Ada Starr', acting_user=None)
self.set_avatar(starr, 'static/images/characters/starr.png')
fisher = do_create_user('2@stage.example.com', 'password', realm, 'Bel Fisher', '', acting_user=None)
fisher = do_create_user('2@stage.example.com', 'password', realm, 'Bel Fisher', acting_user=None)
self.set_avatar(fisher, 'static/images/characters/fisher.png')
twitter_bot = do_create_user('3@stage.example.com', 'password', realm, 'Twitter Bot', '',
twitter_bot = do_create_user('3@stage.example.com', 'password', realm, 'Twitter Bot',
bot_type=UserProfile.DEFAULT_BOT, acting_user=None)
self.set_avatar(twitter_bot, 'static/images/features/twitter.png')

View File

@@ -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])

View File

@@ -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)