Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 5
0
from __future__ import absolute_import

from django.utils.translation import ugettext_lazy as _

from project_setup.api import register_setup

from .links import check_settings


def is_superuser(context):
    return context['request'].user.is_staff or context['request'].user.is_superuser


check_settings = {'text': _(u'settings'), 'view': 'setting_list', 'famfam': 'cog', 'icon': 'cog.png', 'condition': is_superuser, 'children_view_regex': [r'^setting_']}

register_setup(check_settings)
Esempio n. 6
0
    'view': 'rebuild_index_instances',
    'famfam': 'folder_page',
    'permissions': [PERMISSION_DOCUMENT_INDEXING_REBUILD_INDEXES],
    'description':
    _(u'Deletes and creates from scratch all the document indexes.')
}

register_maintenance_links([rebuild_index_instances],
                           namespace='document_indexing',
                           title=_(u'Indexes'))

register_sidebar_template(['index_instance_list'], 'indexing_help.html')

register_links(IndexInstanceNode, [index_parent])

register_links(Document, [document_index_list], menu_name='form_header')

register_setup(index_setup)

register_links([
    Index, 'index_setup_list', 'index_setup_create', 'template_node_edit',
    'template_node_delete'
], [index_setup_list, index_setup_create],
               menu_name='secondary_menu')

register_links(Index, [index_setup_edit, index_setup_delete, index_setup_view])

register_links(
    IndexTemplateNode,
    [template_node_create, template_node_edit, template_node_delete])
Esempio n. 7
0
    children_views=['document_folder_list', 'folder_add_document', 'document_index_list', 'upload_version', ],
    position=1
)

register_sidebar_template(['document_list_recent'], 'recent_document_list_help.html')
register_sidebar_template(['document_type_list'], 'document_types_help.html')

register_links(Document, [document_view_simple], menu_name='form_header', position=0)
register_links(Document, [document_view_advanced], menu_name='form_header', position=1)
register_links(Document, [document_history_view], menu_name='form_header')
register_links(Document, [document_version_list], menu_name='form_header')

if (not validate_path(document_settings.CACHE_PATH)) or (not document_settings.CACHE_PATH):
    setattr(document_settings, 'CACHE_PATH', tempfile.mkdtemp())

register_setup(document_type_setup)

class_permissions(Document, [
    PERMISSION_DOCUMENT_PROPERTIES_EDIT,
    PERMISSION_DOCUMENT_EDIT,
    PERMISSION_DOCUMENT_VIEW,
    PERMISSION_DOCUMENT_DELETE,
    PERMISSION_DOCUMENT_DOWNLOAD,
    PERMISSION_DOCUMENT_TRANSFORM,
    PERMISSION_DOCUMENT_NEW_VERSION,
    PERMISSION_DOCUMENT_VERSION_REVERT,
    PERMISSION_HISTORY_VIEW
])

document_search = SearchModel('documents', 'Document')
document_search.add_model_field('document_type__name', label=_(u'Document type'))
Esempio n. 8
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)
Esempio n. 9
0
    menu_name=u"secondary_menu",
)
register_multi_item_links(["user_list"], [user_multiple_set_password, user_multiple_delete])

register_links(Group, [group_edit, group_members, group_delete])
register_links(
    ["group_multiple_delete", "group_delete", "group_edit", "group_list", "group_add", "group_members"],
    [group_list, group_add],
    menu_name=u"secondary_menu",
)
register_multi_item_links(["group_list"], [group_multiple_delete])

user_management_views = [
    "user_list",
    "user_edit",
    "user_add",
    "user_delete",
    "user_multiple_delete",
    "user_set_password",
    "user_multiple_set_password",
    "group_list",
    "group_edit",
    "group_add",
    "group_delete",
    "group_multiple_delete",
    "group_members",
]

register_setup(user_setup)
register_setup(group_setup)
Esempio n. 10
0
from __future__ import absolute_import

from navigation.api import register_links, register_multi_item_links
from project_setup.api import register_setup

from .classes import (AccessHolder, AccessObjectClass, ClassAccessHolder,
    AccessObject)
from .links import (acl_detail, acl_grant, acl_revoke, acl_holder_new,
    acl_setup_valid_classes, acl_class_list, acl_class_acl_list,
    acl_class_acl_detail, acl_class_new_holder_for, acl_class_grant,
    acl_class_revoke)

