'famfam': 'tab', 'view': 'index_list', 'children_view_regex': [r'^index_[i,l]'] }) rebuild_index_instances = { 'text': _('rebuild indexes'), 'view': 'rebuild_index_instances', 'famfam': 'folder_page', 'permissions': [PERMISSION_DOCUMENT_INDEXING_REBUILD_INDEXES], 'description': _(u'Deletes and creates from scratch all the document indexes.') } register_maintenance_links([rebuild_index_instances], namespace='document_indexing', title=_(u'Indexes')) register_sidebar_template(['index_instance_list'], 'indexing_help.html') register_links(IndexInstanceNode, [index_parent]) register_links(Document, [document_index_list], menu_name='form_header') register_setup(index_setup) register_links([ Index, 'index_setup_list', 'index_setup_create', 'template_node_edit', 'template_node_delete' ], [index_setup_list, index_setup_create], menu_name='secondary_menu')
link_entry_delete_multiple, link_entry_list, link_entry_re_queue, link_entry_re_queue_multiple ) from .models import DocumentVersionOCRError from .permissions import PERMISSION_OCR_DOCUMENT from .tasks import task_do_ocr logger = logging.getLogger(__name__) register_links(Document, [link_document_submit]) register_links([Document], [link_document_submit_multiple, link_spacer], menu_name='multi_item_links') register_links([DocumentVersionOCRError], [link_entry_re_queue_multiple, link_entry_delete_multiple], menu_name='multi_item_links') register_links([DocumentVersionOCRError], [link_entry_re_queue, link_entry_delete]) register_links(['ocr:entry_list', 'ocr:entry_delete_multiple', 'ocr:entry_re_queue_multiple', DocumentVersionOCRError], [link_entry_list], menu_name='secondary_menu') register_maintenance_links([link_document_all_ocr_cleanup], namespace='ocr', title=_('OCR')) def document_ocr_submit(self): task_do_ocr.apply_async(args=[self.latest_version.pk], queue='ocr') def document_version_ocr_submit(self): task_do_ocr.apply_async(args=[self.pk], queue='ocr') @receiver(post_version_upload, dispatch_uid='post_version_upload_ocr', sender=DocumentVersion) def post_version_upload_ocr(sender, instance, **kwargs): logger.debug('received post_version_upload') logger.debug('instance pk: %s', instance.pk) if instance.document.document_type.ocr:
register_links('document_page_transformation_list', [document_page_transformation_create], menu_name='sidebar') register_links('document_page_transformation_create', [document_page_transformation_create], menu_name='sidebar') register_links([ 'document_page_transformation_edit', 'document_page_transformation_delete' ], [document_page_transformation_create], menu_name='sidebar') register_diagnostic('documents', _(u'Documents'), document_missing_list) register_maintenance_links([ document_find_all_duplicates, document_update_page_count, document_clear_image_cache ], namespace='documents', title=_(u'documents')) register_model_list_columns(Document, [ { 'name': _(u'thumbnail'), 'attribute': encapsulate( lambda x: document_thumbnail(x, gallery_name='document_list', title=getattr(x, 'filename', None), size=THUMBNAIL_SIZE)) }, ])
# Document page navigation links register_links(DocumentPage, [ document_page_navigation_first, document_page_navigation_previous, document_page_navigation_next, document_page_navigation_last ], menu_name='related') register_links(['document_page_view'], [document_page_rotate_left, document_page_rotate_right, document_page_zoom_in, document_page_zoom_out, document_page_view_reset], menu_name='form_header') register_links(DocumentPageTransformation, [document_page_transformation_edit, document_page_transformation_delete]) register_links('document_page_transformation_list', [document_page_transformation_create], menu_name='sidebar') register_links('document_page_transformation_create', [document_page_transformation_create], menu_name='sidebar') register_links(['document_page_transformation_edit', 'document_page_transformation_delete'], [document_page_transformation_create], menu_name='sidebar') register_diagnostic('documents', _(u'Documents'), document_missing_list) register_maintenance_links([document_find_all_duplicates, document_update_page_count, document_clear_image_cache], namespace='documents', title=_(u'documents')) register_model_list_columns(Document, [ {'name': _(u'thumbnail'), 'attribute': encapsulate(lambda x: document_thumbnail(x, gallery_name='document_list', title=x.filename, size=THUMBNAIL_SIZE)) }, ]) register_top_menu( 'documents', link={'famfam': 'page', 'text': _(u'documents'), 'view': 'document_list_recent'}, children_path_regex=[ r'^documents/[^t]', r'^metadata/[^s]', r'comments', r'tags/document', r'grouping/[^s]', r'history/list/for_object/documents', ], children_view_regex=[r'document_acl', r'smart_link_instance'], children_views=['document_folder_list', 'folder_add_document', 'document_index_list', 'upload_version', ],
register_links([ 'setup_queue_transformation_create', 'setup_queue_transformation_edit', 'setup_queue_transformation_delete', 'document_queue_disable', 'document_queue_enable', 'queue_document_list', 'node_active_list', 'setup_queue_transformation_list' ], [queue_document_list, node_active_list], menu_name='secondary_menu') register_links([ 'setup_queue_transformation_edit', 'setup_queue_transformation_delete', 'setup_queue_transformation_list', 'setup_queue_transformation_create' ], [setup_queue_transformation_create], menu_name='sidebar') register_maintenance_links([all_document_ocr_cleanup], namespace='ocr', title=_(u'OCR')) @transaction.commit_manually def create_default_queue(): try: default_queue, created = DocumentQueue.objects.get_or_create( name='default') if created: default_queue.label = ugettext(u'Default') default_queue.save() except DatabaseError: transaction.rollback() # Special case for ./manage.py syncdb except (OperationalError, ImproperlyConfigured):
index_setup_view = {'text': _(u'tree template'), 'view': 'index_setup_view', 'args': 'index.pk', 'famfam': 'textfield', 'permissions': [PERMISSION_DOCUMENT_INDEXING_SETUP]} template_node_create = {'text': _(u'new child node'), 'view': 'template_node_create', 'args': 'node.pk', 'famfam': 'textfield_add', 'permissions': [PERMISSION_DOCUMENT_INDEXING_SETUP]} template_node_edit = {'text': _(u'edit'), 'view': 'template_node_edit', 'args': 'node.pk', 'famfam': 'textfield', 'permissions': [PERMISSION_DOCUMENT_INDEXING_SETUP], 'conditional_disable': is_root_node} template_node_delete = {'text': _(u'delete'), 'view': 'template_node_delete', 'args': 'node.pk', 'famfam': 'textfield_delete', 'permissions': [PERMISSION_DOCUMENT_INDEXING_SETUP], 'conditional_disable': is_root_node} index_list = {'text': _(u'index list'), 'view': 'index_list', 'famfam': 'tab', 'permissions': [PERMISSION_DOCUMENT_INDEXING_VIEW]} index_parent = {'text': _(u'go up one level'), 'view': 'index_instance_node_view', 'args': 'object.parent.pk', 'famfam': 'arrow_up', 'permissions': [PERMISSION_DOCUMENT_INDEXING_VIEW], 'dont_mark_active': True, 'condition': is_not_instance_root_node} document_index_list = {'text': _(u'indexes'), 'view': 'document_index_list', 'args': 'object.pk', 'famfam': 'folder_page', 'permissions': [PERMISSION_DOCUMENT_INDEXING_VIEW, PERMISSION_DOCUMENT_VIEW]} register_top_menu('indexes', link={'text': _('indexes'), 'famfam': 'tab', 'view': 'index_list', 'children_view_regex': [r'^index_[i,l]']}) rebuild_index_instances = {'text': _('rebuild indexes'), 'view': 'rebuild_index_instances', 'famfam': 'folder_page', 'permissions': [PERMISSION_DOCUMENT_INDEXING_REBUILD_INDEXES], 'description': _(u'Deletes and creates from scratch all the document indexes.')} register_maintenance_links([rebuild_index_instances], namespace='document_indexing', title=_(u'Indexes')) register_sidebar_template(['index_instance_list'], 'indexing_help.html') register_links(IndexInstanceNode, [index_parent]) register_links(Document, [document_index_list], menu_name='form_header') register_setup(index_setup) register_links([Index, 'index_setup_list', 'index_setup_create', 'template_node_edit', 'template_node_delete'], [index_setup_list, index_setup_create], menu_name='secondary_menu') register_links(Index, [index_setup_edit, index_setup_delete, index_setup_view]) register_links(IndexTemplateNode, [template_node_create, template_node_edit, template_node_delete])
document_page_text, document_page_edit, ]) # Document page navigation links register_links(DocumentPage, [ document_page_navigation_first, document_page_navigation_previous, document_page_navigation_next, document_page_navigation_last ], menu_name='sidebar') register_links(['documents:document_page_view'], [document_page_rotate_left, document_page_rotate_right, document_page_zoom_in, document_page_zoom_out, document_page_view_reset], menu_name='form_header') register_links(DocumentPageTransformation, [document_page_transformation_edit, document_page_transformation_delete]) register_links('documents:document_page_transformation_list', [document_page_transformation_create], menu_name='sidebar') register_links('documents:document_page_transformation_create', [document_page_transformation_create], menu_name='sidebar') register_links(['documents:document_page_transformation_edit', 'documents:document_page_transformation_delete'], [document_page_transformation_create], menu_name='sidebar') register_maintenance_links([document_clear_image_cache], namespace='documents', title=_('Documents')) register_model_list_columns(Document, [ { 'name': _('Thumbnail'), 'attribute': encapsulate(lambda x: document_thumbnail(x, gallery_name='documents:document_list', title=getattr(x, 'filename', None), size=THUMBNAIL_SIZE)) }, { 'name': _('Type'), 'attribute': 'document_type' } ]) if (not validate_path(document_settings.CACHE_PATH)) or (not document_settings.CACHE_PATH): setattr(document_settings, 'CACHE_PATH', tempfile.mkdtemp()) register_setup(document_type_setup)
], [queue_document_list], menu_name="secondary_menu", ) register_links( [ "setup_queue_transformation_edit", "setup_queue_transformation_delete", "setup_queue_transformation_list", "setup_queue_transformation_create", ], [setup_queue_transformation_create], menu_name="sidebar", ) register_maintenance_links([all_document_ocr_cleanup], namespace="ocr", title=_(u"OCR")) @transaction.commit_on_success def create_default_queue(): try: default_queue, created = DocumentQueue.objects.get_or_create(name="default") except DatabaseError: transaction.rollback() else: if created: default_queue.label = ugettext(u"Default") default_queue.save() @receiver(post_save, dispatch_uid="document_post_save", sender=DocumentVersion)
"args": "object.parent.pk", "famfam": "arrow_up", "permissions": [PERMISSION_DOCUMENT_INDEXING_VIEW], "dont_mark_active": True, } document_index_list = { "text": _(u"indexes"), "view": "document_index_list", "args": "object.pk", "famfam": "folder_page", "permissions": [PERMISSION_DOCUMENT_INDEXING_VIEW, PERMISSION_DOCUMENT_VIEW], } register_top_menu("indexes", link={"text": _("indexes"), "famfam": "folder_page", "view": "index_instance_list"}) rebuild_index_instances = { "text": _("rebuild indexes"), "view": "rebuild_index_instances", "famfam": "folder_page", "permissions": [PERMISSION_DOCUMENT_INDEXING_REBUILD_INDEXES], "description": _(u"Deletes and creates from scratch all the document indexes."), } register_maintenance_links([rebuild_index_instances], namespace="document_indexing", title=_(u"Indexes")) register_sidebar_template(["index_instance_list"], "indexing_help.html") register_links(IndexInstance, [index_parent]) register_links(Document, [document_index_list], menu_name="form_header")