Example #1
0
    def register(cls, app_name):
        logger.debug('Trying to import: %s' % app_name)
        try:
            app_module = import_module(app_name)
        except ImportError:
            logger.debug('Unable to import app: %s' % app_name)
        else:
            logger.debug('Trying to import registry from: %s' % app_name)
            try:
                registration = import_module('%s.registry' % app_name)
            except ImportError:
                logger.debug('Unable to import registry for app: %s' %
                             app_name)
            else:
                if not getattr(registration, 'disabled', False):
                    app = App()
                    app.name = app_name
                    # If there are not error go ahead with the stored app instance
                    app.label = getattr(registration, 'label', app_name)
                    app.description = getattr(registration, 'description', u'')

                    for link in getattr(registration, 'setup_links', []):
                        logger.debug('setup link: %s' % link)
                        register_setup(link)

                    for link in getattr(registration, 'tool_links', []):
                        logger.debug('tool link: %s' % link)
                        register_tool(link)

                    for index, link in enumerate(
                            getattr(registration, 'menu_links', [])):
                        logger.debug('menu_link: %s' % link)
                        register_top_menu(name='%s.%s' % (app_name, index),
                                          link=link)
Example #2
0
    def register(cls, app_name):
        logger.debug('Trying to import: %s' % app_name)
        try:
            app_module = import_module(app_name)
        except ImportError:
            logger.debug('Unable to import app: %s' % app_name)
        else:
            logger.debug('Trying to import registry from: %s' % app_name)
            try:
                registration = import_module('%s.registry' % app_name)
            except ImportError:
                logger.debug('Unable to import registry for app: %s' % app_name)
            else:
                if not getattr(registration, 'disabled', False):
                    app = App()
                    app.name=app_name
                    # If there are not error go ahead with the stored app instance
                    app.label = getattr(registration, 'label', app_name)
                    app.description = getattr(registration, 'description', u'')
                          
                    for link in getattr(registration, 'setup_links', []):
                        logger.debug('setup link: %s' % link)
                        register_setup(link) 

                    for link in getattr(registration, 'tool_links', []):
                        logger.debug('tool link: %s' % link)
                        register_tool(link)
                        
                    for index, link in enumerate(getattr(registration, 'menu_links', [])):
                        logger.debug('menu_link: %s' % link)
                        register_top_menu(name='%s.%s' % (app_name, index), link=link)
Example #3
0
    def register(cls, app_name):
        logger.debug('Trying to import: %s' % app_name)
        try:
            app_module = import_module(app_name)
        except ImportError:
            logger.debug('Unable to import app: %s' % app_name)
        else:
            logger.debug('Trying to import registry from: %s' % app_name)
            try:
                registration = import_module('%s.registry' % app_name)
            except ImportError as e:
                logger.debug('Unable to import registry for app: %s; %s' %
                             (app_name, e))
            else:
                if not getattr(registration, 'disabled', False):
                    app = App()
                    app.name = app_name
                    # If there are not error go ahead with the stored app instance
                    app.label = getattr(registration, 'label', app_name)
                    app.description = getattr(registration, 'description', u'')

                    for link in getattr(registration, 'setup_links', []):
                        logger.debug('setup link: %s' % link)
                        register_setup(link)

                    for link in getattr(registration, 'tool_links', []):
                        logger.debug('tool link: %s' % link)
                        register_tool(link)

                    for index, link in enumerate(
                            getattr(registration, 'menu_links', [])):
                        logger.debug('menu_link: %s' % link)
                        register_top_menu(name='%s.%s' % (app_name, index),
                                          link=link)

                    for cleanup_function in getattr(registration,
                                                    'cleanup_functions', []):
                        logger.debug('cleanup_function: %s' % cleanup_function)
                        Cleanup(cleanup_function)

                    for bootstrap_model in getattr(registration,
                                                   'bootstrap_models', []):
                        logger.debug('bootstrap_model: %s' % bootstrap_model)
                        BootstrapModel(
                            model_name=bootstrap_model.get('name'),
                            app_name=app_name,
                            sanitize=bootstrap_model.get('sanitize', True),
                            dependencies=bootstrap_model.get('dependencies'))

                    version_0_api_services = getattr(registration,
                                                     'version_0_api_services',
                                                     [])
                    logger.debug('version_0_api_services: %s' %
                                 version_0_api_services)

                    if version_0_api_services:
                        api_endpoint = APIEndPoint(app_name)

                        for service in version_0_api_services:
                            api_endpoint.add_service(**service)