register_links(AccessHolder, [acl_detail])
register_multi_item_links(['acl_detail'], [acl_grant, acl_revoke])

register_links([AccessObject], [acl_holder_new], menu_name='sidebar')

register_setup(acl_setup_valid_classes)
register_links(['acl_setup_valid_classes', 'acl_class_acl_list', 'acl_class_new_holder_for', 'acl_class_acl_detail', 'acl_class_multiple_grant', 'acl_class_multiple_revoke'], [acl_class_list], menu_name='secondary_menu')

register_links(ClassAccessHolder, [acl_class_acl_detail])

register_links(AccessObjectClass, [acl_class_acl_list, acl_class_new_holder_for])
register_multi_item_links(['acl_class_acl_detail'], [acl_class_grant, acl_class_revoke])
Esempio n. 11
0
from __future__ import unicode_literals

from hkp import Key as KeyServerKey

from navigation.api import register_links
from project_setup.api import register_setup

from .api import Key
from .links import (
    key_delete, key_query, key_receive, key_setup, public_keys
)

register_links(['django_gpg:key_delete', 'django_gpg:key_public_list', 'django_gpg:key_query'], [public_keys, key_query], menu_name='sidebar')
register_links(Key, [key_delete])
register_links(KeyServerKey, [key_receive])
register_setup(key_setup)
Esempio n. 12
0
from __future__ import absolute_import

from project_setup.api import register_setup

from .links import link_check_settings

register_setup(link_check_settings)
Esempio n. 13
0
    link_setup_workflow_edit, link_setup_workflow_list,
    link_setup_workflow_states, link_setup_workflow_state_create,
    link_setup_workflow_state_delete, link_setup_workflow_state_edit,
    link_setup_workflow_transitions, link_setup_workflow_transition_create,
    link_setup_workflow_transition_delete, link_setup_workflow_transition_edit,
    link_workflow_instance_detail, link_workflow_instance_transition
)


@receiver(post_save, dispatch_uid='launch_workflow', sender=Document)
def launch_workflow(sender, instance, created, **kwargs):
    if created:
        Workflow.objects.launch_for(instance)


register_setup(link_setup_workflow_list)

register_model_list_columns(Workflow, [
    {
        'name': _('Initial state'),
        'attribute': encapsulate(lambda workflow: workflow.get_initial_state() or _('None'))
    },
])

register_model_list_columns(WorkflowState, [
    {
        'name': _('Is initial state?'),
        'attribute': 'initial'
    },
])
Esempio n. 14
0
    link_setup_workflow_edit, link_setup_workflow_list,
    link_setup_workflow_states, link_setup_workflow_state_create,
    link_setup_workflow_state_delete, link_setup_workflow_state_edit,
    link_setup_workflow_transitions, link_setup_workflow_transition_create,
    link_setup_workflow_transition_delete, link_setup_workflow_transition_edit,
    link_workflow_instance_detail, link_workflow_instance_transition
)


@receiver(post_save, dispatch_uid='launch_workflow', sender=Document)
def launch_workflow(sender, instance, created, **kwargs):
    if created:
        Workflow.objects.launch_for(instance)


register_setup(link_setup_workflow_list)

register_model_list_columns(Workflow, [
    {
        'name': _('Initial state'),
        'attribute': encapsulate(lambda workflow: workflow.get_initial_state() or _('None'))
    },
])

register_model_list_columns(WorkflowState, [
    {
        'name': _('Is initial state?'),
        'attribute': 'initial'
    },
])
Esempio n. 15
0
from django.utils.translation import ugettext_lazy as _

from navigation.api import register_links, register_multi_item_links
from permissions.api import register_permission, set_namespace_title
from project_setup.api import register_setup

from mechanic.models import Link

