示例#1
0
文件: admin.py 项目: niutool/niuforum
 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
示例#2
0
 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
示例#3
0
文件: views.py 项目: niutool/niuforum
 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
示例#4
0
    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