From b43a6cf6473d1bed757719a19e8ab5664fc7c740 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 29 Jan 2013 07:19:57 +0530 Subject: [PATCH] double check if poster does not exist if it was created async --- pandora/annotation/models.py | 2 +- pandora/item/views.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/pandora/annotation/models.py b/pandora/annotation/models.py index 3933e6a8a..8385f80f3 100644 --- a/pandora/annotation/models.py +++ b/pandora/annotation/models.py @@ -19,7 +19,7 @@ from changelog.models import Changelog from item.utils import sort_string import managers import utils -from tasks import update_matches, update_matches, update_item +from tasks import update_matches, update_item def get_super_matches(obj, model): diff --git a/pandora/item/views.py b/pandora/item/views.py index b4c2e39f9..e1aa6b5de 100644 --- a/pandora/item/views.py +++ b/pandora/item/views.py @@ -708,6 +708,16 @@ def poster(request, id, size=None): item = get_object_or_404(models.Item, itemId=id) if not item.access(request.user): return HttpResponseForbidden() + if not item.poster: + poster_path = os.path.join(settings.MEDIA_ROOT, item.path('poster.jpg')) + if os.path.exists(poster_path): + item.poster.name = item.path('poster.jpg') + models.Item.objects.filter(pk=item.id).update( + poster=item.poster.name, + poster_height=item.poster.height, + poster_width=item.poster.width, + icon=item.icon.name + ) if item.poster: return image_to_response(item.poster, size) else: