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

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