Add natural key support to the document parsing app.
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import logging
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
from django.apps import apps
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
|
||||
@@ -48,3 +49,16 @@ class DocumentPageContentManager(models.Manager):
|
||||
action_object=document_version.document,
|
||||
target=document_version
|
||||
)
|
||||
|
||||
|
||||
class DocumentTypeSettingsManager(models.Manager):
|
||||
def get_by_natural_key(self, document_type_natural_key):
|
||||
DocumentType = apps.get_model(
|
||||
app_label='documents', model_name='DocumentType'
|
||||
)
|
||||
try:
|
||||
document_type = DocumentType.objects.get_by_natural_key(document_type_natural_key)
|
||||
except DocumentType.DoesNotExist:
|
||||
raise self.model.DoesNotExist
|
||||
|
||||
return self.get(document_type__pk=document_type.pk)
|
||||
|
||||
Reference in New Issue
Block a user