def __init__(self, *args, **kwargs): super(SmartLinkConditionForm, self).__init__(*args, **kwargs) self.fields['foreign_document_data'] = forms.ChoiceField( choices=ModelField.get_choices_for(model=Document, ), label=_('Foreign document field')) self.fields['expression'] = TemplateField( initial_help_text=self.fields['expression'].help_text, label=self.fields['expression'].label, model=Document, model_variable='document', required=False)
def __init__(self, *args, **kwargs): super(SmartLinkConditionForm, self).__init__(*args, **kwargs) self.fields['foreign_document_data'] = forms.ChoiceField( choices=ModelField.get_choices_for(model=Document, ), label=_('Foreign document field')) self.fields['expression'].help_text = ' '.join([ force_text(self.fields['expression'].help_text), ModelProperty.get_help_text_for(model=Document, show_name=True).replace( '\n', '<br>') ])
def ready(self): super(TagsApp, self).ready() from actstream import registry from .wizard_steps import WizardStepTags # NOQA Document = apps.get_model(app_label='documents', model_name='Document') DocumentPageResult = apps.get_model(app_label='documents', model_name='DocumentPageResult') DocumentTag = self.get_model(model_name='DocumentTag') Tag = self.get_model(model_name='Tag') Document.add_to_class(name='get_tags', value=method_document_get_tags) ModelEventType.register(model=Tag, event_types=(event_tag_attach, event_tag_edited, event_tag_remove)) ModelField(model=Document, name='tags__label') ModelField(model=Document, name='tags__color') ModelPermission.register(model=Document, permissions=(permission_tag_attach, permission_tag_remove, permission_tag_view)) ModelPermission.register(model=Tag, permissions=( permission_acl_edit, permission_acl_view, permission_events_view, permission_tag_attach, permission_tag_delete, permission_tag_edit, permission_tag_remove, permission_tag_view, )) SourceColumn(attribute='label', is_identifier=True, is_sortable=True, source=DocumentTag) SourceColumn(attribute='get_preview_widget', source=DocumentTag) SourceColumn( source=Document, label=_('Tags'), func=lambda context: widget_document_tags( document=context['object'], user=context['request'].user)) SourceColumn(source=DocumentPageResult, label=_('Tags'), func=lambda context: widget_document_tags( document=context['object'].document, user=context['request'].user)) SourceColumn(attribute='label', is_identifier=True, is_sortable=True, source=Tag) SourceColumn(attribute='get_preview_widget', source=Tag) SourceColumn(source=Tag, label=_('Documents'), func=lambda context: context['object'].get_document_count( user=context['request'].user)) document_page_search.add_model_field( field='document_version__document__tags__label', label=_('Tags')) document_search.add_model_field(field='tags__label', label=_('Tags')) menu_facet.bind_links(links=(link_document_tag_list, ), sources=(Document, )) menu_list_facet.bind_links(links=( link_acl_list, link_events_for_object, link_object_event_types_user_subcriptions_list, link_tag_document_list, ), sources=(Tag, )) menu_tags.bind_links(links=(link_tag_list, link_tag_create)) menu_main.bind_links(links=(menu_tags, ), position=98) menu_multi_item.bind_links( links=(link_document_multiple_attach_multiple_tag, link_document_multiple_tag_multiple_remove), sources=(Document, )) menu_multi_item.bind_links(links=(link_tag_multiple_delete, ), sources=(Tag, )) menu_object.bind_links(links=(link_tag_edit, link_tag_delete), sources=(Tag, )) menu_secondary.bind_links( links=(link_document_tag_multiple_attach, link_document_tag_multiple_remove), sources=('tags:tag_attach', 'tags:document_tag_list', 'tags:single_document_multiple_tag_remove')) registry.register(Tag) # Index update m2m_changed.connect(dispatch_uid='tags_handler_index_document', receiver=handler_index_document, sender=Tag.documents.through) pre_delete.connect(dispatch_uid='tags_handler_tag_pre_delete', receiver=handler_tag_pre_delete, sender=Tag)
def ready(self): super(OCRApp, self).ready() Document = apps.get_model(app_label='documents', model_name='Document') DocumentPage = apps.get_model(app_label='documents', model_name='DocumentPage') DocumentType = apps.get_model(app_label='documents', model_name='DocumentType') DocumentTypeSettings = self.get_model( model_name='DocumentTypeSettings') DocumentVersion = apps.get_model(app_label='documents', model_name='DocumentVersion') DocumentVersionOCRError = self.get_model( model_name='DocumentVersionOCRError') Document.add_to_class(name='submit_for_ocr', value=method_document_ocr_submit) DocumentVersion.add_to_class(name='ocr_content', value=get_document_ocr_content) DocumentVersion.add_to_class(name='submit_for_ocr', value=method_document_version_ocr_submit) ModelEventType.register( model=Document, event_types=(event_ocr_document_content_deleted, event_ocr_document_version_finish, event_ocr_document_version_submit)) ModelField(model=Document, name='versions__version_pages__ocr_content__content') ModelPermission.register(model=Document, permissions=(permission_ocr_document, permission_ocr_content_view)) ModelPermission.register( model=DocumentType, permissions=(permission_document_type_ocr_setup, )) ModelPermission.register_inheritance( model=DocumentTypeSettings, related='document_type', ) SourceColumn(attribute='document_version__document', is_attribute_absolute_url=True, is_identifier=True, is_sortable=True, source=DocumentVersionOCRError) SourceColumn(attribute='datetime_submitted', is_sortable=True, label=_('Date and time'), source=DocumentVersionOCRError) SourceColumn(source=DocumentVersionOCRError, label=_('Result'), attribute='result') document_search.add_model_field( field='versions__version_pages__ocr_content__content', label=_('OCR')) document_page_search.add_model_field(field='ocr_content__content', label=_('OCR')) menu_facet.bind_links(links=(link_document_ocr_content, ), sources=(Document, )) menu_list_facet.bind_links(links=(link_document_page_ocr_content, ), sources=(DocumentPage, )) menu_list_facet.bind_links(links=(link_document_type_ocr_settings, ), sources=(DocumentType, )) menu_multi_item.bind_links(links=( link_document_ocr_content_delete_multiple, link_document_submit_multiple, ), sources=(Document, )) menu_secondary.bind_links(links=(link_document_ocr_content_delete, link_document_ocr_errors_list, link_document_ocr_download, link_document_submit), sources=( 'ocr:document_ocr_content_delete', 'ocr:document_ocr_content', 'ocr:document_ocr_download', 'ocr:document_ocr_error_list', 'ocr:document_submit', )) menu_secondary.bind_links( links=(link_entry_list, ), sources=('ocr:entry_list', 'ocr:entry_delete_multiple', 'ocr:entry_re_queue_multiple', DocumentVersionOCRError)) menu_tools.bind_links(links=(link_document_type_submit, link_entry_list)) post_document_version_ocr.connect( dispatch_uid='ocr_handler_index_document', receiver=handler_index_document_version, sender=DocumentVersion) post_save.connect( dispatch_uid='ocr_handler_initialize_new_ocr_settings', receiver=handler_initialize_new_ocr_settings, sender=DocumentType) post_version_upload.connect( dispatch_uid='ocr_handler_ocr_document_version', receiver=handler_ocr_document_version, sender=DocumentVersion)
def ready(self): super(DocumentsApp, self).ready() from actstream import registry DeletedDocument = self.get_model(model_name='DeletedDocument') Document = self.get_model(model_name='Document') DocumentPage = self.get_model(model_name='DocumentPage') DocumentPageResult = self.get_model(model_name='DocumentPageResult') DocumentType = self.get_model(model_name='DocumentType') DocumentTypeFilename = self.get_model( model_name='DocumentTypeFilename') DocumentVersion = self.get_model(model_name='DocumentVersion') DuplicatedDocument = self.get_model(model_name='DuplicatedDocument') DynamicSerializerField.add_serializer( klass=Document, serializer_class= 'mayan.apps.documents.serializers.DocumentSerializer') MissingItem( label=_('Create a document type'), description=_( 'Every uploaded document must be assigned a document type, ' 'it is the basic way Mayan EDMS categorizes documents.'), condition=lambda: not DocumentType.objects.exists(), view='documents:document_type_list') ModelEventType.register(model=DocumentType, event_types=( event_document_create, event_document_type_created, event_document_type_edited, )) ModelEventType.register(model=Document, event_types=(event_document_download, event_document_properties_edit, event_document_type_changed, event_document_version_new, event_document_version_revert, event_document_view)) ModelField(model=Document, name='description') ModelField(model=Document, name='date_added') ModelField(model=Document, name='deleted_date_time') ModelField(model=Document, name='document_type') ModelField(model=Document, name='in_trash') ModelField(model=Document, name='is_stub') ModelField(model=Document, name='label') ModelField(model=Document, name='language') ModelField(model=Document, name='uuid') ModelFieldRelated(model=Document, name='document_type__label') ModelFieldRelated(model=Document, name='versions__checksum') ModelFieldRelated(model=Document, label=_('Versions comment'), name='versions__comment') ModelFieldRelated(model=Document, label=_('Versions encoding'), name='versions__encoding') ModelFieldRelated(model=Document, label=_('Versions mime type'), name='versions__mimetype') ModelFieldRelated(model=Document, label=_('Versions timestamp'), name='versions__timestamp') ModelProperty( description=_('Return the lastest version of the document.'), model=Document, label=_('Latest version'), name='latest_version') ModelPermission.register(model=Document, permissions=( permission_acl_edit, permission_acl_view, permission_document_delete, permission_document_download, permission_document_edit, permission_document_new_version, permission_document_print, permission_document_properties_edit, permission_document_restore, permission_document_tools, permission_document_trash, permission_document_version_revert, permission_document_version_view, permission_document_view, permission_events_view, permission_transformation_create, permission_transformation_delete, permission_transformation_edit, permission_transformation_view, )) ModelPermission.register(model=DocumentType, permissions=( permission_document_create, permission_document_type_delete, permission_document_type_edit, permission_document_type_view, permission_acl_edit, permission_acl_view, permission_events_view, )) ModelPermission.register_inheritance( model=Document, related='document_type', ) ModelPermission.register_manager(model=Document, manager_name='passthrough') ModelPermission.register_inheritance( model=DocumentPage, related='document_version__document', ) ModelPermission.register_manager(model=DocumentPage, manager_name='passthrough') ModelPermission.register_inheritance( model=DocumentPageResult, related='document_version__document', ) ModelPermission.register_manager(model=DocumentPageResult, manager_name='passthrough') ModelPermission.register_inheritance( model=DocumentTypeFilename, related='document_type', ) ModelPermission.register_inheritance( model=DocumentVersion, related='document', ) # Document and document page thumbnail widget document_page_thumbnail_widget = DocumentPageThumbnailWidget() # Document SourceColumn(attribute='label', is_object_absolute_url=True, is_identifier=True, is_sortable=True, source=Document) SourceColumn(func=lambda context: document_page_thumbnail_widget. render(instance=context['object']), html_extra_classes='text-center document-thumbnail-list', label=_('Thumbnail'), source=Document) SourceColumn( attribute='document_type', is_sortable=True, source=Document, ) SourceColumn(func=lambda context: widget_document_page_number( document=context['object']), label=_('Pages'), source=Document) SourceColumn(attribute='date_added', include_label=True, is_sortable=True, source=Document, views=('documents:document_list_recent_added', )) SourceColumn(func=lambda context: DuplicatedDocument.objects.get( document=context['object']).documents.count(), include_label=True, label=_('Duplicates'), source=Document, views=('documents:duplicated_document_list', )) # DocumentPage SourceColumn(attribute='get_label', is_identifier=True, is_object_absolute_url=True, source=DocumentPage, widget_condition=is_document_page_enabled) SourceColumn(func=lambda context: document_page_thumbnail_widget. render(instance=context['object']), html_extra_classes='text-center document-thumbnail-list', label=_('Thumbnail'), source=DocumentPage) SourceColumn(attribute='enabled', include_label=True, source=DocumentPage, widget=TwoStateWidget) SourceColumn(attribute='page_number', include_label=True, source=DocumentPage) SourceColumn(attribute='get_label', is_identifier=True, is_object_absolute_url=True, source=DocumentPageResult) SourceColumn(func=lambda context: document_page_thumbnail_widget. render(instance=context['object']), html_extra_classes='text-center document-thumbnail-list', label=_('Thumbnail'), source=DocumentPageResult) SourceColumn(attribute='document_version.document.document_type', label=_('Type'), source=DocumentPageResult) # DocumentType SourceColumn(attribute='label', is_identifier=True, is_sortable=True, source=DocumentType) SourceColumn(func=lambda context: context['object'].get_document_count( user=context['request'].user), include_label=True, label=_('Documents'), source=DocumentType) SourceColumn(attribute='filename', is_identifier=True, is_sortable=True, source=DocumentTypeFilename) SourceColumn(attribute='enabled', include_label=True, is_sortable=True, source=DocumentTypeFilename, widget=TwoStateWidget) # DeletedDocument SourceColumn(attribute='label', is_identifier=True, is_sortable=True, source=DeletedDocument) SourceColumn(attribute='deleted_date_time', include_label=True, order=99, source=DeletedDocument) # DocumentVersion SourceColumn(source=DocumentVersion, attribute='timestamp', is_identifier=True, is_object_absolute_url=True) SourceColumn(func=lambda context: document_page_thumbnail_widget. render(instance=context['object']), html_extra_classes='text-center document-thumbnail-list', label=_('Thumbnail'), source=DocumentVersion) SourceColumn(func=lambda context: widget_document_version_page_number( document_version=context['object']), label=_('Pages'), source=DocumentVersion) SourceColumn(attribute='mimetype', is_sortable=True, source=DocumentVersion) SourceColumn(attribute='encoding', is_sortable=True, source=DocumentVersion) SourceColumn(attribute='comment', is_sortable=True, source=DocumentVersion) Template(name='invalid_document', template_name='documents/invalid_document.html') dashboard_main.add_widget(widget=DashboardWidgetDocumentsTotal, order=0) dashboard_main.add_widget(widget=DashboardWidgetDocumentPagesTotal, order=1) dashboard_main.add_widget(widget=DashboardWidgetDocumentsInTrash, order=2) dashboard_main.add_widget(widget=DashboardWidgetDocumentsTypesTotal, order=3) dashboard_main.add_widget(widget=DashboardWidgetDocumentsNewThisMonth, order=4) dashboard_main.add_widget( widget=DashboardWidgetDocumentsPagesNewThisMonth, order=5) menu_documents.bind_links(links=( link_document_list_recent_access, link_document_list_recent_added, link_document_list_favorites, link_document_list, 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_duplicated_document_scan, )) # Document type links menu_list_facet.bind_links(links=( link_document_type_filename_list, link_document_type_policies, link_acl_list, link_object_event_types_user_subcriptions_list, link_events_for_object, ), sources=(DocumentType, )) menu_object.bind_links(links=(link_document_type_delete, link_document_type_edit), sources=(DocumentType, )) menu_object.bind_links(links=(link_document_type_filename_edit, link_document_type_filename_delete), sources=(DocumentTypeFilename, )) menu_secondary.bind_links(links=(link_document_type_list, link_document_type_create), sources=(DocumentType, 'documents:document_type_create', 'documents:document_type_list')) menu_secondary.bind_links( links=(link_document_type_filename_create, ), sources=(DocumentTypeFilename, 'documents:document_type_filename_list', 'documents:document_type_filename_create')) menu_secondary.bind_links(links=(link_trash_can_empty, ), sources=('documents:document_list_deleted', 'documents:trash_can_empty')) # Document object links menu_object.bind_links(links=( link_document_favorites_add, link_document_favorites_remove, link_document_edit, link_document_document_type_edit, link_document_print, link_document_trash, link_document_quick_download, link_document_download, link_document_clear_transformations, link_document_clone_transformations, link_document_update_page_count, ), sources=(Document, )) menu_object.bind_links(links=(link_document_restore, link_document_delete), sources=(DeletedDocument, )) # Document facet links 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) menu_facet.bind_links(links=(link_document_properties, ), sources=(Document, ), position=2) menu_facet.bind_links(links=( link_events_for_object, link_object_event_types_user_subcriptions_list, link_document_version_list, ), sources=(Document, ), position=2) menu_facet.bind_links(links=(link_document_pages, ), sources=(Document, )) # Document actions menu_object.bind_links(links=(link_document_version_revert, link_document_version_download), sources=(DocumentVersion, )) menu_multi_item.bind_links(links=( link_document_multiple_favorites_add, link_document_multiple_favorites_remove, link_document_multiple_clear_transformations, link_document_multiple_trash, link_document_multiple_download, link_document_multiple_update_page_count, link_document_multiple_document_type_edit, ), sources=(Document, )) menu_multi_item.bind_links(links=(link_document_multiple_restore, link_document_multiple_delete), sources=(DeletedDocument, )) # Document pages menu_facet.add_unsorted_source(source=DocumentPage) menu_facet.bind_links( links=(link_document_page_rotate_left, link_document_page_rotate_right, link_document_page_zoom_in, link_document_page_zoom_out, link_document_page_view_reset), sources=('documents:document_page_view', )) menu_facet.bind_links(links=(link_document_page_view, ), sources=(DocumentPage, )) menu_facet.bind_links(links=(link_document_page_navigation_first, link_document_page_navigation_previous, link_document_page_navigation_next, link_document_page_navigation_last), sources=(DocumentPage, )) menu_list_facet.bind_links(links=(link_transformation_list, ), sources=(DocumentPage, )) menu_multi_item.bind_links(links=(link_document_page_multiple_disable, link_document_page_multiple_enable), sources=(DocumentPage, )) menu_object.bind_links(links=(link_document_page_disable, link_document_page_enable), sources=(DocumentPage, )) menu_secondary.bind_links(links=(link_document_page_return, ), sources=(DocumentPage, )) # Document versions menu_list_facet.bind_links(links=(link_document_version_view, ), sources=(DocumentVersion, )) menu_secondary.bind_links(links=(link_document_version_return_document, link_document_version_return_list), sources=(DocumentVersion, )) post_delete.connect( dispatch_uid='documents_handler_remove_empty_duplicates_lists', receiver=handler_remove_empty_duplicates_lists, sender=Document) post_initial_setup.connect( dispatch_uid='documents_handler_create_default_document_type', receiver=handler_create_default_document_type) post_migrate.connect( dispatch_uid='documents_handler_create_document_cache', receiver=handler_create_document_cache, ) post_version_upload.connect( dispatch_uid='documents_handler_scan_duplicates_for', receiver=handler_scan_duplicates_for) registry.register(DeletedDocument) registry.register(Document) registry.register(DocumentType) registry.register(DocumentVersion)
def ready(self): super(MetadataApp, self).ready() from actstream import registry from .wizard_steps import WizardStepMetadata # NOQA Document = apps.get_model(app_label='documents', model_name='Document') DocumentPageResult = apps.get_model(app_label='documents', model_name='DocumentPageResult') DocumentType = apps.get_model(app_label='documents', model_name='DocumentType') DocumentMetadata = self.get_model(model_name='DocumentMetadata') DocumentTypeMetadataType = self.get_model( model_name='DocumentTypeMetadataType') MetadataType = self.get_model(model_name='MetadataType') Document.add_to_class(name='metadata_value_of', value=DocumentMetadataHelper.constructor) ModelAttribute( model=Document, name='metadata_value_of', description=_('Return the value of a specific document metadata')) ModelField(model=Document, name='metadata__metadata_type__name', label=_('Metadata type name')) ModelField(model=Document, name='metadata__value', label=_('Metadata type value')) ModelEventType.register(model=Document, event_types=( event_document_metadata_added, event_document_metadata_edited, event_document_metadata_removed, )) ModelEventType.register(model=MetadataType, event_types=( event_document_metadata_added, event_document_metadata_edited, event_document_metadata_removed, event_metadata_type_edited, event_metadata_type_relationship, )) ModelEventType.register( model=DocumentType, event_types=(event_metadata_type_relationship, )) ModelPermission.register(model=Document, permissions=( permission_document_metadata_add, permission_document_metadata_edit, permission_document_metadata_remove, permission_document_metadata_view, )) ModelPermission.register(model=MetadataType, permissions=(permission_acl_edit, permission_acl_view, permission_events_view, permission_metadata_type_delete, permission_metadata_type_edit, permission_metadata_type_view)) SourceColumn( source=Document, label=_('Metadata'), func=lambda context: get_metadata_string(context['object'])) SourceColumn(source=DocumentPageResult, label=_('Metadata'), func=lambda context: get_metadata_string(context['object'] .document)) SourceColumn(attribute='metadata_type', is_identifier=True, is_sortable=True, source=DocumentMetadata) SourceColumn(attribute='value', is_sortable=True, source=DocumentMetadata) SourceColumn(attribute='is_required', source=DocumentMetadata, widget=TwoStateWidget) SourceColumn(attribute='label', is_identifier=True, is_sortable=True, source=MetadataType) SourceColumn(attribute='name', is_sortable=True, source=MetadataType) document_search.add_model_field(field='metadata__metadata_type__name', label=_('Metadata type')) document_search.add_model_field(field='metadata__value', label=_('Metadata value')) document_page_search.add_model_field( field='document_version__document__metadata__metadata_type__name', label=_('Metadata type')) document_page_search.add_model_field( field='document_version__document__metadata__value', label=_('Metadata value')) menu_facet.bind_links(links=(link_metadata_view, ), sources=(Document, )) menu_list_facet.bind_links( links=(link_setup_document_type_metadata_types, ), sources=(DocumentType, )) menu_multi_item.bind_links(links=(link_metadata_multiple_add, link_metadata_multiple_edit, link_metadata_multiple_remove), sources=(Document, )) menu_list_facet.bind_links(links=( link_acl_list, link_setup_metadata_type_document_types, link_object_event_types_user_subcriptions_list, link_events_for_object, ), sources=(MetadataType, )) menu_object.bind_links(links=(link_setup_metadata_type_delete, link_setup_metadata_type_edit), sources=(MetadataType, )) menu_secondary.bind_links( links=(link_setup_metadata_type_list, link_setup_metadata_type_create), sources=(MetadataType, 'metadata:setup_metadata_type_list', 'metadata:setup_metadata_type_create')) menu_setup.bind_links(links=(link_setup_metadata_type_list, )) menu_secondary.bind_links( links=(link_metadata_add, link_metadata_edit, link_metadata_remove), sources=('metadata:metadata_add', 'metadata:metadata_edit', 'metadata:metadata_remove', 'metadata:metadata_view')) post_delete.connect( dispatch_uid= 'metadata_handler_post_document_type_metadata_type_delete', receiver=handler_post_document_type_metadata_type_delete, sender=DocumentTypeMetadataType) post_document_type_change.connect( dispatch_uid='metadata_handler_post_document_type_change_metadata', receiver=handler_post_document_type_change_metadata, sender=Document) post_save.connect( dispatch_uid= 'metadata_handler_post_document_type_metadata_type_add', receiver=handler_post_document_type_metadata_type_add, sender=DocumentTypeMetadataType) # Index updating post_delete.connect( dispatch_uid='metadata_handler_index_document_delete', receiver=handler_index_document, sender=DocumentMetadata) post_save.connect(dispatch_uid='metadata_handler_index_document_save', receiver=handler_index_document, sender=DocumentMetadata) registry.register(MetadataType) registry.register(DocumentTypeMetadataType)
def ready(self): super(DocumentStatesApp, self).ready() from actstream import registry Action = apps.get_model(app_label='actstream', model_name='Action') Document = apps.get_model(app_label='documents', model_name='Document') DocumentType = apps.get_model(app_label='documents', model_name='DocumentType') ErrorLogEntry = apps.get_model(app_label='common', model_name='ErrorLogEntry') Workflow = self.get_model('Workflow') WorkflowInstance = self.get_model('WorkflowInstance') WorkflowInstanceLogEntry = self.get_model('WorkflowInstanceLogEntry') WorkflowRuntimeProxy = self.get_model('WorkflowRuntimeProxy') WorkflowState = self.get_model('WorkflowState') WorkflowStateAction = self.get_model('WorkflowStateAction') WorkflowStateRuntimeProxy = self.get_model('WorkflowStateRuntimeProxy') WorkflowTransition = self.get_model('WorkflowTransition') WorkflowTransitionField = self.get_model('WorkflowTransitionField') WorkflowTransitionTriggerEvent = self.get_model( 'WorkflowTransitionTriggerEvent') Document.add_to_class(name='workflow', value=DocumentStateHelper.constructor) ErrorLogEntry.objects.register(model=WorkflowStateAction) WorkflowAction.initialize() ModelProperty( model=Document, name='workflow.< workflow internal name >.get_current_state', label=_('Current state of a workflow'), description=_( 'Return the current state of the selected workflow.')) ModelProperty( model=Document, name= 'workflow.< workflow internal name >.get_current_state.completion', label=_('Current state of a workflow'), description=_( 'Return the completion value of the current state of the ' 'selected workflow.')) ModelEventType.register(event_types=(event_workflow_edited, ), model=Workflow) ModelPermission.register(model=Document, permissions=(permission_workflow_view, )) ModelPermission.register( model=Workflow, permissions=(permission_error_log_view, permission_workflow_delete, permission_workflow_edit, permission_workflow_tools, permission_workflow_transition, permission_workflow_view)) ModelPermission.register( model=WorkflowTransition, permissions=(permission_workflow_transition, )) ModelPermission.register_inheritance( model=WorkflowInstance, related='workflow', ) ModelPermission.register_inheritance( model=WorkflowInstanceLogEntry, related='workflow_instance__workflow', ) ModelPermission.register_inheritance( model=WorkflowState, related='workflow', ) ModelPermission.register_inheritance( model=WorkflowStateAction, related='state__workflow', ) ModelPermission.register_inheritance( model=WorkflowTransition, related='workflow', ) ModelPermission.register_inheritance( model=WorkflowTransitionField, related='transition', ) ModelPermission.register_inheritance( model=WorkflowTransitionTriggerEvent, related='transition__workflow', ) ModelField(model=WorkflowInstance, name='document') ModelField(model=WorkflowInstance, name='workflow') ModelReverseField(model=WorkflowInstance, name='log_entries') ModelProperty(description=_( 'Return the last workflow instance log entry. The ' 'log entry itself has the following fields: datetime, ' 'transition, user, and comment.'), label=_('Get last log entry'), model=WorkflowInstance, name='get_last_log_entry') ModelProperty(description=_( 'Return the current context dictionary which includes ' 'runtime data from the workflow transition fields.'), label=_('Get the context'), model=WorkflowInstance, name='get_runtime_context') ModelProperty( description=_('Return the transition of the workflow instance.'), label=_('Get last transition'), model=WorkflowInstance, name='get_last_transition') SourceColumn(attribute='label', is_identifier=True, is_sortable=True, source=Workflow) column_workflow_internal_name = SourceColumn(attribute='internal_name', include_label=True, is_sortable=True, source=Workflow) column_workflow_internal_name.add_exclude(source=WorkflowRuntimeProxy) SourceColumn(attribute='get_initial_state', empty_value=_('None'), include_label=True, source=Workflow) SourceColumn( attribute='get_current_state', include_label=True, label=_('Current state'), source=WorkflowInstance, ) SourceColumn(func=lambda context: getattr( context['object'].get_last_log_entry(), 'user', _('None')), include_label=True, label=_('User'), source=WorkflowInstance) SourceColumn(attribute='get_last_transition', include_label=True, label=_('Last transition'), source=WorkflowInstance) SourceColumn(func=lambda context: getattr( context['object'].get_last_log_entry(), 'datetime', _('None')), include_label=True, label=_('Date and time'), source=WorkflowInstance) SourceColumn(func=lambda context: getattr( context['object'].get_current_state(), 'completion', _('None')), include_label=True, label=_('Completion'), source=WorkflowInstance) SourceColumn(attribute='datetime', is_identifier=True, label=_('Date and time'), source=WorkflowInstanceLogEntry) SourceColumn(attribute='user', include_label=True, label=_('User'), source=WorkflowInstanceLogEntry) SourceColumn(attribute='transition__origin_state', include_label=True, is_sortable=True, source=WorkflowInstanceLogEntry) SourceColumn(attribute='transition', include_label=True, is_sortable=True, source=WorkflowInstanceLogEntry) SourceColumn(attribute='transition__destination_state', include_label=True, is_sortable=True, source=WorkflowInstanceLogEntry) SourceColumn(attribute='comment', include_label=True, is_sortable=True, source=WorkflowInstanceLogEntry) SourceColumn(attribute='get_extra_data', include_label=True, label=_('Additional details'), source=WorkflowInstanceLogEntry, widget=WorkflowLogExtraDataWidget) SourceColumn(attribute='label', is_identifier=True, is_sortable=True, source=WorkflowState) SourceColumn(attribute='initial', include_label=True, is_sortable=True, source=WorkflowState, widget=TwoStateWidget) SourceColumn(attribute='completion', include_label=True, is_sortable=True, source=WorkflowState) SourceColumn(attribute='label', is_identifier=True, is_sortable=True, source=WorkflowStateAction) SourceColumn(attribute='enabled', include_label=True, is_sortable=True, source=WorkflowStateAction, widget=TwoStateWidget) SourceColumn(attribute='get_when_display', include_label=True, label=_('When?'), source=WorkflowStateAction) SourceColumn(attribute='get_class_label', include_label=True, label=_('Action type'), source=WorkflowStateAction) SourceColumn(attribute='has_condition', include_label=True, source=WorkflowStateAction, widget=TwoStateWidget) SourceColumn( attribute='label', is_identifier=True, is_sortable=True, source=WorkflowTransition, ) SourceColumn(attribute='origin_state', include_label=True, is_sortable=True, source=WorkflowTransition) SourceColumn(attribute='destination_state', include_label=True, is_sortable=True, source=WorkflowTransition) SourceColumn(attribute='has_condition', include_label=True, source=WorkflowTransition, widget=TwoStateWidget) SourceColumn( func=lambda context: widget_transition_events(transition=context[ 'object']), help_text=_( 'Triggers are system events that will cause the transition ' 'to be applied.'), include_label=True, label=_('Triggers'), source=WorkflowTransition) SourceColumn(attribute='name', is_identifier=True, is_sortable=True, source=WorkflowTransitionField) SourceColumn(attribute='label', include_label=True, is_sortable=True, source=WorkflowTransitionField) SourceColumn(attribute='get_field_type_display', include_label=True, label=_('Type'), source=WorkflowTransitionField) SourceColumn(attribute='required', include_label=True, is_sortable=True, source=WorkflowTransitionField, widget=TwoStateWidget) SourceColumn(attribute='get_widget_display', include_label=True, label=_('Widget'), is_sortable=False, source=WorkflowTransitionField) SourceColumn(attribute='widget_kwargs', include_label=True, is_sortable=True, source=WorkflowTransitionField) SourceColumn(func=lambda context: context['object'].get_document_count( user=context['request'].user), include_label=True, label=_('Documents'), order=99, source=WorkflowRuntimeProxy) SourceColumn(func=lambda context: context['object'].get_document_count( user=context['request'].user), include_label=True, label=_('Documents'), order=99, source=WorkflowStateRuntimeProxy) menu_facet.bind_links(links=(link_workflow_instance_list, ), sources=(Document, )) menu_list_facet.bind_links( links=(link_acl_list, link_events_for_object, link_object_event_types_user_subcriptions_list, link_workflow_template_document_types, link_workflow_template_state_list, link_workflow_template_transition_list, link_workflow_template_preview), sources=(Workflow, )) menu_list_facet.unbind_links( links=(link_acl_list, link_events_for_object, link_object_event_types_user_subcriptions_list, link_workflow_template_document_types, link_workflow_template_state_list, link_workflow_template_transition_list, link_workflow_template_preview), sources=(WorkflowRuntimeProxy, )) menu_list_facet.bind_links( links=(link_document_type_workflow_templates, ), sources=(DocumentType, )) menu_main.bind_links(links=(link_workflow_runtime_proxy_list, ), position=10) menu_object.bind_links(links=(link_workflow_template_delete, link_workflow_template_edit, link_workflow_template_launch), sources=(Workflow, )) menu_object.bind_links(links=(link_workflow_template_state_edit, link_workflow_template_state_action_list, link_workflow_template_state_delete), sources=(WorkflowState, )) menu_object.bind_links( links=(link_workflow_template_transition_edit, link_workflow_template_transition_events, link_workflow_template_transition_field_list, link_acl_list, link_workflow_template_transition_delete), sources=(WorkflowTransition, )) menu_object.bind_links( links=(link_workflow_template_transition_field_delete, link_workflow_template_transition_field_edit), sources=(WorkflowTransitionField, )) menu_object.bind_links(links=(link_workflow_instance_detail, link_workflow_instance_transition), sources=(WorkflowInstance, )) menu_list_facet.bind_links(links=( link_workflow_runtime_proxy_document_list, link_workflow_runtime_proxy_state_list, ), sources=(WorkflowRuntimeProxy, )) menu_list_facet.bind_links( links=(link_workflow_runtime_proxy_state_document_list, ), sources=(WorkflowStateRuntimeProxy, )) menu_object.bind_links(links=( link_workflow_template_state_action_edit, link_object_error_list, link_workflow_template_state_action_delete, ), sources=(WorkflowStateAction, )) menu_secondary.bind_links( links=(link_workflow_template_list, link_workflow_template_create), sources=(Workflow, 'document_states:workflow_template_create', 'document_states:workflow_template_list')) menu_secondary.bind_links( links=(link_workflow_template_transition_field_create, ), sources=(WorkflowTransition, )) menu_secondary.bind_links(links=(link_workflow_runtime_proxy_list, ), sources=(WorkflowRuntimeProxy, )) menu_secondary.bind_links( links=(link_workflow_template_state_action_selection, ), sources=(WorkflowState, )) menu_secondary.bind_links( links=(link_workflow_template_transition_create, ), sources=( WorkflowTransition, 'document_states:workflow_template_transition_create', 'document_states:workflow_template_transition_list', )) menu_secondary.bind_links( links=(link_workflow_template_state_create, ), sources=( WorkflowState, 'document_states:workflow_template_state_create', 'document_states:workflow_template_state_list', )) menu_setup.bind_links(links=(link_workflow_template_list, )) menu_tools.bind_links(links=(link_tool_launch_workflows, )) post_save.connect(dispatch_uid='workflows_handler_launch_workflow', receiver=handler_launch_workflow, sender=Document) # Index updating post_migrate.connect( dispatch_uid='workflows_handler_create_workflow_image_cache', receiver=handler_create_workflow_image_cache, ) post_save.connect(dispatch_uid='workflows_handler_index_document_save', receiver=handler_index_document, sender=WorkflowInstanceLogEntry) post_save.connect(dispatch_uid='workflows_handler_trigger_transition', receiver=handler_trigger_transition, sender=Action) registry.register(Workflow)
def ready(self): super(FileMetadataApp, self).ready() FileMetadataEntry = self.get_model(model_name='FileMetadataEntry') DocumentVersionDriverEntry = self.get_model( model_name='DocumentVersionDriverEntry') Document = apps.get_model(app_label='documents', model_name='Document') DocumentTypeSettings = self.get_model( model_name='DocumentTypeSettings') DocumentType = apps.get_model(app_label='documents', model_name='DocumentType') DocumentVersion = apps.get_model(app_label='documents', model_name='DocumentVersion') Document.add_to_class(name='file_metadata_value_of', value=FileMetadataHelper.constructor) Document.add_to_class(name='get_file_metadata', value=method_get_document_file_metadata) Document.add_to_class(name='submit_for_file_metadata_processing', value=method_document_submit) DocumentVersion.add_to_class( name='get_file_metadata', value=method_get_document_version_file_metadata) DocumentVersion.add_to_class( name='submit_for_file_metadata_processing', value=method_document_version_submit) ModelAttribute( model=Document, name= 'file_metadata_value_of.< underscore separated driver name and property name >', description=_('Return the value of a specific file metadata.'), label=_('File metadata value of')) ModelEventType.register( model=Document, event_types=(event_file_metadata_document_version_finish, event_file_metadata_document_version_submit)) ModelField( label=_('File metadata key'), model=Document, name='versions__file_metadata_drivers__entries__key', ) ModelField( label=_('File metadata value'), model=Document, name='versions__file_metadata_drivers__entries__value', ) ModelPermission.register(model=Document, permissions=( permission_file_metadata_submit, permission_file_metadata_view, )) ModelPermission.register( model=DocumentType, permissions=(permission_document_type_file_metadata_setup, permission_file_metadata_submit, permission_file_metadata_view)) ModelPermission.register_inheritance( model=DocumentTypeSettings, related='document_type', ) ModelPermission.register_inheritance( model=DocumentVersionDriverEntry, related='document_version', ) SourceColumn(attribute='key', source=FileMetadataEntry) SourceColumn(attribute='value', source=FileMetadataEntry) SourceColumn(attribute='driver', source=DocumentVersionDriverEntry) SourceColumn(attribute='driver__internal_name', source=DocumentVersionDriverEntry) SourceColumn(attribute='get_attribute_count', source=DocumentVersionDriverEntry) document_search.add_model_field( field='versions__file_metadata_drivers__entries__key', label=_('File metadata key')) document_search.add_model_field( field='versions__file_metadata_drivers__entries__value', label=_('File metadata value')) document_page_search.add_model_field( field='document_version__file_metadata_drivers__entries__key', label=_('File metadata key')) document_page_search.add_model_field( field='document_version__file_metadata_drivers__entries__value', label=_('File metadata value')) menu_facet.bind_links(links=(link_document_driver_list, ), sources=(Document, )) menu_list_facet.bind_links( links=(link_document_type_file_metadata_settings, ), sources=(DocumentType, )) menu_object.bind_links(links=(link_document_file_metadata_list, ), sources=(DocumentVersionDriverEntry, )) menu_multi_item.bind_links(links=(link_document_multiple_submit, ), sources=(Document, )) menu_secondary.bind_links( links=(link_document_submit, ), sources=( 'file_metadata:document_driver_list', 'file_metadata:document_version_driver_file_metadata_list')) menu_tools.bind_links(links=(link_document_type_submit, ), ) post_save.connect( dispatch_uid= 'file_metadata_handler_initialize_new_document_type_settings', receiver=handler_initialize_new_document_type_settings, sender=DocumentType) post_version_upload.connect( dispatch_uid='file_metadata_handler_process_document_version', receiver=handler_process_document_version, sender=DocumentVersion) post_document_version_file_metadata_processing.connect( dispatch_uid='file_metadata_handler_index_document', receiver=handler_index_document_version, sender=DocumentVersion)