mirror of
https://github.com/zulip/zulip.git
synced 2025-10-30 11:33:51 +00:00
zerver/migrations: Remove u prefix from strings.
This commit is contained in:
@@ -26,7 +26,7 @@ def patched_user_avatar_path(user_profile: UserProfile) -> Text:
|
||||
@patch('zerver.lib.upload.user_avatar_path', patched_user_avatar_path)
|
||||
def verify_medium_avatar_image(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
|
||||
user_profile_model = apps.get_model('zerver', 'UserProfile')
|
||||
for user_profile in user_profile_model.objects.filter(avatar_source=u"U"):
|
||||
for user_profile in user_profile_model.objects.filter(avatar_source="U"):
|
||||
upload_backend.ensure_medium_avatar_image(user_profile)
|
||||
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ def move_local_file(type: Text, path_src: Text, path_dst: Text) -> None:
|
||||
def move_avatars_to_be_uid_based(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
|
||||
user_profile_model = apps.get_model('zerver', 'UserProfile')
|
||||
if settings.LOCAL_UPLOADS_DIR is not None:
|
||||
for user_profile in user_profile_model.objects.filter(avatar_source=u"U"):
|
||||
for user_profile in user_profile_model.objects.filter(avatar_source="U"):
|
||||
src_file_name = user_avatar_hash(user_profile.email)
|
||||
dst_file_name = user_avatar_path(user_profile)
|
||||
try:
|
||||
@@ -49,13 +49,13 @@ def move_avatars_to_be_uid_based(apps: StateApps, schema_editor: DatabaseSchemaE
|
||||
# If the user's avatar is missing, it's probably
|
||||
# because they previously changed their email address.
|
||||
# So set them to have a gravatar instead.
|
||||
user_profile.avatar_source = u"G"
|
||||
user_profile.avatar_source = "G"
|
||||
user_profile.save(update_fields=["avatar_source"])
|
||||
else:
|
||||
conn = S3Connection(settings.S3_KEY, settings.S3_SECRET_KEY)
|
||||
bucket_name = settings.S3_AVATAR_BUCKET
|
||||
bucket = conn.get_bucket(bucket_name, validate=False)
|
||||
for user_profile in user_profile_model.objects.filter(avatar_source=u"U"):
|
||||
for user_profile in user_profile_model.objects.filter(avatar_source="U"):
|
||||
uid_hash_path = user_avatar_path(user_profile)
|
||||
email_hash_path = user_avatar_hash(user_profile.email)
|
||||
if bucket.get_key(uid_hash_path):
|
||||
@@ -65,7 +65,7 @@ def move_avatars_to_be_uid_based(apps: StateApps, schema_editor: DatabaseSchemaE
|
||||
# If the user's avatar is missing, it's probably
|
||||
# because they previously changed their email address.
|
||||
# So set them to have a gravatar instead.
|
||||
user_profile.avatar_source = u"G"
|
||||
user_profile.avatar_source = "G"
|
||||
user_profile.save(update_fields=["avatar_source"])
|
||||
continue
|
||||
|
||||
@@ -82,7 +82,7 @@ def move_avatars_to_be_uid_based(apps: StateApps, schema_editor: DatabaseSchemaE
|
||||
# From an error handling sanity perspective, it's best to
|
||||
# start deleting after everything is copied, so that recovery
|
||||
# from failures is easy (just rerun one loop or the other).
|
||||
for user_profile in user_profile_model.objects.filter(avatar_source=u"U"):
|
||||
for user_profile in user_profile_model.objects.filter(avatar_source="U"):
|
||||
bucket.delete_key(user_avatar_hash(user_profile.email) + ".original")
|
||||
bucket.delete_key(user_avatar_hash(user_profile.email) + "-medium.png")
|
||||
bucket.delete_key(user_avatar_hash(user_profile.email))
|
||||
|
||||
@@ -124,7 +124,7 @@ class S3Uploader(Uploader):
|
||||
headers = None # type: Optional[Dict[Text, Text]]
|
||||
content_type = response.headers.get(str("Content-Type")) or guess_type(dst_path_id)[0]
|
||||
if content_type:
|
||||
headers = {u'Content-Type': content_type}
|
||||
headers = {'Content-Type': content_type}
|
||||
if resized_image:
|
||||
self.upload_to_s3(dst_path_id, resized_image, headers)
|
||||
else:
|
||||
|
||||
@@ -5,7 +5,7 @@ from django.db.migrations.state import StateApps
|
||||
|
||||
def set_tutorial_status_to_finished(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
|
||||
UserProfile = apps.get_model('zerver', 'UserProfile')
|
||||
UserProfile.objects.update(tutorial_status=u'F')
|
||||
UserProfile.objects.update(tutorial_status='F')
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user