Renamed DocumentMetadataindex model to DocumentIndex and moved it to it's own app
This commit is contained in:
0
apps/document_indexing/__init__.py
Normal file
0
apps/document_indexing/__init__.py
Normal file
23
apps/document_indexing/admin.py
Normal file
23
apps/document_indexing/admin.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
from document_indexing.models import DocumentIndex
|
||||||
|
|
||||||
|
#from filesystem_serving.admin import DocumentMetadataIndexInline
|
||||||
|
|
||||||
|
|
||||||
|
#class MetadataIndexInline(admin.StackedInline):
|
||||||
|
# model = MetadataIndex
|
||||||
|
# extra = 1
|
||||||
|
# classes = ('collapse-open',)
|
||||||
|
# allow_add = True
|
||||||
|
|
||||||
|
|
||||||
|
class DocumentIndexAdmin(admin.ModelAdmin):
|
||||||
|
pass
|
||||||
|
#inlines = [
|
||||||
|
# DocumentMetadataIndexInline,
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
admin.site.register(DocumentIndex, DocumentIndexAdmin)
|
||||||
0
apps/document_indexing/conf/__init__.py
Normal file
0
apps/document_indexing/conf/__init__.py
Normal file
22
apps/document_indexing/conf/settings.py
Normal file
22
apps/document_indexing/conf/settings.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
"""Configuration options for the document_indexing app"""
|
||||||
|
|
||||||
|
import hashlib
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
from common.utils import proper_name
|
||||||
|
from smart_settings.api import register_settings
|
||||||
|
|
||||||
|
available_indexing_functions = {
|
||||||
|
'proper_name': proper_name
|
||||||
|
}
|
||||||
|
|
||||||
|
register_settings(
|
||||||
|
namespace=u'document_indexing',
|
||||||
|
module=u'document_indexing.conf.settings',
|
||||||
|
settings=[
|
||||||
|
# Definition
|
||||||
|
{'name': u'AVAILABLE_INDEXING_FUNCTIONS', 'global_name': u'DOCUMENT_INDEXING_AVAILABLE_INDEXING_FUNCTIONS', 'default': available_indexing_functions},
|
||||||
|
]
|
||||||
|
)
|
||||||
20
apps/document_indexing/models.py
Normal file
20
apps/document_indexing/models.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
from django.db import models
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
from document_indexing.conf.settings import AVAILABLE_INDEXING_FUNCTIONS
|
||||||
|
|
||||||
|
available_indexing_functions_string = (_(u' Available functions: %s') % u','.join([u'%s()' % name for name, function in AVAILABLE_INDEXING_FUNCTIONS.items()])) if AVAILABLE_INDEXING_FUNCTIONS else u''
|
||||||
|
|
||||||
|
|
||||||
|
class DocumentIndex(models.Model):
|
||||||
|
expression = models.CharField(max_length=128,
|
||||||
|
verbose_name=_(u'indexing expression'),
|
||||||
|
help_text=_(u'Enter a python string expression to be evaluated. The slash caracter "/" acts as a directory delimiter.%s') % available_indexing_functions_string)
|
||||||
|
enabled = models.BooleanField(default=True, verbose_name=_(u'enabled'))
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
|
return unicode(self.expression)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
verbose_name = _(u'metadata index')
|
||||||
|
verbose_name_plural = _(u'metadata indexes')
|
||||||
23
apps/document_indexing/tests.py
Normal file
23
apps/document_indexing/tests.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
"""
|
||||||
|
This file demonstrates two different styles of tests (one doctest and one
|
||||||
|
unittest). These will both pass when you run "manage.py test".
|
||||||
|
|
||||||
|
Replace these with more appropriate tests for your application.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
class SimpleTest(TestCase):
|
||||||
|
def test_basic_addition(self):
|
||||||
|
"""
|
||||||
|
Tests that 1 + 1 always equals 2.
|
||||||
|
"""
|
||||||
|
self.failUnlessEqual(1 + 1, 2)
|
||||||
|
|
||||||
|
__test__ = {"doctest": """
|
||||||
|
Another way to test that 1 + 1 is equal to 2.
|
||||||
|
|
||||||
|
>>> 1 + 1 == 2
|
||||||
|
True
|
||||||
|
"""}
|
||||||
|
|
||||||
1
apps/document_indexing/views.py
Normal file
1
apps/document_indexing/views.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# Create your views here.
|
||||||
@@ -3,19 +3,12 @@ from django.contrib import admin
|
|||||||
from metadata.admin import DocumentMetadataInline
|
from metadata.admin import DocumentMetadataInline
|
||||||
|
|
||||||
from documents.models import DocumentType, Document, \
|
from documents.models import DocumentType, Document, \
|
||||||
DocumentTypeFilename, MetadataIndex, DocumentPage, \
|
DocumentTypeFilename, DocumentPage, \
|
||||||
DocumentPageTransformation, RecentDocument
|
DocumentPageTransformation, RecentDocument
|
||||||
|
|
||||||
from filesystem_serving.admin import DocumentMetadataIndexInline
|
from filesystem_serving.admin import DocumentMetadataIndexInline
|
||||||
|
|
||||||
|
|
||||||
class MetadataIndexInline(admin.StackedInline):
|
|
||||||
model = MetadataIndex
|
|
||||||
extra = 1
|
|
||||||
classes = ('collapse-open',)
|
|
||||||
allow_add = True
|
|
||||||
|
|
||||||
|
|
||||||
class DocumentTypeFilenameInline(admin.StackedInline):
|
class DocumentTypeFilenameInline(admin.StackedInline):
|
||||||
model = DocumentTypeFilename
|
model = DocumentTypeFilename
|
||||||
extra = 1
|
extra = 1
|
||||||
@@ -25,7 +18,7 @@ class DocumentTypeFilenameInline(admin.StackedInline):
|
|||||||
|
|
||||||
class DocumentTypeAdmin(admin.ModelAdmin):
|
class DocumentTypeAdmin(admin.ModelAdmin):
|
||||||
inlines = [
|
inlines = [
|
||||||
DocumentTypeFilenameInline, MetadataIndexInline
|
DocumentTypeFilenameInline
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ from converter.api import get_page_count
|
|||||||
from converter import TRANFORMATION_CHOICES
|
from converter import TRANFORMATION_CHOICES
|
||||||
from metadata.classes import MetadataObject
|
from metadata.classes import MetadataObject
|
||||||
|
|
||||||
from documents.conf.settings import AVAILABLE_INDEXING_FUNCTIONS
|
|
||||||
from documents.conf.settings import CHECKSUM_FUNCTION
|
from documents.conf.settings import CHECKSUM_FUNCTION
|
||||||
from documents.conf.settings import UUID_FUNCTION
|
from documents.conf.settings import UUID_FUNCTION
|
||||||
from documents.conf.settings import STORAGE_BACKEND
|
from documents.conf.settings import STORAGE_BACKEND
|
||||||
@@ -25,6 +24,9 @@ from documents.conf.settings import AVAILABLE_TRANSFORMATIONS
|
|||||||
from documents.conf.settings import DEFAULT_TRANSFORMATIONS
|
from documents.conf.settings import DEFAULT_TRANSFORMATIONS
|
||||||
from documents.conf.settings import RECENT_COUNT
|
from documents.conf.settings import RECENT_COUNT
|
||||||
|
|
||||||
|
available_transformations = ([(name, data['label']) for name, data in AVAILABLE_TRANSFORMATIONS.items()])
|
||||||
|
|
||||||
|
|
||||||
def get_filename_from_uuid(instance, filename):
|
def get_filename_from_uuid(instance, filename):
|
||||||
filename, extension = os.path.splitext(filename)
|
filename, extension = os.path.splitext(filename)
|
||||||
instance.file_filename = filename
|
instance.file_filename = filename
|
||||||
@@ -201,22 +203,6 @@ class Document(models.Model):
|
|||||||
|
|
||||||
page_transformation.save()
|
page_transformation.save()
|
||||||
|
|
||||||
available_indexing_functions_string = (_(u' Available functions: %s') % u','.join([u'%s()' % name for name, function in AVAILABLE_INDEXING_FUNCTIONS.items()])) if AVAILABLE_INDEXING_FUNCTIONS else u''
|
|
||||||
|
|
||||||
class MetadataIndex(models.Model):
|
|
||||||
document_type = models.ForeignKey(DocumentType, verbose_name=_(u'document type'))
|
|
||||||
expression = models.CharField(max_length=128,
|
|
||||||
verbose_name=_(u'indexing expression'),
|
|
||||||
help_text=_(u'Enter a python string expression to be evaluated. The slash caracter "/" acts as a directory delimiter.%s') % available_indexing_functions_string)
|
|
||||||
enabled = models.BooleanField(default=True, verbose_name=_(u'enabled'))
|
|
||||||
|
|
||||||
def __unicode__(self):
|
|
||||||
return unicode(self.expression)
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
verbose_name = _(u'metadata index')
|
|
||||||
verbose_name_plural = _(u'metadata indexes')
|
|
||||||
|
|
||||||
|
|
||||||
class DocumentTypeFilename(models.Model):
|
class DocumentTypeFilename(models.Model):
|
||||||
"""
|
"""
|
||||||
@@ -272,11 +258,6 @@ class DocumentPage(models.Model):
|
|||||||
return ' '.join(transformation_list), warnings
|
return ' '.join(transformation_list), warnings
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
available_transformations = ([(name, data['label']) for name, data in AVAILABLE_TRANSFORMATIONS.items()])
|
|
||||||
|
|
||||||
|
|
||||||
class DocumentPageTransformation(models.Model):
|
class DocumentPageTransformation(models.Model):
|
||||||
document_page = models.ForeignKey(DocumentPage, verbose_name=_(u'document page'))
|
document_page = models.ForeignKey(DocumentPage, verbose_name=_(u'document page'))
|
||||||
order = models.PositiveIntegerField(default=0, blank=True, null=True, verbose_name=_(u'order'), db_index=True)
|
order = models.PositiveIntegerField(default=0, blank=True, null=True, verbose_name=_(u'order'), db_index=True)
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from documents.models import Document, MetadataIndex
|
from documents.models import Document
|
||||||
|
from document_indexing.models import DocumentIndex
|
||||||
|
|
||||||
|
|
||||||
class DocumentMetadataIndex(models.Model):
|
class DocumentMetadataIndex(models.Model):
|
||||||
document = models.ForeignKey(Document, verbose_name=_(u'document'))
|
document = models.ForeignKey(Document, verbose_name=_(u'document'))
|
||||||
metadata_index = models.ForeignKey(MetadataIndex, verbose_name=_(u'metadata index'))
|
metadata_index = models.ForeignKey(DocumentIndex, verbose_name=_(u'document index'))
|
||||||
filename = models.CharField(max_length=255, verbose_name=_(u'filename'))
|
filename = models.CharField(max_length=255, verbose_name=_(u'filename'))
|
||||||
suffix = models.PositiveIntegerField(default=0, verbose_name=_(u'suffix'))
|
suffix = models.PositiveIntegerField(default=0, verbose_name=_(u'suffix'))
|
||||||
|
|
||||||
|
|||||||
@@ -147,6 +147,7 @@ INSTALLED_APPS = (
|
|||||||
'user_management',
|
'user_management',
|
||||||
'documents',
|
'documents',
|
||||||
'grouping',
|
'grouping',
|
||||||
|
'document_indexing',
|
||||||
)
|
)
|
||||||
|
|
||||||
TEMPLATE_CONTEXT_PROCESSORS = (
|
TEMPLATE_CONTEXT_PROCESSORS = (
|
||||||
@@ -181,10 +182,9 @@ TEMPLATE_CONTEXT_PROCESSORS = (
|
|||||||
#---------- Metadata -----------------
|
#---------- Metadata -----------------
|
||||||
# METADATA_AVAILABLE_FUNCTIONS = {}
|
# METADATA_AVAILABLE_FUNCTIONS = {}
|
||||||
# METADATA_AVAILABLE_MODELS = {}
|
# METADATA_AVAILABLE_MODELS = {}
|
||||||
|
#---------- Indexing -----------------
|
||||||
|
#DOCUMENT_INDEXING_AVAILABLE_INDEXING_FUNCTIONS = {}
|
||||||
#---------- Documents ------------------
|
#---------- Documents ------------------
|
||||||
# Definition
|
|
||||||
#DOCUMENTS_INDEXING_AVAILABLE_FUNCTIONS = {}
|
|
||||||
|
|
||||||
# Upload
|
# Upload
|
||||||
#DOCUMENTS_USE_STAGING_DIRECTORY = False
|
#DOCUMENTS_USE_STAGING_DIRECTORY = False
|
||||||
#DOCUMENTS_STAGING_DIRECTORY = u'/tmp/mayan/staging'
|
#DOCUMENTS_STAGING_DIRECTORY = u'/tmp/mayan/staging'
|
||||||
|
|||||||
Reference in New Issue
Block a user