Files
zulip/zerver/migrations/0032_verify_all_medium_avatar_images.py
Brock Whittaker fca61b2031 Add medium size avatars for use on the user's own settings page.
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]
2016-10-25 09:42:14 -07:00

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