def ready(self): super(SourcesApp, self).ready() APIEndPoint(app=self, version_string='1') MissingItem( label=_('Create a document source'), description=_( 'Document sources are the way in which new documents are ' 'feed to Mayan EDMS, create at least a web form source to ' 'be able to upload documents from a browser.' ), condition=lambda: not Source.objects.exists(), view='sources:setup_source_list' ) SourceColumn( source=StagingFile, label=_('Created'), func=lambda context: context['object'].get_date_time_created() ) SourceColumn( source=StagingFile, label=_('Thumbnail'), func=lambda context: staging_file_thumbnail( context['object'], gallery_name='sources:staging_list', title=context['object'].filename, size='100' ) ) SourceColumn( source=SourceLog, label=_('Date time'), func=lambda context: context['object'].datetime ) SourceColumn( source=SourceLog, label=_('Message'), func=lambda context: context['object'].message ) app.conf.CELERY_QUEUES.extend( ( Queue( 'sources', Exchange('sources'), routing_key='sources' ), Queue( 'sources_periodic', Exchange('sources_periodic'), routing_key='sources_periodic', delivery_mode=1 ), ) ) app.conf.CELERY_ROUTES.update( { 'sources.tasks.task_check_interval_source': { 'queue': 'sources_periodic' }, 'sources.tasks.task_source_handle_upload': { 'queue': 'sources' }, 'sources.tasks.task_upload_document': { 'queue': 'sources' }, } ) menu_front_page.bind_links(links=(link_document_create_multiple,)) menu_object.bind_links( links=(link_document_create_siblings,), sources=(Document,) ) menu_object.bind_links( links=( link_setup_source_edit, link_setup_source_delete, link_transformation_list, link_setup_source_logs ), sources=( POP3Email, IMAPEmail, StagingFolderSource, WatchFolderSource, WebFormSource ) ) menu_object.bind_links( links=(link_staging_file_delete,), sources=(StagingFile,) ) menu_secondary.bind_links( links=( link_setup_sources, link_setup_source_create_webform, link_setup_source_create_staging_folder, link_setup_source_create_pop3_email, link_setup_source_create_imap_email, link_setup_source_create_watch_folder ), sources=( POP3Email, IMAPEmail, StagingFolderSource, WatchFolderSource, WebFormSource, 'sources:setup_source_list', 'sources:setup_source_create' ) ) menu_setup.bind_links(links=(link_setup_sources,)) menu_sidebar.bind_links( links=(link_upload_version,), sources=( 'documents:document_version_list', 'documents:upload_version', 'documents:document_version_revert' ) ) post_upgrade.connect( initialize_periodic_tasks, dispatch_uid='initialize_periodic_tasks' ) post_initial_setup.connect( create_default_document_source, dispatch_uid='create_default_document_source' ) post_version_upload.connect( copy_transformations_to_version, dispatch_uid='copy_transformations_to_version' )
def ready(self): super(DocumentSignaturesApp, self).ready() Document = apps.get_model(app_label='documents', model_name='Document') DocumentVersion = apps.get_model(app_label='documents', model_name='DocumentVersion') Key = apps.get_model(app_label='django_gpg', model_name='Key') EmbeddedSignature = self.get_model('EmbeddedSignature') SignatureBaseModel = self.get_model('SignatureBaseModel') DocumentVersion.register_post_save_hook( order=1, func=EmbeddedSignature.objects.create) DocumentVersion.register_pre_open_hook( order=1, func=EmbeddedSignature.objects.open_signed) ModelPermission.register( model=Document, permissions=( permission_document_version_sign_detached, permission_document_version_sign_embedded, permission_document_version_signature_delete, permission_document_version_signature_download, permission_document_version_signature_view, permission_document_version_signature_upload, )) SourceColumn(source=SignatureBaseModel, label=_('Date'), attribute='date') SourceColumn(source=SignatureBaseModel, label=_('Key ID'), attribute='get_key_id') SourceColumn( source=SignatureBaseModel, label=_('Signature ID'), func=lambda context: context['object'].signature_id or _('None')) SourceColumn( source=SignatureBaseModel, label=_('Type'), func=lambda context: SignatureBaseModel.objects.get_subclass( pk=context['object'].pk).get_signature_type_display()) app.conf.CELERY_QUEUES.append( Queue('signatures', Exchange('signatures'), routing_key='signatures'), ) app.conf.CELERY_ROUTES.update({ 'document_signatures.tasks.task_verify_key_signatures': { 'queue': 'signatures' }, 'document_signatures.tasks.task_unverify_key_signatures': { 'queue': 'signatures' }, 'document_signatures.tasks.task_verify_document_version': { 'queue': 'signatures' }, 'document_signatures.tasks.task_verify_missing_embedded_signature': { 'queue': 'tools' }, }) menu_facet.bind_links(links=(link_document_signature_list, ), sources=(Document, )) menu_object.bind_links( links=(link_document_version_signature_list, link_document_version_signature_detached_create, link_document_version_signature_embedded_create), sources=(DocumentVersion, )) menu_object.bind_links(links=( link_document_version_signature_details, link_document_version_signature_download, link_document_version_signature_delete, ), sources=(SignatureBaseModel, )) menu_sidebar.bind_links( links=(link_document_version_signature_upload, ), sources=(DocumentVersion, )) menu_tools.bind_links( links=(link_all_document_version_signature_verify, )) post_delete.connect(unverify_key_signatures, dispatch_uid='unverify_key_signatures', sender=Key) post_upgrade.connect( verify_missing_embedded_signature, dispatch_uid='verify_missing_embedded_signature', ) post_save.connect(verify_key_signatures, dispatch_uid='verify_key_signatures', sender=Key)
def ready(self): super(SourcesApp, self).ready() POP3Email = self.get_model('POP3Email') IMAPEmail = self.get_model('IMAPEmail') Source = self.get_model('Source') SourceLog = self.get_model('SourceLog') SaneScanner = self.get_model('SaneScanner') StagingFolderSource = self.get_model('StagingFolderSource') WatchFolderSource = self.get_model('WatchFolderSource') WebFormSource = self.get_model('WebFormSource') APIEndPoint(app=self, version_string='1') MissingItem( label=_('Create a document source'), description=_( 'Document sources are the way in which new documents are ' 'feed to Mayan EDMS, create at least a web form source to ' 'be able to upload documents from a browser.'), condition=lambda: not Source.objects.exists(), view='sources:setup_source_list') SourceColumn( source=StagingFile, label=_('Created'), func=lambda context: context['object'].get_date_time_created()) html_widget = StagingFileThumbnailWidget() SourceColumn(source=StagingFile, label=_('Thumbnail'), func=lambda context: html_widget.render(instance=context[ 'object'], )) SourceColumn(source=SourceLog, label=_('Date time'), func=lambda context: context['object'].datetime) SourceColumn(source=SourceLog, label=_('Message'), func=lambda context: context['object'].message) app.conf.CELERY_QUEUES.extend(( Queue('sources', Exchange('sources'), routing_key='sources'), Queue('sources_periodic', Exchange('sources_periodic'), routing_key='sources_periodic', delivery_mode=1), )) app.conf.CELERY_ROUTES.update({ 'sources.tasks.task_check_interval_source': { 'queue': 'sources_periodic' }, 'sources.tasks.task_source_handle_upload': { 'queue': 'sources' }, 'sources.tasks.task_upload_document': { 'queue': 'sources' }, }) menu_documents.bind_links(links=(link_document_create_multiple, )) menu_object.bind_links( links=(link_setup_source_edit, link_setup_source_delete, link_transformation_list, link_setup_source_logs), sources=(POP3Email, IMAPEmail, SaneScanner, StagingFolderSource, WatchFolderSource, WebFormSource)) menu_object.bind_links(links=(link_staging_file_delete, ), sources=(StagingFile, )) menu_object.bind_links(links=(link_setup_source_check_now, ), sources=( IMAPEmail, POP3Email, WatchFolderSource, )) menu_secondary.bind_links( links=(link_setup_sources, link_setup_source_create_webform, link_setup_source_create_sane_scanner, link_setup_source_create_staging_folder, link_setup_source_create_pop3_email, link_setup_source_create_imap_email, link_setup_source_create_watch_folder), sources=(POP3Email, IMAPEmail, StagingFolderSource, WatchFolderSource, WebFormSource, 'sources:setup_source_list', 'sources:setup_source_create')) menu_setup.bind_links(links=(link_setup_sources, )) menu_sidebar.bind_links(links=(link_upload_version, ), sources=('documents:document_version_list', 'documents:upload_version', 'documents:document_version_revert')) post_upgrade.connect(initialize_periodic_tasks, dispatch_uid='initialize_periodic_tasks') post_initial_setup.connect( create_default_document_source, dispatch_uid='create_default_document_source') post_version_upload.connect( copy_transformations_to_version, dispatch_uid='copy_transformations_to_version')
def ready(self): super(DocumentSignaturesApp, self).ready() Document = apps.get_model( app_label='documents', model_name='Document' ) DocumentVersion = apps.get_model( app_label='documents', model_name='DocumentVersion' ) Key = apps.get_model( app_label='django_gpg', model_name='Key' ) EmbeddedSignature = self.get_model('EmbeddedSignature') SignatureBaseModel = self.get_model('SignatureBaseModel') DocumentVersion.register_post_save_hook( order=1, func=EmbeddedSignature.objects.create ) DocumentVersion.register_pre_open_hook( order=1, func=EmbeddedSignature.objects.open_signed ) ModelPermission.register( model=Document, permissions=( permission_document_version_sign_detached, permission_document_version_sign_embedded, permission_document_version_signature_delete, permission_document_version_signature_download, permission_document_version_signature_view, permission_document_version_signature_upload, ) ) SourceColumn( source=SignatureBaseModel, label=_('Date'), attribute='date' ) SourceColumn( source=SignatureBaseModel, label=_('Key ID'), attribute='get_key_id' ) SourceColumn( source=SignatureBaseModel, label=_('Signature ID'), func=lambda context: context['object'].signature_id or _('None') ) SourceColumn( source=SignatureBaseModel, label=_('Type'), func=lambda context: SignatureBaseModel.objects.get_subclass( pk=context['object'].pk ).get_signature_type_display() ) app.conf.CELERY_QUEUES.append( Queue( 'signatures', Exchange('signatures'), routing_key='signatures' ), ) app.conf.CELERY_ROUTES.update( { 'document_signatures.tasks.task_verify_key_signatures': { 'queue': 'signatures' }, 'document_signatures.tasks.task_unverify_key_signatures': { 'queue': 'signatures' }, 'document_signatures.tasks.task_verify_document_version': { 'queue': 'signatures' }, 'document_signatures.tasks.task_verify_missing_embedded_signature': { 'queue': 'tools' }, } ) menu_facet.bind_links( links=(link_document_signature_list,), sources=(Document,) ) menu_facet.bind_links( links=( link_document_version_signature_list, ), position=9, sources=(DocumentVersion,) ) menu_object.bind_links( links=( link_document_version_signature_detached_create, link_document_version_signature_embedded_create ), sources=(DocumentVersion,) ) menu_object.bind_links( links=( link_document_version_signature_details, link_document_version_signature_download, link_document_version_signature_delete, ), sources=(SignatureBaseModel,) ) menu_sidebar.bind_links( links=( link_document_version_signature_upload, ), sources=(DocumentVersion,) ) menu_tools.bind_links( links=(link_all_document_version_signature_verify,) ) post_delete.connect( unverify_key_signatures, dispatch_uid='unverify_key_signatures', sender=Key ) post_upgrade.connect( verify_missing_embedded_signature, dispatch_uid='verify_missing_embedded_signature', ) post_save.connect( verify_key_signatures, dispatch_uid='verify_key_signatures', sender=Key )