link_setup = {'text': _(u'intercepted links'), 'view': 'link_list', 'icon': 'telephone_link.png'}#, 'permissions': [PERMISSION_USER_VIEW]}
link_list = {'text': _(u'intercepted links list'), 'view': 'link_list', 'famfam': 'telephone_link'}#, 'permissions': [PERMISSION_USER_VIEW]}
link_add = {'text': _(u'new intercepted link'), 'view': 'link_add', 'famfam': 'telephone_add'}#, 'permissions': [PERMISSION_USER_CREATE]}
link_edit = {'text': _(u'edit'), 'view': 'link_edit', 'args': 'object.id', 'famfam': 'telephone_edit'}#, 'permissions': [PERMISSION_USER_EDIT]}
link_delete = {u'text': _('delete'), 'view': 'link_delete', 'args': 'object.id', 'famfam': 'telephone_delete'}#, 'permissions': [PERMISSION_USER_DELETE]}
link_multiple_delete = {u'text': _('delete'), 'view': 'link_multiple_delete', 'famfam': 'telephone_delete'}#, 'permissions': [PERMISSION_USER_DELETE]}


register_links(Link, [link_edit, link_delete])
register_links(['link_list', 'link_add', 'link_edit', 'link_delete', 'link_multiple_delete'], [link_list, link_add], menu_name=u'sidebar')
register_multi_item_links(['link_list'], [link_multiple_delete])

register_setup(link_setup)
Esempio n. 16
0
page_setup_link = {'text': _(u'CMS pages'), 'view': 'page_list', 'icon': 'page.png'}#, 'permissions': [PERMISSION_USER_VIEW]}
page_list_link = {'text': _(u'CMS page list'), 'view': 'page_list', 'famfam': 'page'}#, 'permissions': [PERMISSION_USER_VIEW]}
page_add_link = {'text': _(u'new CMS page'), 'view': 'page_add', 'famfam': 'page_add'}#, 'permissions': [PERMISSION_USER_CREATE]}
page_edit_link = {'text': _(u'edit'), 'view': 'page_edit', 'args': 'object.id', 'famfam': 'page_edit'}#, 'permissions': [PERMISSION_USER_EDIT]}
page_delete_link = {u'text': _('delete'), 'view': 'page_delete', 'args': 'object.id', 'famfam': 'page_delete'}#, 'permissions': [PERMISSION_USER_DELETE]}
page_multiple_delete_link = {u'text': _('delete'), 'view': 'page_multiple_delete', 'famfam': 'page_delete'}#, 'permissions': [PERMISSION_USER_DELETE]}
page_render_link = {'text': _(u'render'), 'view': 'page_render', 'args': 'object.id', 'famfam': 'page_lightning'}#, 'permissions': [PERMISSION_USER_EDIT]}
page_preview_link = {'text': _(u'preview'), 'view': 'page_preview', 'args': 'object.id', 'famfam': 'zoom'}#, 'permissions': [PERMISSION_USER_EDIT]}


media_setup_link = {'text': _(u'CMS media'), 'view': 'media_list', 'icon': 'drive.png'}#, 'permissions': [PERMISSION_USER_VIEW]}
media_list_link = {'text': _(u'CMS media list'), 'view': 'media_list', 'famfam': 'drive'}#, 'permissions': [PERMISSION_USER_VIEW]}
media_add_link = {'text': _(u'new CMS media'), 'view': 'media_add', 'famfam': 'drive_add'}#, 'permissions': [PERMISSION_USER_CREATE]}
media_edit_link = {'text': _(u'edit'), 'view': 'media_edit', 'args': 'object.id', 'famfam': 'drive_edit'}#, 'permissions': [PERMISSION_USER_EDIT]}
media_delete_link = {u'text': _('delete'), 'view': 'media_delete', 'args': 'object.id', 'famfam': 'drive_delete'}#, 'permissions': [PERMISSION_USER_DELETE]}
media_multiple_delete_link = {u'text': _('delete'), 'view': 'media_multiple_delete', 'famfam': 'drive_delete'}#, 'permissions': [PERMISSION_USER_DELETE]}
media_preview_link = {'text': _(u'preview'), 'view': 'media_preview', 'args': 'object.id', 'famfam': 'zoom'}#, 'permissions': [PERMISSION_USER_EDIT]}


register_links(Page, [page_preview_link, page_edit_link, page_delete_link, page_render_link])
register_links(['page_list', 'page_add', 'page_edit', 'page_delete', 'page_multiple_delete'], [page_list_link, page_add_link], menu_name=u'sidebar')
register_multi_item_links(['page_list'], [page_multiple_delete_link])

register_setup(page_setup_link)

