From 33089ccd0873cfd5e8699b1b3579540167050b5a Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Wed, 16 Mar 2011 16:37:30 -0400 Subject: [PATCH] Don't display an error for the thumbnail of non existant documents --- apps/ocr/views.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/ocr/views.py b/apps/ocr/views.py index 13217fbd65..fe85832ac3 100644 --- a/apps/ocr/views.py +++ b/apps/ocr/views.py @@ -22,6 +22,15 @@ from literals import QUEUEDOCUMENT_STATE_PENDING, \ from exceptions import AlreadyQueued +def _display_thumbnail(ocr_document): + try: + preview_url = reverse('document_preview', args=[ocr_document.document.pk]) + thumbnail_url = reverse('document_thumbnail', args=[ocr_document.document.pk]) + return u'' % (preview_url, thumbnail_url) + except: + return u'' + + def queue_document_list(request, queue_name='default'): check_permissions(request.user, 'ocr', [PERMISSION_OCR_DOCUMENT]) @@ -38,10 +47,7 @@ def queue_document_list(request, queue_name='default'): 'object_name':_(u'document queue'), 'extra_columns':[ {'name':'document', 'attribute': lambda x: '%s' % (x.document.get_absolute_url(), x.document) if hasattr(x, 'document') else _(u'Missing document.')}, - {'name':_(u'thumbnail'), 'attribute': - lambda x: '' % (reverse('document_preview', args=[x.document.id]), - reverse('document_thumbnail', args=[x.document.id])) - }, + {'name':_(u'thumbnail'), 'attribute': lambda x: _display_thumbnail(x) }, {'name':'submitted', 'attribute': lambda x: unicode(x.datetime_submitted).split('.')[0], 'keep_together':True}, {'name':'state', 'attribute': lambda x: x.get_state_display()}, {'name':'result', 'attribute':'result'},