mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 17:07:07 +00:00
This adds a medium (500px) size avatar thumbnail, that can be
referenced as `{name}-medium.png`. It is intended to be used on the
user's own settings page, though we may come up with other use cases
for high-resolution avatars in the future.
This will automatically generate and upload the medium avatar images
when a new avatar original is uploaded, and contains a migration
(contributed by Kirill Kanakhin) to ensure all pre-existing avatar
images have a medium avatar.
Note that this implementation does not provide an endpoint for
fetching the medium-size avatar for another user.
[substantially modified by tabbott]
27 lines
803 B
Python
27 lines
803 B
Python
# -*- coding: utf-8 -*-
|
|
from __future__ import unicode_literals
|
|
|
|
from django.db import migrations
|
|
from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor
|
|
from django.db.migrations.state import StateApps
|
|
|
|
from zerver.lib.upload import upload_backend
|
|
|
|
|
|
def verify_medium_avatar_image(apps, schema_editor):
|
|
# type: (StateApps, DatabaseSchemaEditor) -> None
|
|
user_profile_model = apps.get_model('zerver', 'UserProfile')
|
|
for user_profile in user_profile_model.objects.filter(avatar_source=u"U"):
|
|
upload_backend.ensure_medium_avatar_image(user_profile.email)
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('zerver', '0031_remove_system_avatar_source'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.RunPython(verify_medium_avatar_image)
|
|
]
|