register_links(Media, [media_edit_link, media_delete_link])
register_links(['media_list', 'media_add', 'media_edit', 'media_delete', 'media_multiple_delete'], [media_list_link, media_add_link], menu_name=u'sidebar')
register_multi_item_links(['media_list'], [media_multiple_delete_link])

register_setup(media_setup_link)
Esempio n. 17
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)
Esempio n. 18
0
index_setup_view = {'text': _(u'tree template'), 'view': 'index_setup_view', 'args': 'index.pk', 'famfam': 'textfield', 'permissions': [PERMISSION_DOCUMENT_INDEXING_SETUP]}

template_node_create = {'text': _(u'new child node'), 'view': 'template_node_create', 'args': 'node.pk', 'famfam': 'textfield_add', 'permissions': [PERMISSION_DOCUMENT_INDEXING_SETUP]}
template_node_edit = {'text': _(u'edit'), 'view': 'template_node_edit', 'args': 'node.pk', 'famfam': 'textfield', 'permissions': [PERMISSION_DOCUMENT_INDEXING_SETUP], 'conditional_disable': is_root_node}
template_node_delete = {'text': _(u'delete'), 'view': 'template_node_delete', 'args': 'node.pk', 'famfam': 'textfield_delete', 'permissions': [PERMISSION_DOCUMENT_INDEXING_SETUP], 'conditional_disable': is_root_node}

index_list = {'text': _(u'index list'), 'view': 'index_list', 'famfam': 'tab', 'permissions': [PERMISSION_DOCUMENT_INDEXING_VIEW]}

index_parent = {'text': _(u'go up one level'), 'view': 'index_instance_node_view', 'args': 'object.parent.pk', 'famfam': 'arrow_up', 'permissions': [PERMISSION_DOCUMENT_INDEXING_VIEW], 'dont_mark_active': True, 'condition': is_not_instance_root_node}
document_index_list = {'text': _(u'indexes'), 'view': 'document_index_list', 'args': 'object.pk', 'famfam': 'folder_page', 'permissions': [PERMISSION_DOCUMENT_INDEXING_VIEW, PERMISSION_DOCUMENT_VIEW]}

register_top_menu('indexes', link={'text': _('indexes'), 'famfam': 'tab', 'view': 'index_list', 'children_view_regex': [r'^index_[i,l]']})

rebuild_index_instances = {'text': _('rebuild indexes'), 'view': 'rebuild_index_instances', 'famfam': 'folder_page', 'permissions': [PERMISSION_DOCUMENT_INDEXING_REBUILD_INDEXES], 'description': _(u'Deletes and creates from scratch all the document indexes.')}

register_maintenance_links([rebuild_index_instances], namespace='document_indexing', title=_(u'Indexes'))

register_sidebar_template(['index_instance_list'], 'indexing_help.html')

register_links(IndexInstanceNode, [index_parent])

register_links(Document, [document_index_list], menu_name='form_header')

register_setup(index_setup)

register_links([Index, 'index_setup_list', 'index_setup_create', 'template_node_edit', 'template_node_delete'], [index_setup_list, index_setup_create], menu_name='secondary_menu')

register_links(Index, [index_setup_edit, index_setup_delete, index_setup_view])

register_links(IndexTemplateNode, [template_node_create, template_node_edit, template_node_delete])
Esempio n. 19
0
    SourceTransformation,
    [setup_source_transformation_edit, setup_source_transformation_delete])
register_links([
    SourceTransformation, 'sources:setup_source_transformation_create',
    'sources:setup_source_transformation_list'
], [setup_source_transformation_create],
               menu_name='sidebar')
register_links([
    'documents:document_version_list', 'documents:upload_version',
    'documents:document_version_revert'
], [upload_version],
               menu_name='sidebar')
register_links([
    Document, 'documents:document_list_recent', 'documents:document_list',
    'sources:document_create', 'sources:document_create_multiple',
    'sources:upload_interactive', 'sources:staging_file_delete'
], [document_create_multiple],
               menu_name='secondary_menu')
register_links(Document, [document_create_siblings])
register_links([
    'sources:document_create', 'sources:document_create_multiple',
    'sources:upload_interactive', 'sources:staging_file_delete'
], [document_list_recent, document_list],
               menu_name='secondary_menu')

