瀏覽代碼

Only use prefetched thumbnails if there are there

The optimization broke image uploading, this fixes it again.
pull/86/head
Jens Gutermuth 9 年之前
父節點
當前提交
deb04500c5
共有 1 個檔案被更改,包括 7 行新增4 行删除
  1. +7
    -4
      pinry/core/api.py

+ 7
- 4
pinry/core/api.py 查看文件

@@ -60,10 +60,13 @@ class UserResource(ModelResource):

def filter_generator_for(size):
def wrapped_func(bundle, **kwargs):
for thumbnail in bundle.obj._prefetched_objects_cache['thumbnail']:
if thumbnail.size == size:
return thumbnail
raise ObjectDoesNotExist()
if hasattr(bundle.obj, '_prefetched_objects_cache') and 'thumbnail' in bundle.obj._prefetched_objects_cache:
for thumbnail in bundle.obj._prefetched_objects_cache['thumbnail']:
if thumbnail.size == size:
return thumbnail
raise ObjectDoesNotExist()
else:
return bundle.obj.get_by_size(size)
return wrapped_func




Loading…
取消
儲存