Updated OCR models to use the identical source manager SourceTransformationManager

This commit is contained in:
Roberto Rosario
2011-07-25 03:41:28 -04:00
parent 5e4bb41f07
commit 055f64c1cf
2 changed files with 4 additions and 25 deletions
-22
View File
@@ -17,25 +17,3 @@ class DocumentQueueManager(models.Manager):
document_queue.queuedocument_set.create(document=document, delay=True)
return document_queue
class QueueTransformationManager(models.Manager):
def get_for_object(self, obj):
ct = ContentType.objects.get_for_model(obj)
return self.model.objects.filter(content_type=ct).filter(object_id=obj.pk)
def get_for_object_as_list(self, obj):
warnings = []
transformations = []
for transformation in self.get_for_object(obj).values('transformation', 'arguments'):
try:
transformations.append(
{
'transformation': transformation['transformation'],
'arguments': eval(transformation['arguments'], {})
}
)
except Exception, e:
warnings.append(e)
return transformations, warnings