def get_attachments_list(self, qs): attachments = [] for attachment in qs: attachment_data = { 'id': attachment.id, 'url': attachment.attachment.url, 'name': basename(attachment.attachment.name), 'filesize': attachment.size, } if hasattr(attachment, 'attachmentimage'): attachment_data['width'] = attachment.attachmentimage.width attachment_data['height'] = attachment.attachmentimage.height attachment_data['thumbnails'] = { 'standard': thumbnail(attachment.attachment, size=(256, 256)).url } attachments.append(attachment_data) return attachments
def avatar_for_user(user, size=GRAVATAR_DEFAULT_SIZE): if user.avatar: avatar = thumbnail(user.avatar, size=(size, size), crop=True) if avatar: return avatar.url return gravatar_for_email(user.email, size)