register_setup(setup_sources)

APIEndPoint('sources')

FrontPageButton(link=document_create_multiple)
Esempio n. 20
0
from django.utils.translation import ugettext_lazy as _

from project_setup.api import register_setup


def is_superuser(context):
    return context['request'].user.is_staff or context['request'].user.is_superuser

check_settings = {'text': _(u'settings'), 'view': 'setting_list', 'famfam': 'cog', 'icon': 'cog.png', 'condition': is_superuser, 'children_view_regex': [r'^setting_']}

register_setup(check_settings)
Esempio n. 21
0
from .classes import (AccessHolder, AccessObjectClass, ClassAccessHolder,
                      AccessObject)
from .links import (acl_detail, acl_grant, acl_revoke, acl_holder_new,
                    acl_setup_valid_classes, acl_class_list,
                    acl_class_acl_list, acl_class_acl_detail,
                    acl_class_new_holder_for, acl_class_grant,
                    acl_class_revoke)
from .models import CreatorSingleton

register_links(AccessHolder, [acl_detail])
register_multi_item_links(['acl_detail'], [acl_grant, acl_revoke])

register_links([AccessObject], [acl_holder_new], menu_name='sidebar')

register_setup(acl_setup_valid_classes)
register_links([
    'acl_setup_valid_classes', 'acl_class_acl_list',
    'acl_class_new_holder_for', 'acl_class_acl_detail',
    'acl_class_multiple_grant', 'acl_class_multiple_revoke'
], [acl_class_list],
               menu_name='secondary_menu')

register_links(ClassAccessHolder, [acl_class_acl_detail])

register_links(AccessObjectClass,
               [acl_class_acl_list, acl_class_new_holder_for])
register_multi_item_links(['acl_class_acl_detail'],
                          [acl_class_grant, acl_class_revoke])

Esempio n. 22
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)
Esempio n. 23
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)
Esempio n. 24
0
from __future__ import absolute_import

from hkp import Key as KeyServerKey

from navigation.api import register_links
from project_setup.api import register_setup

from .api import Key
from .links import (public_keys, key_delete, key_query, key_receive, key_setup)

# register_links(['key_delete', 'key_private_list', 'key_public_list', 'key_query'], [private_keys, public_keys, key_query], menu_name='sidebar')
register_links(['key_delete', 'key_public_list', 'key_query'],
               [public_keys, key_query],
               menu_name='sidebar')

register_links(Key, [key_delete])
register_links(KeyServerKey, [key_receive])

register_setup(key_setup)
Esempio n. 25
0
from django.utils.translation import ugettext_lazy as _

from navigation.api import register_links, register_multi_item_links
from permissions.api import register_permission, set_namespace_title
from project_setup.api import register_setup

from static_urls.models import URL

url_setup = {'text': _(u'static links'), 'view': 'url_list', 'icon': 'link.png'}#, 'permissions': [PERMISSION_USER_VIEW]}
url_list = {'text': _(u'static link list'), 'view': 'url_list', 'famfam': 'link'}#, 'permissions': [PERMISSION_USER_VIEW]}
url_add = {'text': _(u'new static link'), 'view': 'url_add', 'famfam': 'link_add'}#, 'permissions': [PERMISSION_USER_CREATE]}
url_edit = {'text': _(u'edit'), 'view': 'url_edit', 'args': 'object.id', 'famfam': 'link_edit'}#, 'permissions': [PERMISSION_USER_EDIT]}
url_delete = {u'text': _('delete'), 'view': 'url_delete', 'args': 'object.id', 'famfam': 'link_delete'}#, 'permissions': [PERMISSION_USER_DELETE]}
url_multiple_delete = {u'text': _('delete'), 'view': 'url_multiple_delete', 'famfam': 'link_delete'}#, 'permissions': [PERMISSION_USER_DELETE]}


register_links(URL, [url_edit, url_delete])
register_links(['url_list', 'url_add', 'url_edit', 'url_delete', 'url_multiple_delete'], [url_list, url_add], menu_name=u'sidebar')
register_multi_item_links(['url_list'], [url_multiple_delete])

