Remove 'Only Once Function'

Brightcells 8 年之前
父節點
當前提交
8d20a44c71
共有 1 個文件被更改,包括 0 次插入70 次删除
  1. 0 70
      group/views.py

+ 0 - 70
group/views.py

@@ -667,73 +667,3 @@ class GroupUserInfoViewSet(viewsets.ModelViewSet):
667 667
 class GroupPhotoInfoViewSet(viewsets.ModelViewSet):
668 668
     queryset = GroupPhotoInfo.objects.all().order_by('-pk')
669 669
     serializer_class = GroupPhotoInfoSerializer
670
-
671
-
672
-# Only Once Function
673
-def refresh_thumbnail():
674
-    """ 刷新缩略图 """
675
-    photos = GroupPhotoInfo.objects.filter(status=True)
676
-
677
-    for photo in photos:
678
-        try:
679
-            photo_path = photo.photo_path
680
-            photo_thumbnail_path = photo_path.replace('.', '_thumbnail.')
681
-            photo_thumbnail2_path = photo_path.replace('.', '_thumbnail2.')
682
-
683
-            # 群组照片缩略图生成
684
-            # 双列: 540, 40-50K
685
-            photo_w, photo_h, photo_thumbnail_w, photo_thumbnail_h = make_thumbnail(
686
-                os.path.join(settings.MEDIA_ROOT, photo_path).replace('\\', '/'),
687
-                os.path.join(settings.MEDIA_ROOT, photo_thumbnail_path).replace('\\', '/'),
688
-                settings.THUMBNAIL_MAX_WIDTH
689
-            )
690
-            # 单列: 1080, xx-100K
691
-            photo_w, photo_h, photo_thumbnail2_w, photo_thumbnail2_h = make_thumbnail(
692
-                os.path.join(settings.MEDIA_ROOT, photo_path).replace('\\', '/'),
693
-                os.path.join(settings.MEDIA_ROOT, photo_thumbnail2_path).replace('\\', '/'),
694
-                settings.THUMBNAIL_MAX_WIDTH2
695
-            )
696
-
697
-            photo.photo_w = photo_w
698
-            photo.photo_h = photo_h
699
-            photo.photo_thumbnail_path = photo_thumbnail_path
700
-            photo.photo_thumbnail_w = photo_thumbnail_w
701
-            photo.photo_thumbnail_h = photo_thumbnail_h
702
-            photo.photo_thumbnail2_path = photo_thumbnail2_path
703
-            photo.photo_thumbnail2_w = photo_thumbnail2_w
704
-            photo.photo_thumbnail2_h = photo_thumbnail2_h
705
-
706
-            photo.save()
707
-        except Exception as e:
708
-            pass
709
-
710
-    return 'Refresh Thumbnail OK'
711
-
712
-
713
-def statistic_thumbnail_size(pfrom):
714
-    """
715
-    统计缩略图大小
716
-    :param pfrom: 0 for APP_GROUP, 1 for SESSION_GROUP, -1 for ALL
717
-    :return:
718
-    """
719
-    if pfrom == -1:
720
-        photos = GroupPhotoInfo.objects.filter(status=True)
721
-    else:
722
-        photos = GroupPhotoInfo.objects.filter(photo_from=pfrom, status=True)
723
-
724
-    photo_count = photos.count()
725
-
726
-    photo_size = 0
727
-    photo_thumbnail_size = 0
728
-    photo_thumbnail2_size = 0
729
-
730
-    for photo in photos:
731
-        photo_size += os.path.getsize(os.path.join(settings.MEDIA_ROOT, photo.photo_path).replace('\\', '/'))
732
-        photo_thumbnail_size += os.path.getsize(os.path.join(settings.MEDIA_ROOT, photo.photo_thumbnail_path).replace('\\', '/'))
733
-        photo_thumbnail2_size += os.path.getsize(os.path.join(settings.MEDIA_ROOT, photo.photo_thumbnail2_path).replace('\\', '/'))
734
-
735
-    print '>>> Photo Size: %.3f KB' % (photo_size / 1024 / photo_count)
736
-    print '>>> Photo Thumbnail Size: %.3f KB' % (photo_thumbnail_size / 1024 / photo_count)
737
-    print '>>> Photo Thumbnail2 Size: %.3f KB' % (photo_thumbnail2_size / 1024 / photo_count)
738
-
739
-    return 'Statistic Thumbnail Size OK'