예제 #1
0
    def delete_all_dims(self, filename):
        dims = self.config.get("dims")
        if not type(dims) == dict:
            self.sys_error = u'配置错误,"dims"配置项必须为字典形式'
            return False

        for dim in dims.values():
            file_utils.remove(dim["dir"], filename)  # TODO: some error handling later

        return True
예제 #2
0
    def delete_all_dims(self, filename):
        dims = self.config.get('dims')
        if not type(dims) == dict:
            self.sys_error = u'配置错误,"dims"配置项必须为字典形式'
            return False

        for dim in dims.values():
            file_utils.remove(dim['dir'],
                              filename)  # TODO: some error handling later

        return True
예제 #3
0
     img = img.crop(XY)
 except:
     utils.addMsg(request, messages.WARNING, u"""还没有对头像进行剪切。剪切请在
         大头像上按住、并拖动鼠标。若不需要剪切,可点击'撤销'""")
     return HttpResponseRedirect(reverse("profiles_setpic")) 
 
 
 big_pic = img_utils.scalePic(img, PIC_ROOT, "profile", utils.genUuid()+'_b', settings.PIC_SIZE_BIG, 100)
 normal_pic = img_utils.scalePic(img, PIC_ROOT, "profile", utils.genUuid()+'_n', settings.PIC_SIZE_NORMAL, 80)
 small_pic = img_utils.scalePic(img, PIC_ROOT, "profile", utils.genUuid()+'_s', settings.PIC_SIZE_SMALL, 50)
 
 if big_pic and normal_pic and small_pic:
     
     ## 删除临时图片及设置之前的图片
     if profile.tmp_pic != settings.DEFAULT_PIC:
         file_utils.remove(PIC_ROOT, profile.tmp_pic)
     
     if profile.big_pic != settings.DEFAULT_PIC:
         file_utils.remove(PIC_ROOT, profile.big_pic)
     if profile.normal_pic != settings.DEFAULT_PIC_NORMAL:
         file_utils.remove(PIC_ROOT, profile.normal_pic)
     if profile.small_pic != settings.DEFAULT_PIC_SMALL:
         file_utils.remove(PIC_ROOT, profile.small_pic)
     
     profile.tmp_pic = big_pic
     profile.big_pic = big_pic
     profile.normal_pic = normal_pic
     profile.small_pic = small_pic
     profile.save()
     
     utils.addMsg(request, messages.SUCCESS, u"头像更新成功")