register_setup(url_setup)
Esempio n. 26
0
setup_document_type_metadata = {'text': _(u'default metadata'), 'view': 'setup_document_type_metadata', 'args': 'document_type.pk', 'famfam': 'xhtml', 'permissions': [PERMISSION_DOCUMENT_TYPE_EDIT]}

register_links(['metadata_add', 'metadata_edit', 'metadata_remove', 'metadata_view'], [metadata_add, metadata_edit, metadata_remove], menu_name='sidebar')
register_links(Document, [metadata_view], menu_name='form_header')
register_multi_item_links(['document_find_duplicates', 'folder_view', 'index_instance_list', 'document_type_document_list', 'search', 'results', 'document_group_view', 'document_list', 'document_list_recent'], [metadata_multiple_add, metadata_multiple_edit, metadata_multiple_remove])

register_links(MetadataType, [setup_metadata_type_edit, setup_metadata_type_delete])
register_links([MetadataType, 'setup_metadata_type_list', 'setup_metadata_type_create'], [setup_metadata_type_list, setup_metadata_type_create], menu_name='secondary_menu')

register_links(MetadataSet, [setup_metadata_set_edit, setup_metadata_set_delete])
register_links([MetadataSet, 'setup_metadata_set_list', 'setup_metadata_set_create'], [setup_metadata_set_list, setup_metadata_set_create], menu_name='secondary_menu')

register_links(DocumentType, [setup_document_type_metadata])

metadata_type_setup_views = ['setup_metadata_type_list', 'setup_metadata_type_edit', 'setup_metadata_type_delete', 'setup_metadata_type_create']
metadata_set_setup_views = ['setup_metadata_set_list', 'setup_metadata_set_edit', 'setup_metadata_set_delete', 'setup_metadata_set_create']

register_sidebar_template(['setup_metadata_type_list'], 'metadata_type_help.html')
register_sidebar_template(['setup_metadata_set_list'], 'metadata_set_help.html')

register_setup(setup_metadata_type_list)
register_setup(setup_metadata_set_list)

class_permissions(Document, [
    PERMISSION_METADATA_DOCUMENT_EDIT,
    PERMISSION_METADATA_DOCUMENT_ADD,
    PERMISSION_METADATA_DOCUMENT_REMOVE,
    PERMISSION_METADATA_DOCUMENT_VIEW,
])
Esempio n. 27
0
from .models import SmartLink, SmartLinkCondition
from .permissions import (PERMISSION_SMART_LINK_DELETE,
                          PERMISSION_SMART_LINK_EDIT,
                          PERMISSION_SMART_LINK_VIEW)

register_links(Document, [smart_link_instances_for_document],
               menu_name='form_header')
register_links(SmartLink, [
    smart_link_edit, smart_link_document_types, smart_link_condition_list,
    smart_link_acl_list, smart_link_delete
])
register_links(
    [SmartLink, 'linking:smart_link_list', 'linking:smart_link_create'],
    [smart_link_list, smart_link_create],
    menu_name='secondary_menu')
register_links(SmartLinkCondition,
               [smart_link_condition_edit, smart_link_condition_delete])
register_links(ResolvedSmartLink, [smart_link_instance_view])
register_links([
    'linking:smart_link_condition_list', 'linking:smart_link_condition_create',
    'linking:smart_link_condition_edit', 'linking:smart_link_condition_delete'
], [smart_link_condition_create],
               menu_name='sidebar')

register_setup(smart_link_setup)

class_permissions(SmartLink, [
    ACLS_EDIT_ACL, ACLS_VIEW_ACL, PERMISSION_SMART_LINK_DELETE,
    PERMISSION_SMART_LINK_EDIT, PERMISSION_SMART_LINK_VIEW
])
Esempio n. 28
0
register_sidebar_template(['document_type_list'], 'document_types_help.html')

register_links(Document, [document_view_simple],
               menu_name='form_header',
               position=0)
register_links(Document, [document_view_advanced],
               menu_name='form_header',
               position=1)
register_links(Document, [document_history_view], menu_name='form_header')
register_links(Document, [document_version_list], menu_name='form_header')

if (not validate_path(
        document_settings.CACHE_PATH)) or (not document_settings.CACHE_PATH):
    setattr(document_settings, 'CACHE_PATH', tempfile.mkdtemp())

register_setup(document_type_setup)

