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

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