Example #4
0
    def register(cls, app_name):
        logger.debug('Trying to import: %s' % app_name)
        try:
            app_module = import_module(app_name)
        except ImportError:
            logger.debug('Unable to import app: %s' % app_name)
        else:
            logger.debug('Trying to import registry from: %s' % app_name)
            try:
                registration = import_module('%s.registry' % app_name)
            except ImportError as e:
                logger.debug('Unable to import registry for app: %s; %s' % (app_name, e))
            else:
                if not getattr(registration, 'disabled', False):
                    app = App()
                    app.name = app_name
                    # If there are not error go ahead with the stored app instance
                    app.label = getattr(registration, 'label', app_name)
                    app.description = getattr(registration, 'description', u'')

                    for link in getattr(registration, 'setup_links', []):
                        logger.debug('setup link: %s' % link)
                        register_setup(link)

                    for link in getattr(registration, 'tool_links', []):
                        logger.debug('tool link: %s' % link)
                        register_tool(link)

                    for index, link in enumerate(getattr(registration, 'menu_links', [])):
                        logger.debug('menu_link: %s' % link)
                        register_top_menu(name='%s.%s' % (app_name, index), link=link)

                    for cleanup_function in getattr(registration, 'cleanup_functions', []):
                        logger.debug('cleanup_function: %s' % cleanup_function)
                        Cleanup(cleanup_function)

                    for bootstrap_model in getattr(registration, 'bootstrap_models', []):
                        logger.debug('bootstrap_model: %s' % bootstrap_model)
                        BootstrapModel(model_name=bootstrap_model.get('name'), app_name=app_name, sanitize=bootstrap_model.get('sanitize', True), dependencies=bootstrap_model.get('dependencies'))

                    version_0_api_services = getattr(registration, 'version_0_api_services', [])
                    logger.debug('version_0_api_services: %s' % version_0_api_services)

                    if version_0_api_services:
                        api_endpoint = APIEndPoint(app_name)

                        for service in version_0_api_services:
                            api_endpoint.add_service(**service)
Example #5
0
from django.utils.translation import ugettext_lazy as _
from django.core.exceptions import ImproperlyConfigured

from navigation.api import register_sidebar_template
from project_tools.api import register_tool

from converter.utils import load_backend
from converter.conf.settings import GRAPHICS_BACKEND

formats_list = {
    'text': _('file formats'),
    'view': 'formats_list',
    'famfam': 'pictures',
    'icon': 'pictures.png'
}

register_sidebar_template(['formats_list'], 'converter_file_formats_help.html')

try:
    backend = load_backend().ConverterClass()
except ImproperlyConfigured:
    raise ImproperlyConfigured(u'Missing or incorrect converter backend: %s' %
                               GRAPHICS_BACKEND)

register_tool(formats_list)
Example #6
0
    link_spacer
],
               menu_name='multi_item_links')
register_links(
    DocumentType,
    [setup_document_type_metadata, setup_document_type_metadata_required])
register_links(MetadataType,
               [setup_metadata_type_edit, setup_metadata_type_delete])
register_links([
    MetadataType, 'metadata:setup_metadata_type_list',
    'metadata:setup_metadata_type_create'
], [setup_metadata_type_list, setup_metadata_type_create],
               menu_name='secondary_menu')

register_setup(setup_metadata_type_list)
register_tool(link_documents_missing_required_metadata)