class_permissions(Document, [
    PERMISSION_DOCUMENT_PROPERTIES_EDIT, PERMISSION_DOCUMENT_EDIT,
    PERMISSION_DOCUMENT_VIEW, PERMISSION_DOCUMENT_DELETE,
    PERMISSION_DOCUMENT_DOWNLOAD, PERMISSION_DOCUMENT_TRANSFORM,
    PERMISSION_DOCUMENT_NEW_VERSION, PERMISSION_DOCUMENT_VERSION_REVERT,
    PERMISSION_HISTORY_VIEW
])

document_search = SearchModel('documents', 'Document')
document_search.add_model_field('document_type__name',
                                label=_(u'Document type'))
document_search.add_model_field('versions__mimetype', label=_(u'MIME type'))
document_search.add_model_field('versions__filename', label=_(u'Filename'))
document_search.add_model_field('metadata__metadata_type__name',
Esempio n. 29
0
    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))
    },
])
Esempio n. 30
0
from menu_manager.models import MenuEntry

#PERMISSION_USER_CREATE = {'namespace': 'user_management', 'name': 'user_create', 'label': _(u'Create new users')}
#PERMISSION_USER_EDIT = {'namespace': 'user_management', 'name': 'user_edit', 'label': _(u'Edit existing users')}
#PERMISSION_USER_VIEW = {'namespace': 'user_management', 'name': 'user_view', 'label': _(u'View existing users')}
#PERMISSION_USER_DELETE = {'namespace': 'user_management', 'name': 'user_delete', 'label': _(u'Delete existing users')}

#set_namespace_title('user_management', _(u'User management'))
#register_permission(PERMISSION_USER_CREATE)
#register_permission(PERMISSION_USER_EDIT)
#register_permission(PERMISSION_USER_VIEW)
#register_permission(PERMISSION_USER_DELETE)

menu_list = {'text': _(u'root menu list'), 'view': 'menu_list', 'famfam': 'tab_go'}#, 'permissions': [PERMISSION_USER_VIEW]}
menu_add = {'text': _(u'new root menu'), 'view': 'menu_add', 'famfam': 'tab_add'}#, 'permissions': [PERMISSION_USER_CREATE]}
menu_edit = {'text': _(u'edit'), 'view': 'menu_edit', 'args': 'object.id', 'famfam': 'tab_edit'}#, 'permissions': [PERMISSION_USER_EDIT]}
menu_delete = {u'text': _('delete'), 'view': 'menu_delete', 'args': 'object.id', 'famfam': 'tab_delete'}#, 'permissions': [PERMISSION_USER_DELETE]}
menu_multiple_delete = {u'text': _('delete'), 'view': 'menu_multiple_delete', 'famfam': 'tab_delete'}#, 'permissions': [PERMISSION_USER_DELETE]}
menu_add_child = {'text': _(u'new menu entry'), 'view': 'menu_add_child', 'args': 'object.id', 'famfam': 'tab_add'}#, 'permissions': [PERMISSION_USER_CREATE]}
menu_setup = {'text': _(u'menus'), 'view': 'menu_list', 'icon': 'menu.png'}#, 'permissions': [PERMISSION_USER_VIEW]}
menu_promote = {'text': _(u'up'), 'view': 'menu_promote', 'args': 'object.id', 'famfam': 'arrow_up'}#, 'permissions': [PERMISSION_USER_CREATE]}
menu_demote = {'text': _(u'down'), 'view': 'menu_demote', 'args': 'object.id', 'famfam': 'arrow_down'}#, 'permissions': [PERMISSION_USER_CREATE]}

register_links(MenuEntry, [menu_edit, menu_delete, menu_add_child])
register_links(['menu_list', 'menu_details', 'menu_add', 'menu_add_child', 'menu_edit', 'menu_delete', 'menu_multiple_delete'], [menu_list, menu_add], menu_name=u'sidebar')
register_multi_item_links(['menu_list'], [menu_multiple_delete])

register_setup(menu_setup)

Esempio n. 31
0
Link.bind_links([Group], [group_edit, group_members, group_delete])
Link.bind_links([
    'group_multiple_delete', 'group_delete', 'group_edit', 'group_list',
    'group_add', 'group_members'
], [group_list, group_add],
                menu_name=u'secondary_menu')
