Add duplicated document scan support.
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -31,11 +31,13 @@ from rest_api.classes import APIEndPoint
|
||||
from rest_api.fields import DynamicSerializerField
|
||||
from statistics.classes import StatisticNamespace, CharJSLine
|
||||
|
||||
from .handlers import create_default_document_type
|
||||
from .handlers import (
|
||||
create_default_document_type, handler_scan_duplicates_for
|
||||
)
|
||||
from .links import (
|
||||
link_clear_image_cache, link_document_clear_transformations,
|
||||
link_document_clone_transformations, link_document_delete,
|
||||
link_document_document_type_edit,
|
||||
link_document_document_type_edit, link_document_duplicates_list,
|
||||
link_document_multiple_document_type_edit, link_document_download,
|
||||
link_document_edit, link_document_list, link_document_list_deleted,
|
||||
link_document_list_recent, link_document_multiple_delete,
|
||||
@@ -55,7 +57,8 @@ from .links import (
|
||||
link_document_type_filename_list, link_document_type_list,
|
||||
link_document_type_setup, link_document_update_page_count,
|
||||
link_document_version_download, link_document_version_list,
|
||||
link_document_version_revert, link_trash_can_empty
|
||||
link_document_version_revert, link_duplicated_document_list,
|
||||
link_duplicated_document_scan, link_trash_can_empty
|
||||
)
|
||||
from .literals import (
|
||||
CHECK_DELETE_PERIOD_INTERVAL, CHECK_TRASH_PERIOD_INTERVAL,
|
||||
@@ -73,6 +76,7 @@ from .permissions import (
|
||||
from .queues import * # NOQA
|
||||
# Just import to initialize the search models
|
||||
from .search import document_search, document_page_search # NOQA
|
||||
from .signals import post_version_upload
|
||||
from .statistics import (
|
||||
new_documents_per_month, new_document_pages_per_month,
|
||||
new_document_pages_this_month, new_documents_this_month,
|
||||
@@ -100,6 +104,7 @@ class DocumentsApp(MayanAppConfig):
|
||||
DocumentType = self.get_model('DocumentType')
|
||||
DocumentTypeFilename = self.get_model('DocumentTypeFilename')
|
||||
DocumentVersion = self.get_model('DocumentVersion')
|
||||
DuplicatedDocument = self.get_model('DuplicatedDocument')
|
||||
|
||||
DynamicSerializerField.add_serializer(
|
||||
klass=Document,
|
||||
@@ -271,6 +276,16 @@ class DocumentsApp(MayanAppConfig):
|
||||
source=DocumentVersion, label=_('Comment'),
|
||||
attribute='comment'
|
||||
)
|
||||
SourceColumn(
|
||||
source=DuplicatedDocument, label=_('Thumbnail'),
|
||||
func=lambda context: document_thumbnail_widget.render(
|
||||
instance=context['object'].document
|
||||
)
|
||||
)
|
||||
SourceColumn(
|
||||
source=DuplicatedDocument, label=_('Duplicates'),
|
||||
func=lambda context: context['object'].documents.count()
|
||||
)
|
||||
|
||||
app.conf.CELERYBEAT_SCHEDULE.update(
|
||||
{
|
||||
@@ -328,20 +343,28 @@ class DocumentsApp(MayanAppConfig):
|
||||
'documents.tasks.task_upload_new_version': {
|
||||
'queue': 'uploads'
|
||||
},
|
||||
'documents.tasks.task_scan_duplicates_all': {
|
||||
'queue': 'tools'
|
||||
},
|
||||
'documents.tasks.task_scan_duplicates_for': {
|
||||
'queue': 'uploads'
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
menu_documents.bind_links(
|
||||
links=(
|
||||
link_document_list_recent, link_document_list,
|
||||
link_document_list_deleted
|
||||
link_document_list_deleted, link_duplicated_document_list
|
||||
)
|
||||
)
|
||||
|
||||
menu_main.bind_links(links=(menu_documents,), position=0)
|
||||
|
||||
menu_setup.bind_links(links=(link_document_type_setup,))
|
||||
menu_tools.bind_links(links=(link_clear_image_cache,))
|
||||
menu_tools.bind_links(
|
||||
links=(link_clear_image_cache, link_duplicated_document_scan)
|
||||
)
|
||||
|
||||
# Document type links
|
||||
menu_object.bind_links(
|
||||
@@ -384,7 +407,7 @@ class DocumentsApp(MayanAppConfig):
|
||||
link_document_print, link_document_trash,
|
||||
link_document_download, link_document_clear_transformations,
|
||||
link_document_clone_transformations,
|
||||
link_document_update_page_count
|
||||
link_document_update_page_count,
|
||||
), sources=(Document,)
|
||||
)
|
||||
menu_object.bind_links(
|
||||
@@ -393,7 +416,10 @@ class DocumentsApp(MayanAppConfig):
|
||||
)
|
||||
|
||||
# Document facet links
|
||||
menu_facet.bind_links(links=(link_acl_list,), sources=(Document,))
|
||||
menu_facet.bind_links(
|
||||
links=(link_document_duplicates_list, link_acl_list,),
|
||||
sources=(Document,)
|
||||
)
|
||||
menu_facet.bind_links(
|
||||
links=(link_document_preview,), sources=(Document,), position=0
|
||||
)
|
||||
@@ -499,6 +525,10 @@ class DocumentsApp(MayanAppConfig):
|
||||
create_default_document_type,
|
||||
dispatch_uid='create_default_document_type'
|
||||
)
|
||||
post_version_upload.connect(
|
||||
handler_scan_duplicates_for,
|
||||
dispatch_uid='handler_scan_duplicates_for',
|
||||
)
|
||||
|
||||
registry.register(DeletedDocument)
|
||||
registry.register(Document)
|
||||
|
||||
Reference in New Issue
Block a user