Catch missing documents from the ocr queue list and display a message accordingly.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
|
||||
from documents.models import Document
|
||||
|
||||
@@ -51,4 +53,7 @@ class QueueDocument(models.Model):
|
||||
verbose_name_plural = _(u'queue documents')
|
||||
|
||||
def __unicode__(self):
|
||||
return unicode(self.document)
|
||||
try:
|
||||
return unicode(self.document)
|
||||
except ObjectDoesNotExist:
|
||||
return ugettext(u'Missing document.')
|
||||
|
||||
@@ -35,7 +35,7 @@ def queue_document_list(request, queue_name='default'):
|
||||
'title':_(u'queued documents'),
|
||||
'hide_object':True,
|
||||
'extra_columns':[
|
||||
{'name':'document', 'attribute': 'document'},
|
||||
{'name':'document', 'attribute': lambda x: x.document if hasattr(x, 'document') else _(u'Missing document.')},
|
||||
{'name':'submitted', 'attribute': lambda x: unicode(x.datetime_submitted).split('.')[0]},
|
||||
{'name':'state', 'attribute': lambda x: x.get_state_display()},
|
||||
{'name':'result', 'attribute':'result'},
|
||||
|
||||
Reference in New Issue
Block a user