mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 22:43:42 +00:00
registration: Allow users to import profile picture.
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
from django.contrib.auth.models import UserManager
|
||||
from django.utils.timezone import now as timezone_now
|
||||
from zerver.models import UserProfile, Recipient, Subscription, Realm, Stream
|
||||
from zerver.lib.upload import copy_avatar
|
||||
|
||||
import base64
|
||||
import ujson
|
||||
import os
|
||||
@@ -25,6 +27,12 @@ def copy_user_settings(source_profile: UserProfile, target_profile: UserProfile)
|
||||
setattr(target_profile, settings_name, value)
|
||||
|
||||
setattr(target_profile, "full_name", source_profile.full_name)
|
||||
target_profile.save()
|
||||
|
||||
if source_profile.avatar_source == UserProfile.AVATAR_FROM_USER:
|
||||
from zerver.lib.actions import do_change_avatar_fields
|
||||
do_change_avatar_fields(target_profile, UserProfile.AVATAR_FROM_USER)
|
||||
copy_avatar(source_profile, target_profile)
|
||||
|
||||
# create_user_profile is based on Django's User.objects.create_user,
|
||||
# except that we don't save to the database so it can used in
|
||||
@@ -92,9 +100,11 @@ def create_user(email: str, password: Optional[str], realm: Realm,
|
||||
# than the guess. As we decide on details like avatars and full
|
||||
# names for this feature, we may want to move it.
|
||||
if source_profile is not None:
|
||||
# copy_user_settings saves the attribute values so a secondary
|
||||
# save is not required.
|
||||
copy_user_settings(source_profile, user_profile)
|
||||
|
||||
user_profile.save()
|
||||
else:
|
||||
user_profile.save()
|
||||
|
||||
recipient = Recipient.objects.create(type_id=user_profile.id,
|
||||
type=Recipient.PERSONAL)
|
||||
|
||||
Reference in New Issue
Block a user