def _save_icon(self, obj, image): new_name = get_random_string(length=6) ext = image.name.split('.')[-1] image.name = '%s.%s' % (new_name, ext) large, medium, small = create_thumbnail(image, new_name, ext) obj.icon_raw = image obj.icon_l = large obj.icon_m = medium obj.icon_s = small
def _save_avatar(self, profile, image): new_name = get_random_string(length=6) ext = image.name.split('.')[-1] image.name = '%s.%s' % (new_name, ext) large, medium, small = create_thumbnail(image, new_name, ext) a = Avatar(avatar_raw=image, avatar_l=large, avatar_m=medium, avatar_s=small) a.save() if profile.has_avatar(): profile.avatar.deleted = True profile.avatar.save() profile.avatar = a