class_permissions(Document, [
    PERMISSION_METADATA_DOCUMENT_ADD,
    PERMISSION_METADATA_DOCUMENT_EDIT,
    PERMISSION_METADATA_DOCUMENT_REMOVE,
    PERMISSION_METADATA_DOCUMENT_VIEW,
])

register_model_list_columns(Document, [
    {
        'name': _('Metadata'),
        'attribute': encapsulate(lambda x: get_metadata_string(x))
    },
])
Example #7
0
from __future__ import unicode_literals

from django.utils.translation import ugettext_lazy as _

from navigation.api import register_top_menu
from project_setup.api import register_setup
from project_tools.api import register_tool

from .links import admin_site, maintenance_menu
from .classes import FrontPageButton  # NOQA

register_top_menu('home',
                  link={
                      'text': _('Home'),
                      'view': 'main:home',
                      'famfam': 'house'
                  },
                  position=0)
register_setup(admin_site)
register_tool(maintenance_menu)
Example #8
0
def create_installation_instance(sender, **kwargs):
    if kwargs['app'] == 'installation':
        Installation.objects.get_or_create()


register_model_list_columns(PropertyNamespace, [
    {
        'name': _('Label'),
        'attribute': 'label'
    },
    {
        'name': _('Items'),
        'attribute': encapsulate(lambda entry: len(entry.get_properties()))
    }
])

register_model_list_columns(Property, [
    {
        'name': _('Label'),
        'attribute': 'label'
    },
    {
        'name': _('Value'),
        'attribute': 'value'
    }
])

register_links(PropertyNamespace, [link_namespace_details])
register_links(['installation:namespace_list', PropertyNamespace], [link_namespace_list], menu_name='secondary_menu')
register_tool(link_menu_link)
Example #9
0
from __future__ import unicode_literals

from project_tools.api import register_tool

from .classes import Event  # NOQA
from .links import events_list

register_tool(events_list)
Example #10
0
                      },
                      children_path_regex=[r'^search/'])


def get_version():
    '''
    Return the formatted version information
    '''
    vers = [
        '%(major)i.%(minor)i' % __version_info__,
    ]

    if __version_info__['micro']:
        vers.append('.%(micro)i' % __version_info__)
    if __version_info__['releaselevel'] != 'final':
        vers.append('%(releaselevel)s%(serial)i' % __version_info__)
    return ''.join(vers)


__version__ = get_version()

if 'django.contrib.admin' in settings.INSTALLED_APPS:
    register_setup(admin_site)

register_tool(maintenance_menu)
register_tool(statistics)
register_tool(diagnostics)

if 'sentry' in settings.INSTALLED_APPS:
    register_tool(sentry)
Example #11
0
from django.utils.translation import ugettext_lazy as _

from permissions.api import register_permission, set_namespace_title
from project_tools.api import register_tool

PERMISSION_HISTORY_VIEW = {'namespace': 'history', 'name': u'history_view', 'label': _(u'Access the history app')}

set_namespace_title('history', _(u'History'))
register_permission(PERMISSION_HISTORY_VIEW)

# TODO: support permissions AND operand
history_list = {'text': _(u'history'), 'view': 'history_list', 'famfam': 'book', 'icon': 'book.png', 'permissions': [PERMISSION_HISTORY_VIEW], 'children_views': ['history_view']}

register_tool(history_list)
Example #12
0
from __future__ import absolute_import

from django.utils.translation import ugettext_lazy as _

from project_tools.api import register_tool
from navigation.api import register_model_list_columns, register_links
from common.utils import encapsulate

from .models import History
from .widgets import history_entry_type_link
from .links import history_list, history_details

register_tool(history_list)

register_model_list_columns(History, [
    {
        'name': _(u'date and time'),
        'attribute': 'datetime'
    },
    {
        'name': _(u'type'),
        'attribute': encapsulate(lambda entry: history_entry_type_link(entry))
    },
    {
        'name': _(u'summary'),
        'attribute': encapsulate(lambda entry: unicode(entry.get_processed_summary()))
    }
])

register_links(History, [history_details])
Example #13
0
from __future__ import unicode_literals

from navigation.api import register_links

from project_tools.api import register_tool

from .classes import Statistic, StatisticNamespace
from .links import link_execute, link_namespace_details, link_namespace_list, link_statistics

register_links(StatisticNamespace, [link_namespace_details])
register_links(
    [StatisticNamespace, "statistics:namespace_list", "statistics:execute"],
    [link_namespace_list],
    menu_name="secondary_menu",
)
register_links(Statistic, [link_execute])
register_tool(link_statistics)
Example #14
0
@receiver(post_version_upload,
          dispatch_uid='post_version_upload_ocr',
          sender=DocumentVersion)
def post_version_upload_ocr(sender, instance, **kwargs):
    logger.debug('received post_version_upload')
    logger.debug('instance pk: %s', instance.pk)
    if instance.document.document_type.ocr:
        instance.submit_for_ocr()


Document.add_to_class('submit_for_ocr', document_ocr_submit)
DocumentVersion.add_to_class('submit_for_ocr', document_version_ocr_submit)

class_permissions(Document, [PERMISSION_OCR_DOCUMENT])

register_tool(link_entry_list)

APIEndPoint('ocr')

register_model_list_columns(DocumentVersionOCRError, [
    {
        'name':
        _('Document'),
        'attribute':
        encapsulate(
            lambda entry: document_link(entry.document_version.document))
    },
    {
        'name': _('Added'),
        'attribute': 'datetime_submitted'
    },
Example #15
0
            auto_admin_properties = AutoAdminSingleton.objects.get()
            auto_admin_properties.account = admin
            auto_admin_properties.password = AUTO_ADMIN_PASSWORD
            auto_admin_properties.password_hash = admin.password
            auto_admin_properties.save()
        else:
            print 'Super admin user already exists. -- login: %s' % AUTO_ADMIN_USERNAME


@receiver(post_save, dispatch_uid='auto_admin_account_passwd_change', sender=User)
def auto_admin_account_passwd_change(sender, instance, **kwargs):
    with transaction.commit_on_success():
        try:
            auto_admin_properties = AutoAdminSingleton.objects.get()
            if instance == auto_admin_properties.account and instance.password != auto_admin_properties.password_hash:
                # Only delete the auto admin properties when the password has been changed
                auto_admin_properties.delete(force=True)
        except DatabaseError:
            transaction.rollback()


if (validate_path(TEMPORARY_DIRECTORY) == False) or (not TEMPORARY_DIRECTORY):
    setattr(common_settings, 'TEMPORARY_DIRECTORY', tempfile.mkdtemp())

if 'django.contrib.admin' in django_settings.INSTALLED_APPS:
    register_setup(link_admin_site)


if 'sentry' in django_settings.INSTALLED_APPS:
    register_tool(link_sentry)
Example #16
0
    # Add new document type metadata types to document
    for document_type_metadata_type in instance.document_type.metadata.filter(required=True):
        DocumentMetadata.objects.create(document=instance, metadata_type=document_type_metadata_type.metadata_type, value=None)


Document.add_to_class('metadata_value_of', DocumentMetadataHelper.constructor)

register_links(['metadata:metadata_add', 'metadata:metadata_edit', 'metadata:metadata_remove', 'metadata:metadata_view'], [metadata_add, metadata_edit, metadata_remove], menu_name='sidebar')
register_links(Document, [metadata_view], menu_name='form_header')
register_links([Document], [metadata_multiple_add, metadata_multiple_edit, metadata_multiple_remove, link_spacer], menu_name='multi_item_links')
register_links(DocumentType, [setup_document_type_metadata, setup_document_type_metadata_required])
register_links(MetadataType, [setup_metadata_type_edit, setup_metadata_type_delete])
register_links([MetadataType, 'metadata:setup_metadata_type_list', 'metadata:setup_metadata_type_create'], [setup_metadata_type_list, setup_metadata_type_create], menu_name='secondary_menu')

register_setup(setup_metadata_type_list)
register_tool(link_documents_missing_required_metadata)

class_permissions(Document, [
    PERMISSION_METADATA_DOCUMENT_ADD, PERMISSION_METADATA_DOCUMENT_EDIT,
    PERMISSION_METADATA_DOCUMENT_REMOVE, PERMISSION_METADATA_DOCUMENT_VIEW,
])

register_model_list_columns(Document, [
    {
        'name': _('Metadata'), 'attribute': encapsulate(lambda x: get_metadata_string(x))
    },
])

APIEndPoint('metadata')
ModelAttribute(Document, 'metadata__metadata_type__name', label=_('Metadata type name'), type_name='query')
ModelAttribute(Document, 'metadata__value', label=_('Metadata type value'), type_name='query')
Example #17
0
from __future__ import unicode_literals

from navigation.api import register_links

from project_tools.api import register_tool

from .classes import Statistic, StatisticNamespace
from .links import (link_execute, link_namespace_details, link_namespace_list,
                    link_statistics)

register_links(StatisticNamespace, [link_namespace_details])
register_links(
    [StatisticNamespace, 'statistics:namespace_list', 'statistics:execute'],
    [link_namespace_list],
    menu_name='secondary_menu')
register_links(Statistic, [link_execute])
register_tool(link_statistics)
Example #18
0
            auto_admin_properties.account = admin
            auto_admin_properties.password = AUTO_ADMIN_PASSWORD
            auto_admin_properties.password_hash = admin.password
            auto_admin_properties.save()
        else:
            print 'Super admin user already exists. -- login: %s' % AUTO_ADMIN_USERNAME


@receiver(post_save,
          dispatch_uid='auto_admin_account_passwd_change',
          sender=User)
def auto_admin_account_passwd_change(sender, instance, **kwargs):
    with transaction.commit_on_success():
        try:
            auto_admin_properties = AutoAdminSingleton.objects.get()
            if instance == auto_admin_properties.account and instance.password != auto_admin_properties.password_hash:
                # Only delete the auto admin properties when the password has been changed
                auto_admin_properties.delete(force=True)
        except DatabaseError:
            transaction.rollback()


if (validate_path(TEMPORARY_DIRECTORY) == False) or (not TEMPORARY_DIRECTORY):
    setattr(common_settings, 'TEMPORARY_DIRECTORY', tempfile.mkdtemp())

if 'django.contrib.admin' in django_settings.INSTALLED_APPS:
    register_setup(link_admin_site)

if 'sentry' in django_settings.INSTALLED_APPS:
    register_tool(link_sentry)
Example #19
0
from django.dispatch import receiver
from django.db.models.signals import post_save
from django.db.utils import DatabaseError

from .links import installation_details
from .models import Installation
    

@receiver(post_migrate, dispatch_uid='trigger_first_time')
def trigger_first_time(sender, **kwargs):
    if kwargs['app'] == 'installation':
        details = Installation.objects.get()
        details.is_first_run = True
        details.save()


def check_first_run():
    try:
        details = Installation.objects.get()
    except DatabaseError:
        # Avoid database errors when the app tables haven't been created yet
        pass
    else:
        if details.is_first_run:
            details.submit()


register_tool(installation_details)

check_first_run()
Example #20
0
from .links import job_list
    
logger = logging.getLogger(__name__)

@receiver(post_syncdb, dispatch_uid='scheduler_shutdown_post_syncdb')
def scheduler_shutdown_post_syncdb(sender, **kwargs):
    logger.debug('Scheduler shut down on post syncdb signal')
    scheduler.shutdown()


@receiver(pre_collectstatic, dispatch_uid='sheduler_shutdown_pre_collectstatic')
def sheduler_shutdown_pre_collectstatic(sender, **kwargs):
    logger.debug('Scheduler shut down on collectstatic signal')
    scheduler.shutdown()


@receiver(pre_migrate, dispatch_uid='sheduler_shutdown_pre_migrate')
def sheduler_shutdown_pre_migrate(sender, **kwargs):
    logger.debug('Scheduler shut down on pre_migrate signal')
    scheduler.shutdown()


def schedule_shutdown_on_exit():
    logger.debug('Scheduler shut down on exit')
    scheduler.shutdown()


register_tool(job_list)
atexit.register(schedule_shutdown_on_exit)
Example #21
0
from __future__ import unicode_literals

from django.utils.translation import ugettext_lazy as _

from navigation.api import register_top_menu
from project_setup.api import register_setup
from project_tools.api import register_tool

from .links import admin_site, maintenance_menu
from .classes import FrontPageButton  # NOQA

register_top_menu('home', link={'text': _('Home'), 'view': 'main:home', 'famfam': 'house'}, position=0)
register_setup(admin_site)
register_tool(maintenance_menu)
Example #22
0
if not DISABLE_HOME_VIEW:
    register_top_menu('home', link={'text': _(u'home'), 'view': 'home', 'famfam': 'house'}, position=0)
if not SIDE_BAR_SEARCH:
    register_top_menu('search', link={'text': _(u'search'), 'view': 'search', 'famfam': 'zoom'}, children_path_regex=[r'^search/'])


def get_version():
    '''
    Return the formatted version information
    '''
    vers = ['%(major)i.%(minor)i' % __version_info__, ]

    if __version_info__['micro']:
        vers.append('.%(micro)i' % __version_info__)
    if __version_info__['releaselevel'] != 'final':
        vers.append('%(releaselevel)s%(serial)i' % __version_info__)
    return ''.join(vers)

__version__ = get_version()

if 'django.contrib.admin' in settings.INSTALLED_APPS:
    register_setup(admin_site)

register_tool(maintenance_menu)
register_tool(statistics)
register_tool(diagnostics)

if 'sentry' in settings.INSTALLED_APPS:
    register_tool(sentry)
Example #23
0
            except AlreadyQueued:
                pass


@receiver(post_syncdb, dispatch_uid='create_default_queue', sender=ocr_models)
def create_default_queue_signal_handler(sender, **kwargs):
    default_queue, created = DocumentQueue.objects.get_or_create(name='default')


def reset_queue_documents():
    try:
        default_queue = DocumentQueue.objects.get(name='default')
    except (DatabaseError, DocumentQueue.DoesNotExist):
        pass
    else:
        default_queue.queuedocument_set.filter(state=QUEUEDOCUMENT_STATE_PROCESSING).update(state=QUEUEDOCUMENT_STATE_PENDING)


register_interval_job('task_process_document_queues', _(u'Checks the OCR queue for pending documents.'), task_process_document_queues, seconds=QUEUE_PROCESSING_INTERVAL)

register_tool(ocr_tool_link)

class_permissions(Document, [
    PERMISSION_OCR_DOCUMENT,
])

reset_queue_documents()

namespace = StatisticNamespace(name='ocr', label=_(u'OCR'))
namespace.add_statistic(OCRStatistics(name='ocr_stats', label=_(u'OCR queue statistics')))
Example #24
0
from __future__ import unicode_literals

from project_tools.api import register_tool

from .classes import APIEndPoint
from .links import link_api, link_api_documentation

APIEndPoint('rest_api')

register_tool(link_api)
register_tool(link_api_documentation)
Example #25
0
from django.db.utils import DatabaseError
from django.db import transaction

from .links import installation_details
from .models import Installation


@receiver(post_migrate, dispatch_uid="trigger_first_time")
def trigger_first_time(sender, **kwargs):
    if kwargs["app"] == "installation":
        details = Installation.objects.get()
        details.is_first_run = True
        details.save()


@transaction.commit_on_success
def check_first_run():
    try:
        details = Installation.objects.get()
    except DatabaseError:
        # Avoid database errors when the app tables haven't been created yet
        transaction.rollback()
    else:
        if details.is_first_run:
            details.submit()


register_tool(installation_details)

check_first_run()
Example #26
0
from django.utils.translation import ugettext_lazy as _
from django.core.exceptions import ImproperlyConfigured

from navigation.api import register_sidebar_template
from project_tools.api import register_tool

from converter.utils import load_backend
from converter.conf.settings import GRAPHICS_BACKEND

formats_list = {'text': _('file formats'), 'view': 'formats_list', 'famfam': 'pictures', 'icon': 'pictures.png'}

register_sidebar_template(['formats_list'], 'converter_file_formats_help.html')

try:
    backend = load_backend().ConverterClass()
except ImproperlyConfigured:
    raise ImproperlyConfigured(u'Missing or incorrect converter backend: %s' % GRAPHICS_BACKEND)

register_tool(formats_list)
Example #27
0
        # doing syncdb and creating the database tables
    else:
        transaction.commit()


def document_post_save(sender, instance, **kwargs):
    if kwargs.get('created', False):
        if AUTOMATIC_OCR:
            DocumentQueue.objects.queue_document(instance)


post_save.connect(document_post_save, sender=Document)

# Disabled because it appears Django execute signals using the same
# process effectively blocking the view until the OCR process completes
# which could take several minutes :/
#@receiver(post_save, dispatch_uid='call_queue', sender=QueueDocument)
#def call_queue(sender, **kwargs):
#    if kwargs.get('created', False):
#        logger.debug('got call_queue signal: %s' % kwargs)
#        task_process_document_queues()

create_default_queue()

register_interval_job('task_process_document_queues',
                      _(u'Checks the OCR queue for pending documents.'),
                      task_process_document_queues,
                      seconds=QUEUE_PROCESSING_INTERVAL)

register_tool(ocr_tool_link)
Example #28
0

register_model_list_columns(PropertyNamespace, [
    {
        'name': _(u'label'),
        'attribute': 'label'
    },
    {
        'name': _(u'items'),
        'attribute': encapsulate(lambda entry: len(entry.get_properties()))
    }    
])

register_model_list_columns(Property, [
    {
        'name': _(u'label'),
        'attribute': 'label'
    },
    {
        'name': _(u'value'),
        'attribute': 'value'
    }    
])

register_links(PropertyNamespace, [link_namespace_details])
register_links(['namespace_list', PropertyNamespace], [link_namespace_list], menu_name='secondary_menu')

register_tool(link_menu_link)

check_first_run()
Example #29
0

@receiver(post_version_upload, dispatch_uid='post_version_upload_ocr', sender=DocumentVersion)
def post_version_upload_ocr(sender, instance, **kwargs):
    logger.debug('received post_version_upload')
    logger.debug('instance pk: %s', instance.pk)
    if instance.document.document_type.ocr:
        instance.submit_for_ocr()


Document.add_to_class('submit_for_ocr', document_ocr_submit)
DocumentVersion.add_to_class('submit_for_ocr', document_version_ocr_submit)

class_permissions(Document, [PERMISSION_OCR_DOCUMENT])

register_tool(link_entry_list)

APIEndPoint('ocr')

register_model_list_columns(DocumentVersionOCRError, [
    {
        'name': _('Document'), 'attribute': encapsulate(lambda entry: document_link(entry.document_version.document))
    },
    {
        'name': _('Added'), 'attribute': 'datetime_submitted'
    },
    {
        'name': _('Result'), 'attribute': 'result'
    },
])
Example #30
0
from __future__ import absolute_import

import atexit
import logging
import sys

from .runtime import scheduler, lockdown

from project_tools.api import register_tool

from .links import job_list
from .literals import SHUTDOWN_COMMANDS

logger = logging.getLogger(__name__)


def schedule_shutdown_on_exit():
    logger.debug('Scheduler shut down on exit')
    scheduler.shutdown()


if any([command in sys.argv for command in SHUTDOWN_COMMANDS]):
    logger.debug('Scheduler shut down on SHUTDOWN_COMMAND')
    # Shutdown any scheduler already running
    scheduler.shutdown()
    # Prevent any new scheduler afterwards to start
    lockdown()

atexit.register(schedule_shutdown_on_exit)
register_tool(job_list)