register_multi_item_links(['group_list'], [group_multiple_delete])

user_management_views = [
    'user_list', 'user_edit', 'user_add', 'user_delete',
    'user_multiple_delete', 'user_set_password', 'user_multiple_set_password',
    'group_list', 'group_edit', 'group_add', 'group_delete',
    'group_multiple_delete', 'group_members'
]

register_setup(user_setup)
register_setup(group_setup)

register_model_list_columns(User, [
    {
        'name': _(u'full name'),
        'attribute': 'get_full_name'
    },
    {
        'name': _(u'email'),
        'attribute': 'email'
    },
    {
        'name':
        _(u'active'),
        'attribute':
Esempio n. 32
0
from .conf.settings import DEFAULT_ROLES
from .models import Role
from .links import (role_list, role_create, role_edit, role_members, role_permissions,
    role_delete, permission_grant, permission_revoke)

register_links(Role, [role_edit, role_delete, role_permissions, role_members])
register_links([Role, 'role_list', 'role_create'], [role_list, role_create], menu_name='secondary_menu')
register_multi_item_links(['role_permissions'], [permission_grant, permission_revoke])

permission_views = ['role_list', 'role_create', 'role_edit', 'role_members', 'role_permissions', 'role_delete']


def user_post_save(sender, instance, **kwargs):
    if kwargs.get('created', False):
        for default_role in DEFAULT_ROLES:
            if isinstance(default_role, Role):
                # If a model is passed, execute method
                default_role.add_member(instance)
            else:
                # If a role name is passed, lookup the corresponding model
                try:
                    role = Role.objects.get(name=default_role)
                    role.add_member(instance)
                except ObjectDoesNotExist:
                    pass

post_save.connect(user_post_save, sender=User)

register_setup(role_list)
Esempio n. 33
0
    [SmartLink, "smart_link_list", "smart_link_create"],
    [smart_link_list, smart_link_create],
    menu_name="secondary_menu",
)

register_links(SmartLinkCondition, [smart_link_condition_edit, smart_link_condition_delete])
register_links(
    [
        "smart_link_condition_list",
        "smart_link_condition_create",
        "smart_link_condition_edit",
        "smart_link_condition_delete",
    ],
    [smart_link_condition_create],
    menu_name="sidebar",
)

register_setup(smart_link_setup)
register_sidebar_template(["smart_link_list"], "smart_links_help.html")

class_permissions(
    SmartLink,
    [
        PERMISSION_SMART_LINK_VIEW,
        PERMISSION_SMART_LINK_DELETE,
        PERMISSION_SMART_LINK_EDIT,
        ACLS_EDIT_ACL,
        ACLS_VIEW_ACL,
    ],
)
Esempio n. 34
0
    "setup_source_transformation_create",
]

register_model_list_columns(
    StagingFile,
    [
        {
            "name": _(u"thumbnail"),
            "attribute": encapsulate(
                lambda x: staging_file_thumbnail(x, gallery_name="staging_list", title=x.filename, size="100")
            ),
        }
    ],
)

register_setup(setup_sources)

register_links(
    [
        Document,
        "document_list_recent",
        "document_list",
        "document_create",
        "document_create_multiple",
        "upload_interactive",
        "staging_file_delete",
    ],
    [document_create_multiple],
    menu_name="secondary_menu",
)
register_links(Document, [document_create_siblings])
Esempio n. 35
0
register_links(Role, [role_edit, role_delete, role_permissions, role_members])
register_links([Role, 'role_list', 'role_create'], [role_list, role_create],
               menu_name='secondary_menu')
register_multi_item_links(['role_permissions'],
                          [permission_grant, permission_revoke])

permission_views = [
    'role_list', 'role_create', 'role_edit', 'role_members',
    'role_permissions', 'role_delete'
]


def user_post_save(sender, instance, **kwargs):
    if kwargs.get('created', False):
        for default_role in DEFAULT_ROLES:
            if isinstance(default_role, Role):
                #If a model is passed, execute method
                default_role.add_member(instance)
            else:
                #If a role name is passed, lookup the corresponding model
                try:
                    role = Role.objects.get(name=default_role)
                    role.add_member(instance)
                except ObjectDoesNotExist:
                    pass


post_save.connect(user_post_save, sender=User)

register_setup(role_list)