double check if poster does not exist if it was created async
This commit is contained in:
parent
039f8c9335
commit
b43a6cf647
2 changed files with 11 additions and 1 deletions
|
@ -19,7 +19,7 @@ from changelog.models import Changelog
|
||||||
from item.utils import sort_string
|
from item.utils import sort_string
|
||||||
import managers
|
import managers
|
||||||
import utils
|
import utils
|
||||||
from tasks import update_matches, update_matches, update_item
|
from tasks import update_matches, update_item
|
||||||
|
|
||||||
|
|
||||||
def get_super_matches(obj, model):
|
def get_super_matches(obj, model):
|
||||||
|
|
|
@ -708,6 +708,16 @@ def poster(request, id, size=None):
|
||||||
item = get_object_or_404(models.Item, itemId=id)
|
item = get_object_or_404(models.Item, itemId=id)
|
||||||
if not item.access(request.user):
|
if not item.access(request.user):
|
||||||
return HttpResponseForbidden()
|
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:
|
if item.poster:
|
||||||
return image_to_response(item.poster, size)
|
return image_to_response(item.poster, size)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue