def ready(self): super(EventsApp, self).ready() Action = apps.get_model(app_label='actstream', model_name='Action') APIEndPoint(app=self, version_string='1') SourceColumn( source=Action, label=_('Timestamp'), attribute='timestamp' ) SourceColumn( source=Action, label=_('Actor'), func=lambda context: event_actor(context['object']) ) SourceColumn( source=Action, label=_('Verb'), func=lambda context: event_type_link(context['object']) ) SourceColumn( source=Action, label=_('Action object'), func=lambda context: event_object_link( entry=context['object'], attribute='action_object' ) ) menu_tools.bind_links(links=(link_events_list,))
def ready(self): super(InstallationApp, self).ready() SourceColumn( source=PropertyNamespace, label=_('Label'), attribute='label' ) SourceColumn( source=PropertyNamespace, label=_('Items'), func=lambda context: len(context['object'].get_properties()) ) SourceColumn(source=Property, label=_('Label'), attribute='label') SourceColumn(source=Property, label=_('Value'), attribute='value') menu_object.bind_links( links=(link_namespace_details,), sources=(PropertyNamespace,) ) menu_secondary.bind_links( links=(link_namespace_list,), sources=('installation:namespace_list', PropertyNamespace) ) menu_tools.bind_links(links=(link_menu_link,)) namespace = PropertyNamespace('venv', _('VirtualEnv')) try: venv = VirtualEnv() except PIPNotFound: namespace.add_property( 'pip', 'pip', _('pip not found.'), report=True ) else: for item, version, result in venv.get_results(): namespace.add_property( item, '%s (%s)' % (item, version), result, report=True )
def ready(self): super(MailerApp, self).ready() SourceColumn(source=LogEntry, label=_('Date and time'), attribute='datetime') SourceColumn(source=LogEntry, label=_('Message'), attribute='message') ModelPermission.register( model=Document, permissions=(permission_mailing_link, permission_mailing_send_document)) app.conf.CELERY_QUEUES.append( Queue('mailing', Exchange('mailing'), routing_key='mailing'), ) app.conf.CELERY_ROUTES.update({ 'mailer.tasks.task_send_document': { 'queue': 'mailing' }, }) menu_object.bind_links(links=(link_send_document_link, link_send_document), sources=(Document, )) menu_tools.bind_links(links=(link_document_mailing_error_log, ))
def ready(self): super(StatisticsApp, self).ready() SourceColumn( source=StatisticLineChart, # Translators: Schedule here is a verb, the 'schedule' at # which the statistic will be updated label=_('Schedule'), attribute='schedule', ) app.conf.CELERY_QUEUES.extend((Queue('statistics', Exchange('statistics'), routing_key='statistics', delivery_mode=1), )) app.conf.CELERY_ROUTES.update({ 'mayan_statistics.tasks.task_execute_statistic': { 'queue': 'statistics' }, }) menu_object.bind_links(links=(link_execute, link_view), sources=(StatisticLineChart, )) menu_object.bind_links(links=(link_namespace_details, ), sources=(StatisticNamespace, )) menu_secondary.bind_links(links=(link_namespace_list, ), sources=(StatisticNamespace, 'statistics:namespace_list')) menu_tools.bind_links(links=(link_statistics, ))
def ready(self): super(InstallationApp, self).ready() SourceColumn(source=PropertyNamespace, label=_('Label'), attribute='label') SourceColumn( source=PropertyNamespace, label=_('Items'), func=lambda context: len(context['object'].get_properties())) SourceColumn(source=Property, label=_('Label'), attribute='label') SourceColumn(source=Property, label=_('Value'), attribute='value') menu_object.bind_links(links=(link_namespace_details, ), sources=(PropertyNamespace, )) menu_secondary.bind_links(links=(link_namespace_list, ), sources=('installation:namespace_list', PropertyNamespace)) menu_tools.bind_links(links=(link_menu_link, )) namespace = PropertyNamespace('venv', _('VirtualEnv')) try: venv = VirtualEnv() except PIPNotFound: namespace.add_property('pip', 'pip', _('pip not found.'), report=True) else: for item, version, result in venv.get_results(): namespace.add_property(item, '%s (%s)' % (item, version), result, report=True)
def ready(self): super(RESTAPIApp, self).ready() settings.STRONGHOLD_PUBLIC_URLS += (r'^/%s/.+$' % self.app_url,) APIEndPoint(app=self, name='rest', version_string='1') menu_tools.bind_links(links=(link_api, link_api_documentation))
def ready(self): super(EventsApp, self).ready() Action = apps.get_model(app_label='actstream', model_name='Action') Notification = self.get_model(model_name='Notification') StoredEventType = self.get_model(model_name='StoredEventType') User = get_user_model() SourceColumn(source=Action, label=_('Timestamp'), attribute='timestamp') SourceColumn(source=Action, label=_('Actor'), func=lambda context: event_user_link(context['object'])) SourceColumn(source=Action, label=_('Event'), func=lambda context: event_type_link(context['object'])) SourceColumn(source=Action, label=_('Action object'), func=lambda context: event_object_link( entry=context['object'], attribute='action_object')) SourceColumn(source=StoredEventType, label=_('Namespace'), attribute='namespace') SourceColumn(source=StoredEventType, label=_('Label'), attribute='label') SourceColumn(source=Notification, label=_('Timestamp'), attribute='action.timestamp') SourceColumn(source=Notification, label=_('Actor'), attribute='action.actor') SourceColumn( source=Notification, label=_('Event'), func=lambda context: event_type_link(context['object'].action)) SourceColumn( source=Notification, label=_('Target'), func=lambda context: event_object_link(context['object'].action)) SourceColumn(source=Notification, label=_('Seen'), func=lambda context: two_state_template(state=context[ 'object'].read)) menu_main.bind_links(links=(link_user_notifications_list, ), position=99) menu_object.bind_links(links=(link_notification_mark_read, ), sources=(Notification, )) menu_object.bind_links(links=(link_user_events, ), sources=(User, )) menu_secondary.bind_links(links=(link_notification_mark_read_all, ), sources=('events:user_notifications_list', )) menu_tools.bind_links(links=(link_events_list, )) menu_user.bind_links(links=(link_event_types_subscriptions_list, ))
def ready(self): super(RESTAPIApp, self).ready() from .urls import api_urls settings.STRONGHOLD_PUBLIC_URLS += (r'^/%s/.+$' % self.app_url, ) menu_tools.bind_links(links=(link_api, link_api_documentation, link_api_documentation_redoc)) for app in apps.get_app_configs(): if getattr(app, 'has_rest_api', False): app_api_urls = import_string('{}.urls.api_urls'.format( app.label)) api_urls.extend(app_api_urls)
def ready(self): super(StatisticsApp, self).ready() Package(label='Chart.js', license_text=''' Copyright (c) 2013-2015 Nick Downie Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ''') SourceColumn( source=Statistic, # Translators: Schedule here is a verb, the 'schedule' at which the # statistic will be updated label=_('Schedule'), attribute='schedule', ) app.conf.CELERY_QUEUES.extend( ( Queue( 'statistics', Exchange('statistics'), routing_key='statistics', delivery_mode=1 ), ) ) app.conf.CELERY_ROUTES.update( { 'statistics.tasks.task_execute_statistic': { 'queue': 'statistics' }, } ) menu_object.bind_links( links=(link_execute, link_view), sources=(Statistic,) ) menu_object.bind_links( links=(link_namespace_details,), sources=(StatisticNamespace,) ) menu_secondary.bind_links( links=(link_namespace_list,), sources=(StatisticNamespace, 'statistics:namespace_list') ) menu_tools.bind_links(links=(link_statistics,))
def ready(self): super(EventsApp, self).ready() Action = apps.get_model(app_label='actstream', model_name='Action') APIEndPoint(app=self, version_string='1') SourceColumn(source=Action, label=_('Timestamp'), attribute='timestamp') SourceColumn(source=Action, label=_('Actor'), attribute='actor') SourceColumn(source=Action, label=_('Verb'), func=lambda context: event_type_link(context['object'])) menu_tools.bind_links(links=(link_events_list, ))
def ready(self): super(StatisticsApp, self).ready() Package(label='Chart.js', license_text=''' Copyright (c) 2013-2015 Nick Downie Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ''') SourceColumn( source=Statistic, # Translators: Schedule here is a verb, the 'schedule' at which the # statistic will be updated label=_('Schedule'), attribute='schedule', ) app.conf.CELERY_QUEUES.extend( ( Queue( 'statistics', Exchange('statistics'), routing_key='statistics', delivery_mode=1 ), ) ) app.conf.CELERY_ROUTES.update( { 'statistics.tasks.task_execute_statistic': { 'queue': 'statistics' }, } ) menu_object.bind_links(links=(link_execute, link_view), sources=(Statistic,)) menu_object.bind_links( links=(link_namespace_details,), sources=(StatisticNamespace,) ) menu_secondary.bind_links( links=(link_namespace_list,), sources=(StatisticNamespace, 'statistics:namespace_list') ) menu_tools.bind_links(links=(link_statistics,))
def ready(self): super(TaskManagerApp, self).ready() SourceColumn(source=CeleryQueue, label=_('Label'), attribute='label') SourceColumn(source=CeleryQueue, label=_('Name'), attribute='name') SourceColumn(source=CeleryQueue, label=_('Default queue?'), func=lambda context: two_state_template(context['object']. is_default_queue)) SourceColumn(source=CeleryQueue, label=_('Is transient?'), func=lambda context: two_state_template(context['object']. is_transient)) SourceColumn(source=Task, label=_('Type'), attribute='task_type') SourceColumn(source=Task, label=_('Start time'), attribute='get_time_started') SourceColumn(source=Task, label=_('Host'), func=lambda context: context['object'].kwargs['hostname']) SourceColumn(source=Task, label=_('Acknowledged'), func=lambda context: two_state_template(context[ 'object'].kwargs['acknowledged'])) SourceColumn(source=Task, label=_('Arguments'), func=lambda context: context['object'].kwargs['args']) SourceColumn(source=Task, label=_('Keyword arguments'), func=lambda context: context['object'].kwargs['kwargs']) SourceColumn( source=Task, label=_('Worker process ID'), func=lambda context: context['object'].kwargs['worker_pid']) menu_object.bind_links(links=( link_queue_active_task_list, link_queue_scheduled_task_list, link_queue_reserved_task_list, ), sources=(CeleryQueue, )) menu_secondary.bind_links(links=(link_queue_list, ), sources=(CeleryQueue, Task, 'task_manager:queue_list')) menu_tools.bind_links(links=(link_task_manager, ))
def ready(self): super(EventsApp, self).ready() APIEndPoint(app=self, version_string='1') Package(label='django-activity-stream', license_text=''' Copyright (c) 2010-2015, Justin Quick All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the author nor the names of other contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ''') SourceColumn( source=Action, label=_('Timestamp'), attribute='timestamp' ) SourceColumn(source=Action, label=_('Actor'), attribute='actor') SourceColumn( source=Action, label=_('Verb'), func=lambda context: event_type_link(context['object']) ) menu_tools.bind_links(links=(link_events_list,))
def ready(self): super(RESTAPIApp, self).ready() settings.STRONGHOLD_PUBLIC_URLS += (r'^/%s/.+$' % self.app_url, ) APIEndPoint(app=self, name='rest', version_string='1') Package(label='Django REST framework', license_text=''' Copyright (c) 2011-2015, Tom Christie All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ''') Package(label='django-rest-swagger', license_text=''' Copyright (c) 2013, Marc Gibbons All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ''') menu_tools.bind_links(links=(link_api, link_api_documentation))
def ready(self): super(EventsApp, self).ready() Package(label='django-activity-stream', license_text=''' Copyright (c) 2010-2015, Justin Quick All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the author nor the names of other contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ''') SourceColumn( source=Action, label=_('Timestamp'), attribute='timestamp' ) SourceColumn(source=Action, label=_('Actor'), attribute='actor') SourceColumn( source=Action, label=_('Verb'), func=lambda context: event_type_link(context['object']) ) menu_tools.bind_links(links=(link_events_list,))
def ready(self): super(RESTAPIApp, self).ready() APIEndPoint(app=self, name='rest', version_string='1') Package(label='Django REST framework', license_text=''' Copyright (c) 2011-2015, Tom Christie All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ''') Package(label='django-rest-swagger', license_text=''' Copyright (c) 2013, Marc Gibbons All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ''') menu_tools.bind_links(links=(link_api, link_api_documentation))
def ready(self): super(StatisticsApp, self).ready() SourceColumn( source=Statistic, # Translators: Schedule here is a verb, the 'schedule' at which the # statistic will be updated label=_('Schedule'), attribute='schedule', ) app.conf.CELERY_QUEUES.extend( ( Queue( 'statistics', Exchange('statistics'), routing_key='statistics', delivery_mode=1 ), ) ) app.conf.CELERY_ROUTES.update( { 'mayan_statistics.tasks.task_execute_statistic': { 'queue': 'statistics' }, } ) menu_object.bind_links( links=(link_execute, link_view), sources=(Statistic,) ) menu_object.bind_links( links=(link_namespace_details,), sources=(StatisticNamespace,) ) menu_secondary.bind_links( links=(link_namespace_list,), sources=(StatisticNamespace, 'statistics:namespace_list') ) menu_tools.bind_links(links=(link_statistics,))
def ready(self): super(MailerApp, self).ready() SourceColumn( source=LogEntry, label=_('Date and time'), attribute='datetime' ) SourceColumn( source=LogEntry, label=_('Message'), attribute='message' ) ModelPermission.register( model=Document, permissions=( permission_mailing_link, permission_mailing_send_document ) ) app.conf.CELERY_QUEUES.append( Queue('mailing', Exchange('mailing'), routing_key='mailing'), ) app.conf.CELERY_ROUTES.update( { 'mailer.tasks.task_send_document': { 'queue': 'mailing' }, } ) menu_object.bind_links( links=( link_send_document_link, link_send_document ), sources=(Document,) ) menu_tools.bind_links(links=(link_document_mailing_error_log,))
def ready(self): super(DocumentStatesApp, self).ready() Action = apps.get_model(app_label='actstream', model_name='Action') Document = apps.get_model(app_label='documents', model_name='Document') 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') WorkflowTransitionTriggerEvent = self.get_model( 'WorkflowTransitionTriggerEvent') Document.add_to_class('workflow', DocumentStateHelper.constructor) ErrorLogEntry.objects.register(model=WorkflowStateAction) WorkflowAction.initialize() ModelAttribute( 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')) ModelAttribute( 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')) 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_transition, permission_workflow_view, )) ModelPermission.register_inheritance( model=WorkflowInstance, related='workflow', ) ModelPermission.register_inheritance( model=WorkflowInstanceLogEntry, related='workflow_instance__workflow', ) ModelPermission.register( model=WorkflowTransition, permissions=(permission_workflow_transition, )) 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=WorkflowTransitionTriggerEvent, related='transition__workflow', ) SourceColumn(source=Workflow, label=_('Label'), attribute='label') SourceColumn(source=Workflow, label=_('Internal name'), attribute='internal_name') SourceColumn(source=Workflow, label=_('Initial state'), func=lambda context: context['object'].get_initial_state( ) or _('None')) SourceColumn(source=WorkflowInstance, label=_('Current state'), attribute='get_current_state') SourceColumn( source=WorkflowInstance, label=_('User'), func=lambda context: getattr( context['object'].get_last_log_entry(), 'user', _('None'))) SourceColumn(source=WorkflowInstance, label=_('Last transition'), attribute='get_last_transition') SourceColumn( source=WorkflowInstance, label=_('Date and time'), func=lambda context: getattr( context['object'].get_last_log_entry(), 'datetime', _('None'))) SourceColumn( source=WorkflowInstance, label=_('Completion'), func=lambda context: getattr(context['object'].get_current_state(), 'completion', _('None'))) SourceColumn(source=WorkflowInstanceLogEntry, label=_('Date and time'), attribute='datetime') SourceColumn(source=WorkflowInstanceLogEntry, label=_('User'), attribute='user') SourceColumn(source=WorkflowInstanceLogEntry, label=_('Transition'), attribute='transition') SourceColumn(source=WorkflowInstanceLogEntry, label=_('Comment'), attribute='comment') SourceColumn(source=WorkflowState, label=_('Is initial state?'), func=lambda context: TwoStateWidget(state=context[ 'object'].initial).render()) SourceColumn(source=WorkflowState, label=_('Completion'), attribute='completion') SourceColumn(source=WorkflowStateAction, label=_('Label'), attribute='label') SourceColumn(source=WorkflowStateAction, label=_('Enabled?'), func=lambda context: TwoStateWidget(state=context[ 'object'].enabled).render()) SourceColumn(source=WorkflowStateAction, label=_('When?'), attribute='get_when_display') SourceColumn(source=WorkflowStateAction, label=_('Action type'), attribute='get_class_label') SourceColumn(source=WorkflowTransition, label=_('Origin state'), attribute='origin_state') SourceColumn(source=WorkflowTransition, label=_('Destination state'), attribute='destination_state') SourceColumn(source=WorkflowTransition, label=_('Triggers'), func=lambda context: widget_transition_events( transition=context['object'])) app.conf.CELERY_QUEUES.extend((Queue('document_states', Exchange('document_states'), routing_key='document_states'), )) app.conf.CELERY_ROUTES.update({ 'document_states.tasks.task_launch_all_workflows': { 'queue': 'document_states' }, }) menu_facet.bind_links(links=(link_document_workflow_instance_list, ), sources=(Document, )) menu_main.bind_links(links=(link_workflow_list, ), position=10) menu_object.bind_links( links=(link_setup_workflow_states, link_setup_workflow_transitions, link_setup_workflow_document_types, link_setup_workflow_edit, link_acl_list, link_workflow_preview, link_setup_workflow_delete), sources=(Workflow, )) menu_object.bind_links(links=(link_setup_workflow_state_edit, link_setup_workflow_state_action_list, link_setup_workflow_state_delete), sources=(WorkflowState, )) menu_object.bind_links(links=(link_setup_workflow_transition_edit, link_workflow_instance_transition_events, link_acl_list, link_setup_workflow_transition_delete), sources=(WorkflowTransition, )) menu_object.bind_links(links=(link_workflow_instance_detail, link_workflow_instance_transition), sources=(WorkflowInstance, )) menu_object.bind_links(links=( link_workflow_document_list, link_workflow_state_list, ), sources=(WorkflowRuntimeProxy, )) menu_object.bind_links(links=(link_workflow_state_document_list, ), sources=(WorkflowStateRuntimeProxy, )) menu_object.bind_links(links=( link_setup_workflow_state_action_edit, link_object_error_list, link_setup_workflow_state_action_delete, ), sources=(WorkflowStateAction, )) menu_secondary.bind_links( links=(link_setup_workflow_list, link_setup_workflow_create), sources=(Workflow, 'document_states:setup_workflow_create', 'document_states:setup_workflow_list')) menu_secondary.bind_links(links=(link_workflow_list, ), sources=(WorkflowRuntimeProxy, )) menu_secondary.bind_links( links=(link_setup_workflow_state_action_selection, ), sources=(WorkflowState, )) menu_setup.bind_links(links=(link_setup_workflow_list, )) menu_sidebar.bind_links(links=(link_setup_workflow_state_create, link_setup_workflow_transition_create), sources=(Workflow, )) menu_tools.bind_links(links=(link_tool_launch_all_workflows, )) post_save.connect(launch_workflow, dispatch_uid='launch_workflow', sender=Document) # Index updating post_save.connect(handler_index_document, dispatch_uid='handler_index_document_save', sender=WorkflowInstanceLogEntry) post_save.connect( handler_trigger_transition, dispatch_uid='document_states_handler_trigger_transition', sender=Action)
def ready(self): super(MailerApp, self).ready() Document = apps.get_model( app_label='documents', model_name='Document' ) LogEntry = self.get_model('LogEntry') UserMailer = self.get_model('UserMailer') MailerBackend.initialize() SourceColumn( source=LogEntry, label=_('Date and time'), attribute='datetime' ) SourceColumn( source=LogEntry, label=_('Message'), attribute='message' ) SourceColumn( source=UserMailer, label=_('Label'), attribute='label' ) SourceColumn( source=UserMailer, label=_('Default?'), func=lambda context: TwoStateWidget( state=context['object'].default ).render() ) SourceColumn( source=UserMailer, label=_('Enabled?'), func=lambda context: TwoStateWidget( state=context['object'].enabled ).render() ) SourceColumn( source=UserMailer, label=_('Label'), attribute='backend_label' ) ModelPermission.register( model=Document, permissions=( permission_mailing_link, permission_mailing_send_document ) ) ModelPermission.register( model=UserMailer, permissions=( permission_acl_edit, permission_acl_view, permission_user_mailer_delete, permission_user_mailer_edit, permission_user_mailer_view, permission_user_mailer_use ) ) app.conf.CELERY_QUEUES.append( Queue('mailing', Exchange('mailing'), routing_key='mailing'), ) app.conf.CELERY_ROUTES.update( { 'mailer.tasks.task_send_document': { 'queue': 'mailing' }, } ) menu_multi_item.bind_links( links=( link_send_multiple_document, link_send_multiple_document_link ), sources=(Document,) ) menu_object.bind_links( links=( link_send_document_link, link_send_document ), sources=(Document,) ) menu_object.bind_links( links=( link_user_mailer_edit, link_user_mailer_log_list, link_user_mailer_test, link_acl_list, link_user_mailer_delete, ), sources=(UserMailer,) ) menu_secondary.bind_links( links=( link_user_mailer_list, link_user_mailer_create, ), sources=( UserMailer, 'mailer:user_mailer_list', 'mailer:user_mailer_create' ) ) menu_tools.bind_links(links=(link_system_mailer_error_log,)) menu_setup.bind_links(links=(link_user_mailer_setup,))
def ready(self): super(EventsApp, self).ready() Action = apps.get_model(app_label='actstream', model_name='Action') Notification = self.get_model(model_name='Notification') StoredEventType = self.get_model(model_name='StoredEventType') User = get_user_model() SourceColumn( source=Action, label=_('Timestamp'), attribute='timestamp' ) SourceColumn( source=Action, label=_('Actor'), func=lambda context: event_user_link(context['object']) ) SourceColumn( source=Action, label=_('Event'), func=lambda context: event_type_link(context['object']) ) SourceColumn( source=Action, label=_('Action object'), func=lambda context: event_object_link( entry=context['object'], attribute='action_object' ) ) SourceColumn( source=StoredEventType, label=_('Namespace'), attribute='namespace' ) SourceColumn( source=StoredEventType, label=_('Label'), attribute='label' ) SourceColumn( source=Notification, label=_('Timestamp'), attribute='action.timestamp' ) SourceColumn( source=Notification, label=_('Actor'), attribute='action.actor' ) SourceColumn( source=Notification, label=_('Event'), func=lambda context: event_type_link(context['object'].action) ) SourceColumn( source=Notification, label=_('Target'), func=lambda context: event_object_link(context['object'].action) ) SourceColumn( source=Notification, label=_('Seen'), func=lambda context: TwoStateWidget( state=context['object'].read ).render() ) menu_main.bind_links( links=(link_user_notifications_list,), position=99 ) menu_object.bind_links( links=(link_notification_mark_read,), sources=(Notification,) ) menu_object.bind_links( links=(link_user_events,), sources=(User,) ) menu_secondary.bind_links( links=(link_notification_mark_read_all,), sources=('events:user_notifications_list',) ) menu_tools.bind_links(links=(link_events_list,)) menu_user.bind_links(links=(link_event_types_subscriptions_list,))
def ready(self): super(TaskManagerApp, self).ready() SourceColumn( source=CeleryQueue, label=_('Label'), attribute='label' ) SourceColumn( source=CeleryQueue, label=_('Name'), attribute='name' ) SourceColumn( source=CeleryQueue, label=_('Default queue?'), func=lambda context: TwoStateWidget( state=context['object'].is_default_queue ).render() ) SourceColumn( source=CeleryQueue, label=_('Is transient?'), func=lambda context: TwoStateWidget( state=context['object'].is_transient ).render() ) SourceColumn( source=Task, label=_('Type'), attribute='task_type' ) SourceColumn( source=Task, label=_('Start time'), attribute='get_time_started' ) SourceColumn( source=Task, label=_('Host'), func=lambda context: context['object'].kwargs['hostname'] ) SourceColumn( source=Task, label=_('Acknowledged'), func=lambda context: TwoStateWidget( state=context['object'].kwargs['acknowledged'] ).render() ) SourceColumn( source=Task, label=_('Arguments'), func=lambda context: context['object'].kwargs['args'] ) SourceColumn( source=Task, label=_('Keyword arguments'), func=lambda context: context['object'].kwargs['kwargs'] ) SourceColumn( source=Task, label=_('Worker process ID'), func=lambda context: context['object'].kwargs['worker_pid'] ) menu_object.bind_links( links=( link_queue_active_task_list, link_queue_scheduled_task_list, link_queue_reserved_task_list, ), sources=(CeleryQueue,) ) menu_secondary.bind_links( links=(link_queue_list,), sources=(CeleryQueue, Task, 'task_manager:queue_list') ) menu_tools.bind_links(links=(link_task_manager,))
def ready(self): super(DocumentStatesApp, self).ready() APIEndPoint(app=self, version_string='1') Document = apps.get_model( app_label='documents', model_name='Document' ) Document.add_to_class( 'workflow', DocumentStateHelper.constructor ) 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') WorkflowStateRuntimeProxy = self.get_model('WorkflowStateRuntimeProxy') WorkflowTransition = self.get_model('WorkflowTransition') ModelAttribute( Document, 'workflow.< workflow internal name >.get_current_state', label=_('Current state of a workflow'), description=_( 'Return the current state of the selected workflow' ), type_name=['property', 'indexing'] ) ModelAttribute( Document, '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' ), type_name=['property', 'indexing'] ) ModelPermission.register( model=Workflow, permissions=(permission_workflow_transition,) ) ModelPermission.register( model=WorkflowTransition, permissions=(permission_workflow_transition,) ) SourceColumn( source=Workflow, label=_('Label'), attribute='label' ) SourceColumn( source=Workflow, label=_('Internal name'), attribute='internal_name' ) SourceColumn( source=Workflow, label=_('Initial state'), func=lambda context: context['object'].get_initial_state() or _('None') ) SourceColumn( source=WorkflowInstance, label=_('Current state'), attribute='get_current_state' ) SourceColumn( source=WorkflowInstance, label=_('User'), func=lambda context: getattr( context['object'].get_last_log_entry(), 'user', _('None') ) ) SourceColumn( source=WorkflowInstance, label=_('Last transition'), attribute='get_last_transition' ) SourceColumn( source=WorkflowInstance, label=_('Date and time'), func=lambda context: getattr( context['object'].get_last_log_entry(), 'datetime', _('None') ) ) SourceColumn( source=WorkflowInstance, label=_('Completion'), func=lambda context: getattr( context['object'].get_current_state(), 'completion', _('None') ) ) SourceColumn( source=WorkflowInstanceLogEntry, label=_('Date and time'), attribute='datetime' ) SourceColumn( source=WorkflowInstanceLogEntry, label=_('User'), attribute='user' ) SourceColumn( source=WorkflowInstanceLogEntry, label=_('Transition'), attribute='transition' ) SourceColumn( source=WorkflowInstanceLogEntry, label=_('Comment'), attribute='comment' ) SourceColumn( source=WorkflowState, label=_('Is initial state?'), func=lambda context: two_state_template(context['object'].initial) ) SourceColumn( source=WorkflowState, label=_('Completion'), attribute='completion' ) SourceColumn( source=WorkflowTransition, label=_('Origin state'), attribute='origin_state' ) SourceColumn( source=WorkflowTransition, label=_('Destination state'), attribute='destination_state' ) app.conf.CELERY_QUEUES.extend( ( Queue( 'document_states', Exchange('document_states'), routing_key='document_states' ), ) ) app.conf.CELERY_ROUTES.update( { 'document_states.tasks.task_launch_all_workflows': { 'queue': 'document_states' }, } ) menu_facet.bind_links( links=(link_document_workflow_instance_list,), sources=(Document,) ) menu_main.bind_links(links=(link_workflow_list,), position=10) menu_object.bind_links( links=( link_setup_workflow_states, link_setup_workflow_transitions, link_setup_workflow_document_types, link_setup_workflow_edit, link_acl_list, link_setup_workflow_delete ), sources=(Workflow,) ) menu_object.bind_links( links=( link_setup_workflow_state_edit, link_setup_workflow_state_delete ), sources=(WorkflowState,) ) menu_object.bind_links( links=( link_setup_workflow_transition_edit, link_acl_list, link_setup_workflow_transition_delete ), sources=(WorkflowTransition,) ) menu_object.bind_links( links=( link_workflow_instance_detail, link_workflow_instance_transition ), sources=(WorkflowInstance,) ) menu_object.bind_links( links=( link_workflow_document_list, link_workflow_state_list, ), sources=(WorkflowRuntimeProxy,) ) menu_object.bind_links( links=( link_workflow_state_document_list, ), sources=(WorkflowStateRuntimeProxy,) ) menu_secondary.bind_links( links=(link_setup_workflow_list, link_setup_workflow_create), sources=( Workflow, 'document_states:setup_workflow_create', 'document_states:setup_workflow_list' ) ) menu_secondary.bind_links( links=(link_workflow_list,), sources=( WorkflowRuntimeProxy, ) ) menu_setup.bind_links(links=(link_setup_workflow_list,)) menu_sidebar.bind_links( links=( link_setup_workflow_state_create, link_setup_workflow_transition_create ), sources=(Workflow,) ) menu_tools.bind_links(links=(link_tool_launch_all_workflows,)) post_save.connect( launch_workflow, dispatch_uid='launch_workflow', sender=Document ) # Index updating post_save.connect( handler_index_document, dispatch_uid='handler_index_document_save', sender=WorkflowInstanceLogEntry )
def ready(self): super(DocumentIndexingApp, self).ready() APIEndPoint(app=self, version_string='1') Document = apps.get_model( app_label='documents', model_name='Document' ) DocumentType = apps.get_model( app_label='documents', model_name='DocumentType' ) DocumentIndexInstanceNode = self.get_model('DocumentIndexInstanceNode') Index = self.get_model('Index') IndexInstance = self.get_model('IndexInstance') IndexInstanceNode = self.get_model('IndexInstanceNode') IndexTemplateNode = self.get_model('IndexTemplateNode') ModelPermission.register( model=Index, permissions=( permission_acl_edit, permission_acl_view, permission_document_indexing_create, permission_document_indexing_delete, permission_document_indexing_edit, permission_document_indexing_view, ) ) SourceColumn(source=Index, label=_('Label'), attribute='label') SourceColumn(source=Index, label=_('Slug'), attribute='slug') SourceColumn( source=Index, label=_('Enabled'), func=lambda context: two_state_template(context['object'].enabled) ) SourceColumn( source=IndexInstance, label=_('Total levels'), func=lambda context: context[ 'object' ].instance_root.get_descendants_count() ) SourceColumn( source=IndexInstance, label=_('Total documents'), func=lambda context: context[ 'object' ].instance_root.get_descendants_document_count( user=context['request'].user ) ) SourceColumn( source=IndexInstance, label=_('Document types'), attribute='get_document_types_names' ) SourceColumn( source=IndexTemplateNode, label=_('Level'), func=lambda context: node_level(context['object']) ) SourceColumn( source=IndexTemplateNode, label=_('Enabled'), func=lambda context: two_state_template(context['object'].enabled) ) SourceColumn( source=IndexTemplateNode, label=_('Has document links?'), func=lambda context: two_state_template( context['object'].link_documents ) ) SourceColumn( source=IndexInstanceNode, label=_('Level'), func=lambda context: index_instance_item_link(context['object']) ) SourceColumn( source=IndexInstanceNode, label=_('Levels'), func=lambda context: context['object'].get_descendants_count() ) SourceColumn( source=IndexInstanceNode, label=_('Documents'), func=lambda context: context[ 'object' ].get_descendants_document_count( user=context['request'].user ) ) SourceColumn( source=DocumentIndexInstanceNode, label=_('Level'), func=lambda context: get_instance_link( index_instance_node=context['object'], ) ) SourceColumn( source=DocumentIndexInstanceNode, label=_('Levels'), func=lambda context: context['object'].get_descendants_count() ) SourceColumn( source=DocumentIndexInstanceNode, label=_('Documents'), func=lambda context: context[ 'object' ].get_descendants_document_count( user=context['request'].user ) ) app.conf.CELERY_QUEUES.append( Queue('indexing', Exchange('indexing'), routing_key='indexing'), ) app.conf.CELERY_ROUTES.update( { 'document_indexing.tasks.task_delete_empty': { 'queue': 'indexing' }, 'document_indexing.tasks.task_remove_document': { 'queue': 'indexing' }, 'document_indexing.tasks.task_index_document': { 'queue': 'indexing' }, 'document_indexing.tasks.task_rebuild_index': { 'queue': 'tools' }, } ) menu_facet.bind_links( links=(link_document_index_list,), sources=(Document,) ) menu_object.bind_links( links=( link_index_setup_edit, link_index_setup_view, link_index_setup_document_types, link_acl_list, link_index_setup_delete ), sources=(Index,) ) menu_object.bind_links( links=( link_template_node_create, link_template_node_edit, link_template_node_delete ), sources=(IndexTemplateNode,) ) menu_main.bind_links(links=(link_index_main_menu,), position=98) menu_secondary.bind_links( links=(link_index_setup_list, link_index_setup_create), sources=( Index, 'indexing:index_setup_list', 'indexing:index_setup_create' ) ) menu_setup.bind_links(links=(link_index_setup,)) menu_tools.bind_links(links=(link_rebuild_index_instances,)) post_delete.connect( handler_delete_empty, dispatch_uid='handler_delete_empty', sender=Document ) pre_delete.connect( handler_remove_document, dispatch_uid='handler_remove_document', sender=Document ) post_document_created.connect( handler_index_document, dispatch_uid='handler_index_document', sender=Document ) post_initial_document_type.connect( create_default_document_index, dispatch_uid='create_default_document_index', sender=DocumentType )
def ready(self): super(DocumentIndexingApp, self).ready() Document = apps.get_model(app_label='documents', model_name='Document') DocumentType = apps.get_model(app_label='documents', model_name='DocumentType') DocumentMetadata = apps.get_model(app_label='metadata', model_name='DocumentMetadata') DocumentIndexInstanceNode = self.get_model('DocumentIndexInstanceNode') Index = self.get_model('Index') IndexInstance = self.get_model('IndexInstance') IndexInstanceNode = self.get_model('IndexInstanceNode') IndexTemplateNode = self.get_model('IndexTemplateNode') APIEndPoint(app=self, version_string='1') ModelPermission.register(model=Index, permissions=( permission_acl_edit, permission_acl_view, permission_document_indexing_create, permission_document_indexing_delete, permission_document_indexing_edit, permission_document_indexing_view, )) Package(label='Django MPTT', license_text=''' Django MPTT ----------- Copyright (c) 2007, Jonathan Buchanan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ''') Package(label='djangorestframework-recursive', license_text=''' Copyright (c) 2015, Warren Jin <*****@*****.**> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ''') SourceColumn(source=Index, label=_('Label'), attribute='label') SourceColumn(source=Index, label=_('Slug'), attribute='slug') SourceColumn( source=Index, label=_('Enabled'), func=lambda context: two_state_template(context['object'].enabled)) SourceColumn(source=IndexInstance, label=_('Items'), func=lambda context: context['object'].get_item_count( user=context['request'].user)) SourceColumn(source=IndexInstance, label=_('Document types'), attribute='get_document_types_names') SourceColumn(source=IndexTemplateNode, label=_('Level'), func=lambda context: node_level(context['object'])) SourceColumn( source=IndexTemplateNode, label=_('Enabled'), func=lambda context: two_state_template(context['object'].enabled)) SourceColumn(source=IndexTemplateNode, label=_('Has document links?'), func=lambda context: two_state_template(context['object']. link_documents)) SourceColumn( source=IndexInstanceNode, label=_('Node'), func=lambda context: index_instance_item_link(context['object'])) SourceColumn(source=IndexInstanceNode, label=_('Items'), func=lambda context: context['object'].get_item_count( user=context['request'].user)) SourceColumn(source=DocumentIndexInstanceNode, label=_('Node'), func=lambda context: get_instance_link( index_instance_node=context['object'], )) SourceColumn(source=DocumentIndexInstanceNode, label=_('Items'), func=lambda context: context['object'].get_item_count( user=context['request'].user)) app.conf.CELERY_QUEUES.append( Queue('indexing', Exchange('indexing'), routing_key='indexing'), ) app.conf.CELERY_ROUTES.update({ 'document_indexing.tasks.task_delete_empty_index_nodes': { 'queue': 'indexing' }, 'document_indexing.tasks.task_index_document': { 'queue': 'indexing' }, 'document_indexing.tasks.task_do_rebuild_all_indexes': { 'queue': 'tools' }, }) menu_facet.bind_links(links=(link_document_index_list, ), sources=(Document, )) menu_object.bind_links(links=(link_index_setup_edit, link_index_setup_view, link_index_setup_document_types, link_acl_list, link_index_setup_delete), sources=(Index, )) menu_object.bind_links(links=(link_template_node_create, link_template_node_edit, link_template_node_delete), sources=(IndexTemplateNode, )) menu_main.bind_links(links=(link_index_main_menu, )) menu_secondary.bind_links(links=(link_index_setup_list, link_index_setup_create), sources=(Index, 'indexing:index_setup_list', 'indexing:index_setup_create')) menu_setup.bind_links(links=(link_index_setup, )) menu_tools.bind_links(links=(link_rebuild_index_instances, )) post_delete.connect(document_index_delete, dispatch_uid='document_index_delete', sender=Document) post_delete.connect(document_metadata_index_post_delete, dispatch_uid='document_metadata_index_post_delete', sender=DocumentMetadata) post_document_created.connect( document_created_index_update, dispatch_uid='document_created_index_update', sender=Document) post_initial_document_type.connect( create_default_document_index, dispatch_uid='create_default_document_index', sender=DocumentType) post_save.connect(document_metadata_index_update, dispatch_uid='document_metadata_index_update', sender=DocumentMetadata)
def ready(self): super(DocumentStatesApp, self).ready() Action = apps.get_model( app_label='actstream', model_name='Action' ) Document = apps.get_model( app_label='documents', model_name='Document' ) 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') WorkflowTransitionTriggerEvent = self.get_model( 'WorkflowTransitionTriggerEvent' ) Document.add_to_class( 'workflow', DocumentStateHelper.constructor ) ErrorLogEntry.objects.register(model=WorkflowStateAction) WorkflowAction.initialize() ModelAttribute( 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' ) ) ModelAttribute( 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' ) ) 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_transition, permission_workflow_view, ) ) ModelPermission.register_inheritance( model=WorkflowInstance, related='workflow', ) ModelPermission.register_inheritance( model=WorkflowInstanceLogEntry, related='workflow_instance__workflow', ) ModelPermission.register( model=WorkflowTransition, permissions=(permission_workflow_transition,) ) 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=WorkflowTransitionTriggerEvent, related='transition__workflow', ) SourceColumn( source=Workflow, label=_('Label'), attribute='label' ) SourceColumn( source=Workflow, label=_('Internal name'), attribute='internal_name' ) SourceColumn( source=Workflow, label=_('Initial state'), func=lambda context: context['object'].get_initial_state() or _('None') ) SourceColumn( source=WorkflowInstance, label=_('Current state'), attribute='get_current_state' ) SourceColumn( source=WorkflowInstance, label=_('User'), func=lambda context: getattr( context['object'].get_last_log_entry(), 'user', _('None') ) ) SourceColumn( source=WorkflowInstance, label=_('Last transition'), attribute='get_last_transition' ) SourceColumn( source=WorkflowInstance, label=_('Date and time'), func=lambda context: getattr( context['object'].get_last_log_entry(), 'datetime', _('None') ) ) SourceColumn( source=WorkflowInstance, label=_('Completion'), func=lambda context: getattr( context['object'].get_current_state(), 'completion', _('None') ) ) SourceColumn( source=WorkflowInstanceLogEntry, label=_('Date and time'), attribute='datetime' ) SourceColumn( source=WorkflowInstanceLogEntry, label=_('User'), attribute='user' ) SourceColumn( source=WorkflowInstanceLogEntry, label=_('Transition'), attribute='transition' ) SourceColumn( source=WorkflowInstanceLogEntry, label=_('Comment'), attribute='comment' ) SourceColumn( source=WorkflowState, label=_('Is initial state?'), func=lambda context: TwoStateWidget( state=context['object'].initial ).render() ) SourceColumn( source=WorkflowState, label=_('Completion'), attribute='completion' ) SourceColumn( source=WorkflowStateAction, label=_('Label'), attribute='label' ) SourceColumn( source=WorkflowStateAction, label=_('Enabled?'), func=lambda context: TwoStateWidget( state=context['object'].enabled ).render() ) SourceColumn( source=WorkflowStateAction, label=_('When?'), attribute='get_when_display' ) SourceColumn( source=WorkflowStateAction, label=_('Action type'), attribute='get_class_label' ) SourceColumn( source=WorkflowTransition, label=_('Origin state'), attribute='origin_state' ) SourceColumn( source=WorkflowTransition, label=_('Destination state'), attribute='destination_state' ) SourceColumn( source=WorkflowTransition, label=_('Triggers'), func=lambda context: widget_transition_events( transition=context['object'] ) ) app.conf.CELERY_QUEUES.extend( ( Queue( 'document_states', Exchange('document_states'), routing_key='document_states' ), ) ) app.conf.CELERY_ROUTES.update( { 'document_states.tasks.task_launch_all_workflows': { 'queue': 'document_states' }, } ) menu_facet.bind_links( links=(link_document_workflow_instance_list,), sources=(Document,) ) menu_main.bind_links(links=(link_workflow_list,), position=10) menu_object.bind_links( links=( link_setup_workflow_states, link_setup_workflow_transitions, link_setup_workflow_document_types, link_setup_workflow_edit, link_acl_list, link_workflow_preview, link_setup_workflow_delete ), sources=(Workflow,) ) menu_object.bind_links( links=( link_setup_workflow_state_edit, link_setup_workflow_state_action_list, link_setup_workflow_state_delete ), sources=(WorkflowState,) ) menu_object.bind_links( links=( link_setup_workflow_transition_edit, link_workflow_instance_transition_events, link_acl_list, link_setup_workflow_transition_delete ), sources=(WorkflowTransition,) ) menu_object.bind_links( links=( link_workflow_instance_detail, link_workflow_instance_transition ), sources=(WorkflowInstance,) ) menu_object.bind_links( links=( link_workflow_document_list, link_workflow_state_list, ), sources=(WorkflowRuntimeProxy,) ) menu_object.bind_links( links=( link_workflow_state_document_list, ), sources=(WorkflowStateRuntimeProxy,) ) menu_object.bind_links( links=( link_setup_workflow_state_action_edit, link_object_error_list, link_setup_workflow_state_action_delete, ), sources=(WorkflowStateAction,) ) menu_secondary.bind_links( links=(link_setup_workflow_list, link_setup_workflow_create), sources=( Workflow, 'document_states:setup_workflow_create', 'document_states:setup_workflow_list' ) ) menu_secondary.bind_links( links=(link_workflow_list,), sources=( WorkflowRuntimeProxy, ) ) menu_secondary.bind_links( links=(link_setup_workflow_state_action_selection,), sources=( WorkflowState, ) ) menu_setup.bind_links(links=(link_setup_workflow_list,)) menu_sidebar.bind_links( links=( link_setup_workflow_state_create, link_setup_workflow_transition_create ), sources=(Workflow,) ) menu_tools.bind_links(links=(link_tool_launch_all_workflows,)) post_save.connect( launch_workflow, dispatch_uid='launch_workflow', sender=Document ) # Index updating post_save.connect( handler_index_document, dispatch_uid='handler_index_document_save', sender=WorkflowInstanceLogEntry ) post_save.connect( handler_trigger_transition, dispatch_uid='document_states_handler_trigger_transition', sender=Action )
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('DocumentVersionOCRError') Document.add_to_class('submit_for_ocr', document_ocr_submit) DocumentVersion.add_to_class( 'ocr_content', get_document_ocr_content ) DocumentVersion.add_to_class( 'submit_for_ocr', document_version_ocr_submit ) ModelField( Document, name='versions__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( source=DocumentVersionOCRError, label=_('Document'), func=lambda context: document_link(context['object'].document_version.document) ) SourceColumn( source=DocumentVersionOCRError, label=_('Added'), attribute='datetime_submitted' ) SourceColumn( source=DocumentVersionOCRError, label=_('Result'), attribute='result' ) app.conf.CELERY_QUEUES.append( Queue('ocr', Exchange('ocr'), routing_key='ocr'), ) app.conf.CELERY_ROUTES.update( { 'ocr.tasks.task_do_ocr': { 'queue': 'ocr' }, } ) document_search.add_model_field( field='versions__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_facet.bind_links( links=(link_document_page_ocr_content,), sources=(DocumentPage,) ) menu_multi_item.bind_links( links=(link_document_submit_multiple,), sources=(Document,) ) menu_object.bind_links( links=(link_document_submit,), sources=(Document,) ) menu_object.bind_links( links=(link_document_page_ocr_content,), sources=(DocumentPage,) ) menu_object.bind_links( links=(link_document_type_ocr_settings,), sources=(DocumentType,) ) menu_secondary.bind_links( links=( link_document_ocr_content, link_document_ocr_errors_list, link_document_ocr_download ), sources=( 'ocr:document_content', 'ocr:document_ocr_error_list', 'ocr:document_ocr_download', ) ) 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, 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 APIEndPoint(app=self, version_string='1') DeletedDocument = self.get_model('DeletedDocument') Document = self.get_model('Document') DocumentPage = self.get_model('DocumentPage') DocumentPageResult = self.get_model('DocumentPageResult') DocumentType = self.get_model('DocumentType') DocumentTypeFilename = self.get_model('DocumentTypeFilename') DocumentVersion = self.get_model('DocumentVersion') DuplicatedDocument = self.get_model('DuplicatedDocument') Collection( label=_('Recent documents'), link=link_document_list_recent, order=1 ) Collection( label=_('Document types'), model=DocumentType, icon='fa fa-book' ) Collection( label=_('All documents'), link=link_document_list, order=99 ) Collection( label=_('Trash'), link=link_document_list_deleted, order=100 ) DynamicSerializerField.add_serializer( klass=Document, serializer_class='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' ) ModelAttribute( Document, label=_('Label'), name='label', type_name='field' ) ModelAttribute( Document, description=_('The MIME type of any of the versions of a document'), label=_('MIME type'), name='versions__mimetype', type_name='field' ) 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_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 ) ) ModelPermission.register_proxy( source=Document, model=DocumentType, ) ModelPermission.register_inheritance( model=Document, related='document_type', ) ModelPermission.register_inheritance( model=DocumentPage, related='document', ) 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_thumbnail_widget = DocumentThumbnailWidget() document_version_thumbnail_widget = DocumentVersionThumbnailWidget() # Document SourceColumn( source=Document, label=_('Thumbnail'), func=lambda context: document_thumbnail_widget.render( instance=context['object'] ) ) SourceColumn( source=Document, label=_('Type'), attribute='document_type' ) # DocumentPage SourceColumn( source=DocumentPage, label=_('Thumbnail'), func=lambda context: document_page_thumbnail_widget.render( instance=context['object'] ) ) SourceColumn( source=DocumentPageResult, label=_('Thumbnail'), func=lambda context: document_page_thumbnail_widget.render( instance=context['object'] ) ) SourceColumn( source=DocumentPageResult, label=_('Type'), attribute='document_version.document.document_type' ) # DocumentType SourceColumn( source=DocumentType, label=_('Documents'), func=lambda context: context['object'].get_document_count( user=context['request'].user ) ) SourceColumn( source=DocumentTypeFilename, label=_('Enabled'), func=lambda context: two_state_template(context['object'].enabled) ) # DeletedDocument SourceColumn( source=DeletedDocument, label=_('Thumbnail'), func=lambda context: document_thumbnail_widget.render( instance=context['object'] ) ) SourceColumn( source=DeletedDocument, label=_('Type'), attribute='document_type' ) SourceColumn( source=DeletedDocument, label=_('Date time trashed'), attribute='deleted_date_time' ) # DocumentVersion SourceColumn( source=DocumentVersion, label=_('Time and date'), attribute='timestamp' ) SourceColumn( source=DocumentVersion, label=_('MIME type'), attribute='mimetype' ) SourceColumn( source=DocumentVersion, label=_('Encoding'), attribute='encoding' ) SourceColumn( source=DocumentVersion, label=_('Comment'), attribute='comment' ) SourceColumn( source=DocumentVersion, label=_('Thumbnail'), func=lambda context: document_version_thumbnail_widget.render( instance=context['object'] ) ) # DuplicatedDocument 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( { 'task_check_delete_periods': { 'task': 'documents.tasks.task_check_delete_periods', 'schedule': timedelta( seconds=CHECK_DELETE_PERIOD_INTERVAL ), }, 'task_check_trash_periods': { 'task': 'documents.tasks.task_check_trash_periods', 'schedule': timedelta(seconds=CHECK_TRASH_PERIOD_INTERVAL), }, 'task_delete_stubs': { 'task': 'documents.tasks.task_delete_stubs', 'schedule': timedelta(seconds=DELETE_STALE_STUBS_INTERVAL), }, } ) app.conf.CELERY_QUEUES.extend( ( Queue( 'converter', Exchange('converter'), routing_key='converter', delivery_mode=1 ), Queue( 'documents_periodic', Exchange('documents_periodic'), routing_key='documents_periodic', delivery_mode=1 ), Queue('uploads', Exchange('uploads'), routing_key='uploads'), Queue( 'documents', Exchange('documents'), routing_key='documents' ), ) ) app.conf.CELERY_ROUTES.update( { 'documents.tasks.task_check_delete_periods': { 'queue': 'documents_periodic' }, 'documents.tasks.task_check_trash_periods': { 'queue': 'documents_periodic' }, 'documents.tasks.task_delete_stubs': { 'queue': 'documents_periodic' }, 'documents.tasks.task_clear_image_cache': { 'queue': 'tools' }, 'documents.tasks.task_generate_document_page_image': { 'queue': 'converter' }, 'documents.tasks.task_update_page_count': { 'queue': 'uploads' }, 'documents.tasks.task_upload_new_version': { 'queue': 'uploads' }, 'documents.tasks.task_scan_duplicates_all': { 'queue': 'tools' }, 'documents.tasks.task_scan_duplicates_for': { 'queue': 'uploads' }, 'documents.tasks.task_delete_document': { 'queue': 'documents' }, } ) dashboard_main.add_widget(widget=widget_document_types) dashboard_main.add_widget(widget=widget_documents_in_trash) dashboard_main.add_widget(widget=widget_new_documents_this_month) dashboard_main.add_widget(widget=widget_pages_per_month) dashboard_main.add_widget(widget=widget_total_documents) menu_documents.bind_links( links=( link_document_list_recent, 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_clear_image_cache, link_duplicated_document_scan) ) # Document type links menu_object.bind_links( links=( link_document_type_edit, link_document_type_filename_list, link_acl_list, link_document_type_delete ), 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_sidebar.bind_links( links=(link_document_type_filename_create,), sources=( DocumentTypeFilename, 'documents:document_type_filename_list', 'documents:document_type_filename_create' ) ) menu_sidebar.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_edit, link_document_document_type_edit, link_document_print, link_document_trash, 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_with_icon,), 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_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_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.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_return, 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, link_transformation_list ), sources=(DocumentPage,) ) menu_object.bind_links( links=(link_transformation_list,), sources=(DocumentPage,) ) # Document versions menu_facet.bind_links( links=( link_document_version_return_document, link_document_version_return_list ), sources=(DocumentVersion,) ) menu_facet.bind_links( links=(link_document_version_view,), sources=(DocumentVersion,) ) namespace = StatisticNamespace(slug='documents', label=_('Documents')) namespace.add_statistic( slug='new-documents-per-month', label=_('New documents per month'), func=new_documents_per_month, renderer=CharJSLine, minute='0' ) namespace.add_statistic( slug='new-document-versions-per-month', label=_('New document versions per month'), func=new_document_versions_per_month, renderer=CharJSLine, minute='0' ) namespace.add_statistic( slug='new-document-pages-per-month', label=_('New document pages per month'), func=new_document_pages_per_month, renderer=CharJSLine, minute='0' ) namespace.add_statistic( slug='total-documents-at-each-month', label=_('Total documents at each month'), func=total_document_per_month, renderer=CharJSLine, minute='0' ) namespace.add_statistic( slug='total-document-versions-at-each-month', label=_('Total document versions at each month'), func=total_document_version_per_month, renderer=CharJSLine, minute='0' ) namespace.add_statistic( slug='total-document-pages-at-each-month', label=_('Total document pages at each month'), func=total_document_page_per_month, renderer=CharJSLine, minute='0' ) post_initial_setup.connect( 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) registry.register(DocumentType) registry.register(DocumentVersion)
def ready(self): super(OCRApp, self).ready() Document = apps.get_model(app_label='documents', model_name='Document') DocumentType = apps.get_model(app_label='documents', model_name='DocumentType') DocumentVersion = apps.get_model(app_label='documents', model_name='DocumentVersion') DocumentVersionOCRError = self.get_model('DocumentVersionOCRError') APIEndPoint(app=self, version_string='1') Document.add_to_class('submit_for_ocr', document_ocr_submit) DocumentVersion.add_to_class('submit_for_ocr', document_version_ocr_submit) ModelPermission.register(model=Document, permissions=(permission_ocr_document, permission_ocr_content_view)) SourceColumn(source=DocumentVersionOCRError, label=_('Document'), func=lambda context: document_link(context[ 'object'].document_version.document)) SourceColumn(source=DocumentVersionOCRError, label=_('Added'), attribute='datetime_submitted') SourceColumn(source=DocumentVersionOCRError, label=_('Result'), attribute='result') app.conf.CELERY_QUEUES.append( Queue('ocr', Exchange('ocr'), routing_key='ocr'), ) app.conf.CELERY_ROUTES.update({ 'ocr.tasks.task_do_ocr': { 'queue': 'ocr' }, }) document_search.add_model_field( field='versions__pages__ocr_content__content', label=_('OCR')) menu_facet.bind_links(links=(link_document_content, ), sources=(Document, )) menu_multi_item.bind_links(links=(link_document_submit_multiple, ), sources=(Document, )) menu_object.bind_links(links=(link_document_submit, ), sources=(Document, )) menu_object.bind_links(links=(link_document_type_ocr_settings, ), sources=(DocumentType, )) 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_submit_all, link_document_type_submit, link_entry_list)) post_save.connect(initialize_new_ocr_settings, dispatch_uid='initialize_new_ocr_settings', sender=DocumentType) post_version_upload.connect(post_version_upload_ocr, dispatch_uid='post_version_upload_ocr', sender=DocumentVersion) namespace = PropertyNamespace('ocr', _('OCR')) try: pdftotext = sh.Command(setting_pdftotext_path.value) except sh.CommandNotFound: namespace.add_property('pdftotext', _('pdftotext version'), _('not found'), report=True) except Exception: namespace.add_property('pdftotext', _('pdftotext version'), _('error getting version'), report=True) else: namespace.add_property('pdftotext', _('pdftotext version'), pdftotext('-v').stderr, report=True) try: tesseract = sh.Command(setting_tesseract_path.value) except sh.CommandNotFound: namespace.add_property('tesseract', _('tesseract version'), _('not found'), report=True) except Exception: namespace.add_property('tesseract', _('tesseract version'), _('error getting version'), report=True) else: namespace.add_property('tesseract', _('tesseract version'), tesseract('-v').stderr, report=True)
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(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 )
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('DocumentVersionOCRError') Document.add_to_class('submit_for_ocr', document_ocr_submit) DocumentVersion.add_to_class('ocr_content', get_document_ocr_content) DocumentVersion.add_to_class('submit_for_ocr', document_version_ocr_submit) ModelField(Document, name='versions__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(source=DocumentVersionOCRError, label=_('Document'), func=lambda context: document_link(context[ 'object'].document_version.document)) SourceColumn(source=DocumentVersionOCRError, label=_('Added'), attribute='datetime_submitted') SourceColumn(source=DocumentVersionOCRError, label=_('Result'), attribute='result') app.conf.CELERY_QUEUES.append( Queue('ocr', Exchange('ocr'), routing_key='ocr'), ) app.conf.CELERY_ROUTES.update({ 'ocr.tasks.task_do_ocr': { 'queue': 'ocr' }, }) document_search.add_model_field( field='versions__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_facet.bind_links(links=(link_document_page_ocr_content, ), sources=(DocumentPage, )) menu_multi_item.bind_links(links=(link_document_submit_multiple, ), sources=(Document, )) menu_object.bind_links(links=(link_document_submit, ), sources=(Document, )) menu_object.bind_links(links=(link_document_page_ocr_content, ), sources=(DocumentPage, )) menu_object.bind_links(links=(link_document_type_ocr_settings, ), sources=(DocumentType, )) menu_secondary.bind_links(links=(link_document_ocr_content, link_document_ocr_errors_list, link_document_ocr_download), sources=( 'ocr:document_content', 'ocr:document_ocr_error_list', 'ocr:document_ocr_download', )) 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_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('DeletedDocument') Document = self.get_model('Document') DocumentPage = self.get_model('DocumentPage') DocumentPageResult = self.get_model('DocumentPageResult') 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, serializer_class='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' ) ModelField(Document, name='description') ModelField(Document, name='date_added') ModelField(Document, name='deleted_date_time') ModelField(Document, name='document_type__label') ModelField(Document, name='in_trash') ModelField(Document, name='is_stub') ModelField(Document, name='label') ModelField(Document, name='language') ModelField(Document, name='uuid') ModelField( Document, name='versions__checksum' ) ModelField( Document, label=_('Versions comment'), name='versions__comment' ) ModelField( Document, label=_('Versions encoding'), name='versions__encoding' ) ModelField( Document, label=_('Versions mime type'), name='versions__mimetype' ) ModelField( Document, label=_('Versions timestamp'), name='versions__timestamp' ) 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_change, event_document_new_version, event_document_version_revert, event_document_view ) ) 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_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 ) ) ModelPermission.register_proxy( source=Document, model=DocumentType, ) ModelPermission.register_inheritance( model=Document, related='document_type', ) ModelPermission.register_inheritance( model=DocumentPage, related='document_version__document', ) ModelPermission.register_inheritance( model=DocumentPageResult, related='document_version__document', ) 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( source=Document, label=_('Thumbnail'), func=lambda context: document_page_thumbnail_widget.render( instance=context['object'] ) ) SourceColumn( source=Document, attribute='document_type' ) SourceColumn( source=Document, label=_('Pages'), func=lambda context: widget_document_page_number( document=context['object'] ) ) # DocumentPage SourceColumn( source=DocumentPage, label=_('Thumbnail'), func=lambda context: document_page_thumbnail_widget.render( instance=context['object'] ) ) SourceColumn( source=DocumentPageResult, label=_('Thumbnail'), func=lambda context: document_page_thumbnail_widget.render( instance=context['object'] ) ) SourceColumn( source=DocumentPageResult, label=_('Type'), attribute='document_version.document.document_type' ) # DocumentType SourceColumn( source=DocumentType, label=_('Documents'), func=lambda context: context['object'].get_document_count( user=context['request'].user ) ) SourceColumn( source=DocumentTypeFilename, label=_('Enabled'), func=lambda context: TwoStateWidget( state=context['object'].enabled ).render() ) # DeletedDocument SourceColumn( source=DeletedDocument, label=_('Thumbnail'), func=lambda context: document_page_thumbnail_widget.render( instance=context['object'] ) ) SourceColumn( source=DeletedDocument, attribute='document_type' ) SourceColumn( source=DeletedDocument, attribute='deleted_date_time' ) # DocumentVersion SourceColumn( source=DocumentVersion, label=_('Thumbnail'), func=lambda context: document_page_thumbnail_widget.render( instance=context['object'] ) ) SourceColumn( source=DocumentVersion, attribute='timestamp' ) SourceColumn( source=DocumentVersion, label=_('Pages'), func=lambda context: widget_document_version_page_number( document_version=context['object'] ) ) SourceColumn( source=DocumentVersion, attribute='mimetype' ) SourceColumn( source=DocumentVersion, attribute='encoding' ) SourceColumn( source=DocumentVersion, attribute='comment' ) # DuplicatedDocument SourceColumn( source=DuplicatedDocument, label=_('Thumbnail'), func=lambda context: document_page_thumbnail_widget.render( instance=context['object'].document ) ) SourceColumn( source=DuplicatedDocument, label=_('Duplicates'), func=lambda context: context['object'].documents.count() ) app.conf.CELERYBEAT_SCHEDULE.update( { 'task_check_delete_periods': { 'task': 'documents.tasks.task_check_delete_periods', 'schedule': timedelta( seconds=CHECK_DELETE_PERIOD_INTERVAL ), }, 'task_check_trash_periods': { 'task': 'documents.tasks.task_check_trash_periods', 'schedule': timedelta(seconds=CHECK_TRASH_PERIOD_INTERVAL), }, 'task_delete_stubs': { 'task': 'documents.tasks.task_delete_stubs', 'schedule': timedelta(seconds=DELETE_STALE_STUBS_INTERVAL), }, } ) app.conf.CELERY_QUEUES.extend( ( Queue( 'converter', Exchange('converter'), routing_key='converter', delivery_mode=1 ), Queue( 'documents_periodic', Exchange('documents_periodic'), routing_key='documents_periodic', delivery_mode=1 ), Queue('uploads', Exchange('uploads'), routing_key='uploads'), Queue( 'documents', Exchange('documents'), routing_key='documents' ), ) ) app.conf.CELERY_ROUTES.update( { 'documents.tasks.task_check_delete_periods': { 'queue': 'documents_periodic' }, 'documents.tasks.task_check_trash_periods': { 'queue': 'documents_periodic' }, 'documents.tasks.task_clean_empty_duplicate_lists': { 'queue': 'documents' }, 'documents.tasks.task_clear_image_cache': { 'queue': 'tools' }, 'documents.tasks.task_delete_document': { 'queue': 'documents' }, 'documents.tasks.task_delete_stubs': { 'queue': 'documents_periodic' }, 'documents.tasks.task_generate_document_page_image': { 'queue': 'converter' }, 'documents.tasks.task_scan_duplicates_all': { 'queue': 'tools' }, 'documents.tasks.task_scan_duplicates_for': { 'queue': 'uploads' }, 'documents.tasks.task_update_page_count': { 'queue': 'uploads' }, 'documents.tasks.task_upload_new_version': { 'queue': 'uploads' }, } ) 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_clear_image_cache, link_duplicated_document_scan) ) # Document type links menu_object.bind_links( links=( link_document_type_edit, link_document_type_filename_list, link_acl_list, link_object_event_types_user_subcriptions_list, link_document_type_delete, link_events_for_object, ), 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_sidebar.bind_links( links=(link_document_type_filename_create,), sources=( DocumentTypeFilename, 'documents:document_type_filename_list', 'documents:document_type_filename_create' ) ) menu_sidebar.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_return, 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, link_transformation_list ), sources=(DocumentPage,) ) menu_object.bind_links( links=(link_transformation_list,), sources=(DocumentPage,) ) # Document versions menu_facet.bind_links( links=( link_document_version_return_document, link_document_version_return_list ), sources=(DocumentVersion,) ) menu_facet.bind_links( links=(link_document_version_view,), sources=(DocumentVersion,) ) post_delete.connect( dispatch_uid='handler_remove_empty_duplicates_lists', receiver=handler_remove_empty_duplicates_lists, sender=Document, ) post_initial_setup.connect( 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) registry.register(DocumentType) registry.register(DocumentVersion)
def ready(self): super(DocumentParsingApp, self).ready() APIEndPoint(app=self, version_string='1') Document = apps.get_model( app_label='documents', model_name='Document' ) DocumentVersion = apps.get_model( app_label='documents', model_name='DocumentVersion' ) DocumentVersionParseError = self.get_model('DocumentVersionParseError') Document.add_to_class('submit_for_parsing', document_parsing_submit) DocumentVersion.add_to_class( 'content', get_document_content ) DocumentVersion.add_to_class( 'submit_for_parsing', document_version_parsing_submit ) ModelPermission.register( model=Document, permissions=(permission_content_view,) ) SourceColumn( source=DocumentVersionParseError, label=_('Document'), func=lambda context: document_link(context['object'].document_version.document) ) SourceColumn( source=DocumentVersionParseError, label=_('Added'), attribute='datetime_submitted' ) SourceColumn( source=DocumentVersionParseError, label=_('Result'), attribute='result' ) app.conf.CELERY_QUEUES.append( Queue('parsing', Exchange('parsing'), routing_key='parsing'), ) app.conf.CELERY_ROUTES.update( { 'document_parsing.tasks.task_parse_document_version': { 'queue': 'parsing' }, } ) document_search.add_model_field( field='versions__pages__content__content', label=_('Content') ) document_page_search.add_model_field( field='content__content', label=_('Content') ) menu_facet.bind_links( links=(link_document_content,), sources=(Document,) ) menu_multi_item.bind_links( links=(link_document_submit_multiple,), sources=(Document,) ) menu_object.bind_links( links=(link_document_submit,), sources=(Document,) ) menu_secondary.bind_links( links=( link_document_content, link_document_parsing_errors_list, link_document_content_download ), sources=( 'document_parsing:document_content', 'document_parsing:document_content_download', 'document_parsing:document_parsing_error_list', ) ) menu_tools.bind_links( links=( link_document_type_submit, link_error_list, ) ) post_version_upload.connect( dispatch_uid='document_parsing_handler_parse_document_version', receiver=handler_parse_document_version, sender=DocumentVersion )
def ready(self): super(DocumentIndexingApp, self).ready() APIEndPoint(app=self, version_string='1') Package(label='Django MPTT', license_text=''' Django MPTT ----------- Copyright (c) 2007, Jonathan Buchanan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ''') Package(label='djangorestframework-recursive', license_text=''' Copyright (c) 2015, Warren Jin <*****@*****.**> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ''') SourceColumn(source=Index, label=_('Label'), attribute='label') SourceColumn(source=Index, label=_('Slug'), attribute='slug') SourceColumn( source=Index, label=_('Enabled'), func=lambda context: two_state_template(context['object'].enabled) ) SourceColumn( source=IndexInstance, label=_('Items'), func=lambda context: context['object'].get_items_count( user=context['request'].user ) ) SourceColumn( source=IndexInstance, label=_('Document types'), attribute='get_document_types_names' ) SourceColumn( source=IndexTemplateNode, label=_('Level'), func=lambda context: node_level(context['object']) ) SourceColumn( source=IndexTemplateNode, label=_('Enabled'), func=lambda context: two_state_template(context['object'].enabled) ) SourceColumn( source=IndexTemplateNode, label=_('Has document links?'), func=lambda context: two_state_template( context['object'].link_documents ) ) SourceColumn( source=IndexInstanceNode, label=_('Node'), func=lambda context: index_instance_item_link(context['object']) ) SourceColumn( source=IndexInstanceNode, label=_('Items'), func=lambda context: context['object'].get_item_count( user=context['request'].user ) ) SourceColumn( source=DocumentIndexInstanceNode, label=_('Node'), func=lambda context: get_breadcrumbs( index_instance_node=context['object'], single_link=True, ) ) SourceColumn( source=DocumentIndexInstanceNode, label=_('Items'), func=lambda context: context['object'].get_item_count( user=context['request'].user ) ) app.conf.CELERY_QUEUES.append( Queue('indexing', Exchange('indexing'), routing_key='indexing'), ) app.conf.CELERY_ROUTES.update( { 'document_indexing.tasks.task_delete_empty_index_nodes': { 'queue': 'indexing' }, 'document_indexing.tasks.task_index_document': { 'queue': 'indexing' }, 'document_indexing.tasks.task_do_rebuild_all_indexes': { 'queue': 'tools' }, } ) menu_facet.bind_links( links=(link_document_index_list,), sources=(Document,) ) menu_object.bind_links( links=( link_index_setup_edit, link_index_setup_view, link_index_setup_document_types, link_index_setup_delete ), sources=(Index,) ) menu_object.bind_links( links=( link_template_node_create, link_template_node_edit, link_template_node_delete ), sources=(IndexTemplateNode,) ) menu_main.bind_links(links=(link_index_main_menu,)) menu_secondary.bind_links( links=(link_index_setup_list, link_index_setup_create), sources=( Index, 'indexing:index_setup_list', 'indexing:index_setup_create' ) ) menu_setup.bind_links(links=(link_index_setup,)) menu_tools.bind_links(links=(link_rebuild_index_instances,)) post_delete.connect( document_index_delete, dispatch_uid='document_index_delete', sender=Document ) post_delete.connect( document_metadata_index_post_delete, dispatch_uid='document_metadata_index_post_delete', sender=DocumentMetadata ) post_document_created.connect( document_created_index_update, dispatch_uid='document_created_index_update', sender=Document ) post_save.connect( document_metadata_index_update, dispatch_uid='document_metadata_index_update', sender=DocumentMetadata )
def ready(self): super(DocumentsApp, self).ready() APIEndPoint(app=self, version_string='1') DeletedDocument = self.get_model('DeletedDocument') Document = self.get_model('Document') DocumentPage = self.get_model('DocumentPage') DocumentType = self.get_model('DocumentType') DocumentTypeFilename = self.get_model('DocumentTypeFilename') DocumentVersion = self.get_model('DocumentVersion') 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' ) ModelAttribute( Document, label=_('Label'), name='label', type_name='field' ) ModelAttribute( Document, description=_('The MIME type of any of the versions of a document'), label=_('MIME type'), name='versions__mimetype', type_name='field' ) 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_trash, permission_document_version_revert, 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,) ) ModelPermission.register_proxy( source=Document, model=DocumentType, ) ModelPermission.register_inheritance( model=Document, related='document_type', ) ModelPermission.register_inheritance( model=DocumentVersion, related='document', ) ModelPermission.register_inheritance( model=DocumentPage, related='document', ) SourceColumn( source=Document, label=_('Thumbnail'), func=lambda context: document_thumbnail( context['object'], gallery_name='documents:document_list', size=setting_thumbnail_size.value, title=getattr(context['object'], 'label', None), ) ) SourceColumn( source=Document, label=_('Type'), attribute='document_type' ) SourceColumn( source=DocumentType, label=_('Documents'), func=lambda context: context['object'].get_document_count( user=context['request'].user ) ) SourceColumn( source=DocumentTypeFilename, label=_('Enabled'), func=lambda context: two_state_template(context['object'].enabled) ) SourceColumn( source=DeletedDocument, label=_('Thumbnail'), func=lambda context: document_thumbnail( context['object'], gallery_name='documents:delete_document_list', size=setting_thumbnail_size.value, title=getattr(context['object'], 'label', None), disable_title_link=True ) ) SourceColumn( source=DeletedDocument, label=_('Type'), attribute='document_type' ) SourceColumn( source=DeletedDocument, label=_('Date time trashed'), attribute='deleted_date_time' ) SourceColumn( source=DocumentVersion, label=_('Time and date'), attribute='timestamp' ) SourceColumn( source=DocumentVersion, label=_('MIME type'), attribute='mimetype' ) SourceColumn( source=DocumentVersion, label=_('Encoding'), attribute='encoding' ) SourceColumn( source=DocumentVersion, label=_('Comment'), attribute='comment' ) app.conf.CELERYBEAT_SCHEDULE.update( { 'task_check_delete_periods': { 'task': 'documents.tasks.task_check_delete_periods', 'schedule': timedelta( seconds=CHECK_DELETE_PERIOD_INTERVAL ), }, 'task_check_trash_periods': { 'task': 'documents.tasks.task_check_trash_periods', 'schedule': timedelta(seconds=CHECK_TRASH_PERIOD_INTERVAL), }, 'task_delete_stubs': { 'task': 'documents.tasks.task_delete_stubs', 'schedule': timedelta(seconds=DELETE_STALE_STUBS_INTERVAL), }, } ) app.conf.CELERY_QUEUES.extend( ( Queue( 'converter', Exchange('converter'), routing_key='converter', delivery_mode=1 ), Queue( 'documents_periodic', Exchange('documents_periodic'), routing_key='documents_periodic', delivery_mode=1 ), Queue('uploads', Exchange('uploads'), routing_key='uploads'), ) ) app.conf.CELERY_ROUTES.update( { 'documents.tasks.task_check_delete_periods': { 'queue': 'documents_periodic' }, 'documents.tasks.task_check_trash_periods': { 'queue': 'documents_periodic' }, 'documents.tasks.task_delete_stubs': { 'queue': 'documents_periodic' }, 'documents.tasks.task_clear_image_cache': { 'queue': 'tools' }, 'documents.tasks.task_get_document_page_image': { 'queue': 'converter' }, 'documents.tasks.task_update_page_count': { 'queue': 'uploads' }, 'documents.tasks.task_upload_new_version': { 'queue': 'uploads' }, } ) menu_front_page.bind_links( links=( link_document_list_recent, link_document_list, link_document_list_deleted ) ) menu_setup.bind_links(links=(link_document_type_setup,)) menu_tools.bind_links(links=(link_clear_image_cache,)) # Document type links menu_object.bind_links( links=( link_document_type_edit, link_document_type_filename_list, link_acl_list, link_document_type_delete ), 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_sidebar.bind_links( links=(link_document_type_filename_create,), sources=( DocumentTypeFilename, 'documents:document_type_filename_list', 'documents:document_type_filename_create' ) ) menu_sidebar.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_edit, link_document_document_type_edit, link_document_print, link_document_trash, link_document_download, link_document_clear_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_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_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_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.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_return, 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, link_transformation_list ), sources=(DocumentPage,) ) menu_object.bind_links( links=(link_transformation_list,), sources=(DocumentPage,) ) namespace = StatisticNamespace(slug='documents', label=_('Documents')) namespace.add_statistic( slug='new-documents-per-month', label=_('New documents per month'), func=new_documents_per_month, renderer=CharJSLine, minute='0' ) namespace.add_statistic( slug='new-document-versions-per-month', label=_('New document versions per month'), func=new_document_versions_per_month, renderer=CharJSLine, minute='0' ) namespace.add_statistic( slug='new-document-pages-per-month', label=_('New document pages per month'), func=new_document_pages_per_month, renderer=CharJSLine, minute='0' ) namespace.add_statistic( slug='total-documents-at-each-month', label=_('Total documents at each month'), func=total_document_per_month, renderer=CharJSLine, minute='0' ) namespace.add_statistic( slug='total-document-versions-at-each-month', label=_('Total document versions at each month'), func=total_document_version_per_month, renderer=CharJSLine, minute='0' ) namespace.add_statistic( slug='total-document-pages-at-each-month', label=_('Total document pages at each month'), func=total_document_page_per_month, renderer=CharJSLine, minute='0' ) post_initial_setup.connect( create_default_document_type, dispatch_uid='create_default_document_type' ) registry.register(DeletedDocument) registry.register(Document)
def ready(self): super(OCRApp, self).ready() APIEndPoint(app=self, version_string='1') Document.add_to_class('submit_for_ocr', document_ocr_submit) DocumentVersion.add_to_class( 'submit_for_ocr', document_version_ocr_submit ) ModelPermission.register( model=Document, permissions=( permission_ocr_document, permission_ocr_content_view ) ) SourceColumn( source=DocumentVersionOCRError, label=_('Document'), func=lambda context: document_link(context['object'].document_version.document) ) SourceColumn( source=DocumentVersionOCRError, label=_('Added'), attribute='datetime_submitted' ) SourceColumn( source=DocumentVersionOCRError, label=_('Result'), attribute='result' ) app.conf.CELERY_QUEUES.append( Queue('ocr', Exchange('ocr'), routing_key='ocr'), ) app.conf.CELERY_ROUTES.update( { 'ocr.tasks.task_do_ocr': { 'queue': 'ocr' }, } ) document_search.add_model_field( field='versions__pages__ocr_content__content', label=_('Content') ) menu_facet.bind_links( links=(link_document_content,), sources=(Document,) ) menu_multi_item.bind_links( links=(link_document_submit_multiple,), sources=(Document,) ) menu_object.bind_links( links=(link_document_submit,), sources=(Document,) ) menu_object.bind_links( links=(link_document_type_ocr_settings,), sources=(DocumentType,) ) 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_submit_all, link_document_type_submit, link_entry_list ) ) post_save.connect( initialize_new_ocr_settings, dispatch_uid='initialize_new_ocr_settings', sender=DocumentType ) post_version_upload.connect( post_version_upload_ocr, dispatch_uid='post_version_upload_ocr', sender=DocumentVersion ) namespace = PropertyNamespace('ocr', _('OCR')) try: pdftotext = sh.Command(setting_pdftotext_path.value) except sh.CommandNotFound: namespace.add_property( 'pdftotext', _('pdftotext version'), _('not found'), report=True ) except Exception: namespace.add_property( 'pdftotext', _('pdftotext version'), _('error getting version'), report=True ) else: namespace.add_property( 'pdftotext', _('pdftotext version'), pdftotext('-v').stderr, report=True ) try: tesseract = sh.Command(setting_tesseract_path.value) except sh.CommandNotFound: namespace.add_property( 'tesseract', _('tesseract version'), _('not found'), report=True ) except Exception: namespace.add_property( 'tesseract', _('tesseract version'), _('error getting version'), report=True ) else: namespace.add_property( 'tesseract', _('tesseract version'), tesseract('-v').stderr, report=True )