Esempio n. 1
0
    def ready(self):
        super(TagsApp, self).ready()
        from .wizard_steps import WizardStepTags  # NOQA

        Document = apps.get_model(app_label='documents', model_name='Document')

        DocumentPageResult = apps.get_model(app_label='documents',
                                            model_name='DocumentPageResult')

        DocumentTag = self.get_model(model_name='DocumentTag')
        Tag = self.get_model(model_name='Tag')

        Document.add_to_class(name='get_tags', value=method_document_get_tags)

        EventModelRegistry.register(model=Tag)

        ModelCopy(model=Tag, bind_link=True,
                  register_permission=True).add_fields(field_names=(
                      'label',
                      'color',
                      'documents',
                  ), )

        ModelEventType.register(model=Tag,
                                event_types=(event_tag_attach,
                                             event_tag_edited,
                                             event_tag_removed))

        ModelFieldRelated(model=Document, name='tags__label')
        ModelFieldRelated(model=Document, name='tags__color')

        ModelPermission.register(model=Document,
                                 permissions=(permission_tag_attach,
                                              permission_tag_remove,
                                              permission_tag_view))

        ModelPermission.register(model=Tag,
                                 permissions=(
                                     permission_acl_edit,
                                     permission_acl_view,
                                     permission_events_view,
                                     permission_tag_attach,
                                     permission_tag_delete,
                                     permission_tag_edit,
                                     permission_tag_remove,
                                     permission_tag_view,
                                 ))

        model_query_fields_document = ModelQueryFields.get(model=Document)
        model_query_fields_document.add_prefetch_related_field(
            field_name='tags')

        model_query_fields_tag = ModelQueryFields.get(model=Tag)
        model_query_fields_tag.add_prefetch_related_field(
            field_name='documents')

        SourceColumn(attribute='label',
                     is_identifier=True,
                     is_sortable=True,
                     source=DocumentTag)

        SourceColumn(func=lambda context: widget_document_tags(
            document=context['object'], user=context['request'].user),
                     label=_('Tags'),
                     source=Document)

        SourceColumn(func=lambda context: widget_document_tags(
            document=context['object'].document, user=context['request'].user),
                     label=_('Tags'),
                     source=DocumentPageResult)

        SourceColumn(attribute='label',
                     is_identifier=True,
                     is_sortable=True,
                     source=Tag)
        SourceColumn(attribute='get_preview_widget',
                     include_label=True,
                     source=Tag)
        source_column_tag_document_count = SourceColumn(
            func=lambda context: context['object'].get_document_count(
                user=context['request'].user),
            include_label=True,
            label=_('Documents'),
            source=Tag)
        source_column_tag_document_count.add_exclude(source=DocumentTag)

        menu_facet.bind_links(links=(link_document_tag_list, ),
                              sources=(Document, ))

        menu_list_facet.bind_links(links=(
            link_acl_list,
            link_events_for_object,
            link_object_event_types_user_subcriptions_list,
            link_tag_document_list,
        ),
                                   sources=(Tag, ))

        menu_tags.bind_links(links=(link_tag_list, link_tag_create))

        menu_main.bind_links(links=(menu_tags, ), position=98)

        menu_multi_item.bind_links(
            links=(link_document_multiple_attach_multiple_tag,
                   link_document_multiple_tag_multiple_remove),
            sources=(Document, ))
        menu_multi_item.bind_links(links=(link_tag_multiple_delete, ),
                                   sources=(Tag, ))
        menu_object.bind_links(links=(link_tag_edit, link_tag_delete),
                               sources=(Tag, ))
        menu_secondary.bind_links(
            links=(link_document_tag_multiple_attach,
                   link_document_tag_multiple_remove),
            sources=('tags:tag_attach', 'tags:document_tag_list',
                     'tags:single_document_multiple_tag_remove'))

        # Index update

        m2m_changed.connect(dispatch_uid='tags_handler_index_document',
                            receiver=handler_index_document,
                            sender=Tag.documents.through)

        pre_delete.connect(dispatch_uid='tags_handler_tag_pre_delete',
                           receiver=handler_tag_pre_delete,
                           sender=Tag)
Esempio n. 2
0
    def ready(self):
        super(DocumentIndexingApp, self).ready()
        from actstream import registry

        Document = apps.get_model(app_label='documents', model_name='Document')

        DocumentType = apps.get_model(app_label='documents',
                                      model_name='DocumentType')

        DocumentIndexInstanceNode = self.get_model(
            model_name='DocumentIndexInstanceNode')

        Index = self.get_model(model_name='Index')
        IndexInstance = self.get_model(model_name='IndexInstance')
        IndexInstanceNode = self.get_model(model_name='IndexInstanceNode')
        IndexTemplateNode = self.get_model(model_name='IndexTemplateNode')

        ModelEventType.register(event_types=(event_index_template_created,
                                             event_index_template_edited),
                                model=Index)

        ModelPermission.register(
            model=Index,
            permissions=(
                permission_acl_edit,
                permission_acl_view,
                permission_document_indexing_delete,
                permission_document_indexing_edit,
                permission_document_indexing_instance_view,
                permission_document_indexing_rebuild,
                permission_document_indexing_view,
            ))
        ModelPermission.register_inheritance(model=IndexTemplateNode,
                                             related='index')

        ModelPermission.register_inheritance(
            model=IndexInstanceNode, related='index_template_node__index')

        column_index_label = SourceColumn(attribute='label',
                                          is_identifier=True,
                                          is_sortable=True,
                                          source=Index)
        column_index_label.add_exclude(source=IndexInstance)
        SourceColumn(attribute='label',
                     is_object_absolute_url=True,
                     is_identifier=True,
                     is_sortable=True,
                     source=IndexInstance)
        column_index_slug = SourceColumn(attribute='slug',
                                         is_sortable=True,
                                         source=Index)
        column_index_slug.add_exclude(IndexInstance)
        column_index_enabled = SourceColumn(attribute='enabled',
                                            is_sortable=True,
                                            source=Index,
                                            widget=TwoStateWidget)
        column_index_enabled.add_exclude(source=IndexInstance)

        SourceColumn(func=lambda context: context['object'].instance_root.
                     get_descendants_count(),
                     label=_('Total levels'),
                     source=IndexInstance)
        SourceColumn(
            func=lambda context: context['object'].instance_root.
            get_descendants_document_count(user=context['request'].user),
            label=_('Total documents'),
            source=IndexInstance)

        SourceColumn(func=lambda context: node_level(context['object']),
                     label=_('Level'),
                     source=IndexTemplateNode)
        SourceColumn(attribute='enabled',
                     is_sortable=True,
                     source=IndexTemplateNode,
                     widget=TwoStateWidget)
        SourceColumn(attribute='link_documents',
                     is_sortable=True,
                     source=IndexTemplateNode,
                     widget=TwoStateWidget)
        SourceColumn(
            func=lambda context: index_instance_item_link(context['object']),
            label=_('Level'),
            is_sortable=True,
            sort_field='value',
            source=IndexInstanceNode)
        SourceColumn(
            func=lambda context: context['object'].get_descendants_count(),
            label=_('Levels'),
            source=IndexInstanceNode)

        SourceColumn(
            func=lambda context: context['object'].
            get_descendants_document_count(user=context['request'].user),
            label=_('Documents'),
            source=IndexInstanceNode)

        SourceColumn(func=lambda context: get_instance_link(
            index_instance_node=context['object'], ),
                     label=_('Level'),
                     is_sortable=True,
                     sort_field='value',
                     source=DocumentIndexInstanceNode)
        SourceColumn(
            func=lambda context: context['object'].get_descendants_count(),
            label=_('Levels'),
            source=DocumentIndexInstanceNode)
        SourceColumn(
            func=lambda context: context['object'].
            get_descendants_document_count(user=context['request'].user),
            label=_('Documents'),
            source=DocumentIndexInstanceNode)

        menu_facet.bind_links(links=(link_document_index_instance_list, ),
                              sources=(Document, ))
        menu_list_facet.bind_links(
            links=(link_document_type_index_templates, ),
            sources=(DocumentType, ))
        menu_list_facet.bind_links(
            links=(link_acl_list, link_events_for_object,
                   link_index_template_document_types,
                   link_index_template_node_tree_view,
                   link_object_event_types_user_subcriptions_list),
            sources=(Index, ))
        menu_object.bind_links(links=(link_index_template_delete,
                                      link_index_template_edit,
                                      link_index_instance_rebuild),
                               sources=(Index, ))
        menu_object.bind_links(links=(link_index_template_node_create,
                                      link_index_template_node_edit,
                                      link_index_template_node_delete),
                               sources=(IndexTemplateNode, ))
        menu_main.bind_links(links=(link_index_instance_menu, ), position=98)
        menu_secondary.bind_links(links=(link_index_template_list,
                                         link_index_template_create),
                                  sources=(Index, 'indexing:index_setup_list',
                                           'indexing:index_setup_create'))
        menu_setup.bind_links(links=(link_index_template_setup, ))
        menu_tools.bind_links(links=(link_index_instances_rebuild,
                                     link_index_instances_reset))

        post_delete.connect(
            dispatch_uid='document_indexing_handler_delete_empty',
            receiver=handler_delete_empty,
            sender=Document)
        post_document_created.connect(
            dispatch_uid='document_indexing_handler_index_document',
            receiver=handler_index_document,
            sender=Document)
        post_initial_document_type.connect(
            dispatch_uid=
            'document_indexing_handler_create_default_document_index',
            receiver=handler_create_default_document_index,
            sender=DocumentType)
        post_save.connect(
            dispatch_uid='document_indexing_handler_post_save_index_document',
            receiver=handler_post_save_index_document,
            sender=Document)
        pre_delete.connect(
            dispatch_uid='document_indexing_handler_remove_document',
            receiver=handler_remove_document,
            sender=Document)

        registry.register(Index)
Esempio n. 3
0
    def ready(self):
        super(DocumentStatesApp, self).ready()
        from actstream import registry

        Action = apps.get_model(app_label='actstream', model_name='Action')
        Document = apps.get_model(app_label='documents', model_name='Document')
        DocumentType = apps.get_model(app_label='documents',
                                      model_name='DocumentType')
        ErrorLogEntry = apps.get_model(app_label='common',
                                       model_name='ErrorLogEntry')

        Workflow = self.get_model('Workflow')
        WorkflowInstance = self.get_model('WorkflowInstance')
        WorkflowInstanceLogEntry = self.get_model('WorkflowInstanceLogEntry')
        WorkflowRuntimeProxy = self.get_model('WorkflowRuntimeProxy')
        WorkflowState = self.get_model('WorkflowState')
        WorkflowStateAction = self.get_model('WorkflowStateAction')
        WorkflowStateRuntimeProxy = self.get_model('WorkflowStateRuntimeProxy')
        WorkflowTransition = self.get_model('WorkflowTransition')
        WorkflowTransitionField = self.get_model('WorkflowTransitionField')
        WorkflowTransitionTriggerEvent = self.get_model(
            'WorkflowTransitionTriggerEvent')

        Document.add_to_class(name='workflow',
                              value=DocumentStateHelper.constructor)

        ErrorLogEntry.objects.register(model=WorkflowStateAction)

        WorkflowAction.initialize()

        ModelProperty(
            model=Document,
            name='workflow.< workflow internal name >.get_current_state',
            label=_('Current state of a workflow'),
            description=_(
                'Return the current state of the selected workflow.'))
        ModelProperty(
            model=Document,
            name=
            'workflow.< workflow internal name >.get_current_state.completion',
            label=_('Current state of a workflow'),
            description=_(
                'Return the completion value of the current state of the '
                'selected workflow.'))

        ModelEventType.register(event_types=(event_workflow_edited, ),
                                model=Workflow)

        ModelPermission.register(model=Document,
                                 permissions=(permission_workflow_view, ))
        ModelPermission.register(
            model=Workflow,
            permissions=(permission_error_log_view, permission_workflow_delete,
                         permission_workflow_edit, permission_workflow_tools,
                         permission_workflow_transition,
                         permission_workflow_view))
        ModelPermission.register(
            model=WorkflowTransition,
            permissions=(permission_workflow_transition, ))

        ModelPermission.register_inheritance(
            model=WorkflowInstance,
            related='workflow',
        )
        ModelPermission.register_inheritance(
            model=WorkflowInstanceLogEntry,
            related='workflow_instance__workflow',
        )
        ModelPermission.register_inheritance(
            model=WorkflowState,
            related='workflow',
        )
        ModelPermission.register_inheritance(
            model=WorkflowStateAction,
            related='state__workflow',
        )
        ModelPermission.register_inheritance(
            model=WorkflowTransition,
            related='workflow',
        )
        ModelPermission.register_inheritance(
            model=WorkflowTransitionField,
            related='transition',
        )
        ModelPermission.register_inheritance(
            model=WorkflowTransitionTriggerEvent,
            related='transition__workflow',
        )

        ModelField(model=WorkflowInstance, name='document')
        ModelField(model=WorkflowInstance, name='workflow')
        ModelReverseField(model=WorkflowInstance, name='log_entries')

        ModelProperty(description=_(
            'Return the last workflow instance log entry. The '
            'log entry itself has the following fields: datetime, '
            'transition, user, and comment.'),
                      label=_('Get last log entry'),
                      model=WorkflowInstance,
                      name='get_last_log_entry')

        ModelProperty(description=_(
            'Return the current context dictionary which includes '
            'runtime data from the workflow transition fields.'),
                      label=_('Get the context'),
                      model=WorkflowInstance,
                      name='get_runtime_context')

        ModelProperty(
            description=_('Return the transition of the workflow instance.'),
            label=_('Get last transition'),
            model=WorkflowInstance,
            name='get_last_transition')

        SourceColumn(attribute='label',
                     is_identifier=True,
                     is_sortable=True,
                     source=Workflow)
        column_workflow_internal_name = SourceColumn(attribute='internal_name',
                                                     include_label=True,
                                                     is_sortable=True,
                                                     source=Workflow)
        column_workflow_internal_name.add_exclude(source=WorkflowRuntimeProxy)
        SourceColumn(attribute='get_initial_state',
                     empty_value=_('None'),
                     include_label=True,
                     source=Workflow)

        SourceColumn(
            attribute='get_current_state',
            include_label=True,
            label=_('Current state'),
            source=WorkflowInstance,
        )
        SourceColumn(func=lambda context: getattr(
            context['object'].get_last_log_entry(), 'user', _('None')),
                     include_label=True,
                     label=_('User'),
                     source=WorkflowInstance)
        SourceColumn(attribute='get_last_transition',
                     include_label=True,
                     label=_('Last transition'),
                     source=WorkflowInstance)
        SourceColumn(func=lambda context: getattr(
            context['object'].get_last_log_entry(), 'datetime', _('None')),
                     include_label=True,
                     label=_('Date and time'),
                     source=WorkflowInstance)
        SourceColumn(func=lambda context: getattr(
            context['object'].get_current_state(), 'completion', _('None')),
                     include_label=True,
                     label=_('Completion'),
                     source=WorkflowInstance)

        SourceColumn(attribute='datetime',
                     is_identifier=True,
                     label=_('Date and time'),
                     source=WorkflowInstanceLogEntry)
        SourceColumn(attribute='user',
                     include_label=True,
                     label=_('User'),
                     source=WorkflowInstanceLogEntry)
        SourceColumn(attribute='transition__origin_state',
                     include_label=True,
                     is_sortable=True,
                     source=WorkflowInstanceLogEntry)
        SourceColumn(attribute='transition',
                     include_label=True,
                     is_sortable=True,
                     source=WorkflowInstanceLogEntry)
        SourceColumn(attribute='transition__destination_state',
                     include_label=True,
                     is_sortable=True,
                     source=WorkflowInstanceLogEntry)
        SourceColumn(attribute='comment',
                     include_label=True,
                     is_sortable=True,
                     source=WorkflowInstanceLogEntry)
        SourceColumn(attribute='get_extra_data',
                     include_label=True,
                     label=_('Additional details'),
                     source=WorkflowInstanceLogEntry,
                     widget=WorkflowLogExtraDataWidget)

        SourceColumn(attribute='label',
                     is_identifier=True,
                     is_sortable=True,
                     source=WorkflowState)
        SourceColumn(attribute='initial',
                     include_label=True,
                     is_sortable=True,
                     source=WorkflowState,
                     widget=TwoStateWidget)
        SourceColumn(attribute='completion',
                     include_label=True,
                     is_sortable=True,
                     source=WorkflowState)

        SourceColumn(attribute='label',
                     is_identifier=True,
                     is_sortable=True,
                     source=WorkflowStateAction)
        SourceColumn(attribute='enabled',
                     include_label=True,
                     is_sortable=True,
                     source=WorkflowStateAction,
                     widget=TwoStateWidget)
        SourceColumn(attribute='get_when_display',
                     include_label=True,
                     label=_('When?'),
                     source=WorkflowStateAction)
        SourceColumn(attribute='get_class_label',
                     include_label=True,
                     label=_('Action type'),
                     source=WorkflowStateAction)
        SourceColumn(attribute='has_condition',
                     include_label=True,
                     source=WorkflowStateAction,
                     widget=TwoStateWidget)

        SourceColumn(
            attribute='label',
            is_identifier=True,
            is_sortable=True,
            source=WorkflowTransition,
        )
        SourceColumn(attribute='origin_state',
                     include_label=True,
                     is_sortable=True,
                     source=WorkflowTransition)
        SourceColumn(attribute='destination_state',
                     include_label=True,
                     is_sortable=True,
                     source=WorkflowTransition)
        SourceColumn(attribute='has_condition',
                     include_label=True,
                     source=WorkflowTransition,
                     widget=TwoStateWidget)
        SourceColumn(
            func=lambda context: widget_transition_events(transition=context[
                'object']),
            help_text=_(
                'Triggers are system events that will cause the transition '
                'to be applied.'),
            include_label=True,
            label=_('Triggers'),
            source=WorkflowTransition)

        SourceColumn(attribute='name',
                     is_identifier=True,
                     is_sortable=True,
                     source=WorkflowTransitionField)
        SourceColumn(attribute='label',
                     include_label=True,
                     is_sortable=True,
                     source=WorkflowTransitionField)
        SourceColumn(attribute='get_field_type_display',
                     include_label=True,
                     label=_('Type'),
                     source=WorkflowTransitionField)
        SourceColumn(attribute='required',
                     include_label=True,
                     is_sortable=True,
                     source=WorkflowTransitionField,
                     widget=TwoStateWidget)
        SourceColumn(attribute='get_widget_display',
                     include_label=True,
                     label=_('Widget'),
                     is_sortable=False,
                     source=WorkflowTransitionField)
        SourceColumn(attribute='widget_kwargs',
                     include_label=True,
                     is_sortable=True,
                     source=WorkflowTransitionField)

        SourceColumn(func=lambda context: context['object'].get_document_count(
            user=context['request'].user),
                     include_label=True,
                     label=_('Documents'),
                     order=99,
                     source=WorkflowRuntimeProxy)
        SourceColumn(func=lambda context: context['object'].get_document_count(
            user=context['request'].user),
                     include_label=True,
                     label=_('Documents'),
                     order=99,
                     source=WorkflowStateRuntimeProxy)

        menu_facet.bind_links(links=(link_workflow_instance_list, ),
                              sources=(Document, ))

        menu_list_facet.bind_links(
            links=(link_acl_list, link_events_for_object,
                   link_object_event_types_user_subcriptions_list,
                   link_workflow_template_document_types,
                   link_workflow_template_state_list,
                   link_workflow_template_transition_list,
                   link_workflow_template_preview),
            sources=(Workflow, ))

        menu_list_facet.unbind_links(
            links=(link_acl_list, link_events_for_object,
                   link_object_event_types_user_subcriptions_list,
                   link_workflow_template_document_types,
                   link_workflow_template_state_list,
                   link_workflow_template_transition_list,
                   link_workflow_template_preview),
            sources=(WorkflowRuntimeProxy, ))

        menu_list_facet.bind_links(
            links=(link_document_type_workflow_templates, ),
            sources=(DocumentType, ))

        menu_main.bind_links(links=(link_workflow_runtime_proxy_list, ),
                             position=10)
        menu_object.bind_links(links=(link_workflow_template_delete,
                                      link_workflow_template_edit,
                                      link_workflow_template_launch),
                               sources=(Workflow, ))
        menu_object.bind_links(links=(link_workflow_template_state_edit,
                                      link_workflow_template_state_action_list,
                                      link_workflow_template_state_delete),
                               sources=(WorkflowState, ))
        menu_object.bind_links(
            links=(link_workflow_template_transition_edit,
                   link_workflow_template_transition_events,
                   link_workflow_template_transition_field_list, link_acl_list,
                   link_workflow_template_transition_delete),
            sources=(WorkflowTransition, ))
        menu_object.bind_links(
            links=(link_workflow_template_transition_field_delete,
                   link_workflow_template_transition_field_edit),
            sources=(WorkflowTransitionField, ))
        menu_object.bind_links(links=(link_workflow_instance_detail,
                                      link_workflow_instance_transition),
                               sources=(WorkflowInstance, ))

        menu_list_facet.bind_links(links=(
            link_workflow_runtime_proxy_document_list,
            link_workflow_runtime_proxy_state_list,
        ),
                                   sources=(WorkflowRuntimeProxy, ))
        menu_list_facet.bind_links(
            links=(link_workflow_runtime_proxy_state_document_list, ),
            sources=(WorkflowStateRuntimeProxy, ))
        menu_object.bind_links(links=(
            link_workflow_template_state_action_edit,
            link_object_error_list,
            link_workflow_template_state_action_delete,
        ),
                               sources=(WorkflowStateAction, ))

        menu_secondary.bind_links(
            links=(link_workflow_template_list, link_workflow_template_create),
            sources=(Workflow, 'document_states:workflow_template_create',
                     'document_states:workflow_template_list'))
        menu_secondary.bind_links(
            links=(link_workflow_template_transition_field_create, ),
            sources=(WorkflowTransition, ))
        menu_secondary.bind_links(links=(link_workflow_runtime_proxy_list, ),
                                  sources=(WorkflowRuntimeProxy, ))
        menu_secondary.bind_links(
            links=(link_workflow_template_state_action_selection, ),
            sources=(WorkflowState, ))
        menu_secondary.bind_links(
            links=(link_workflow_template_transition_create, ),
            sources=(
                WorkflowTransition,
                'document_states:workflow_template_transition_create',
                'document_states:workflow_template_transition_list',
            ))
        menu_secondary.bind_links(
            links=(link_workflow_template_state_create, ),
            sources=(
                WorkflowState,
                'document_states:workflow_template_state_create',
                'document_states:workflow_template_state_list',
            ))

        menu_setup.bind_links(links=(link_workflow_template_list, ))

        menu_tools.bind_links(links=(link_tool_launch_workflows, ))

        post_save.connect(dispatch_uid='workflows_handler_launch_workflow',
                          receiver=handler_launch_workflow,
                          sender=Document)

        # Index updating

        post_migrate.connect(
            dispatch_uid='workflows_handler_create_workflow_image_cache',
            receiver=handler_create_workflow_image_cache,
        )
        post_save.connect(dispatch_uid='workflows_handler_index_document_save',
                          receiver=handler_index_document,
                          sender=WorkflowInstanceLogEntry)
        post_save.connect(dispatch_uid='workflows_handler_trigger_transition',
                          receiver=handler_trigger_transition,
                          sender=Action)

        registry.register(Workflow)
Esempio n. 4
0
    def ready(self):
        super(LinkingApp, self).ready()

        Document = apps.get_model(app_label='documents', model_name='Document')
        DocumentType = apps.get_model(app_label='documents',
                                      model_name='DocumentType')

        ResolvedSmartLink = self.get_model(model_name='ResolvedSmartLink')
        SmartLink = self.get_model(model_name='SmartLink')
        SmartLinkCondition = self.get_model(model_name='SmartLinkCondition')

        EventModelRegistry.register(model=SmartLink)

        ModelEventType.register(event_types=(event_smart_link_edited, ),
                                model=SmartLink)

        ModelPermission.register(model=SmartLink,
                                 permissions=(permission_acl_edit,
                                              permission_acl_view,
                                              permission_smart_link_delete,
                                              permission_smart_link_edit,
                                              permission_smart_link_view))
        ModelPermission.register_inheritance(
            model=SmartLinkCondition,
            related='smart_link',
        )

        SourceColumn(func=lambda context: context['object'].get_label_for(
            document=context['document']),
                     is_identifier=True,
                     label=_('Label'),
                     source=ResolvedSmartLink)

        source_column_smart_link_label = SourceColumn(attribute='label',
                                                      is_identifier=True,
                                                      is_sortable=True,
                                                      source=SmartLink)
        source_column_smart_link_label.add_exclude(ResolvedSmartLink)
        source_column_smart_link_dynamic_label = SourceColumn(
            attribute='dynamic_label',
            include_label=True,
            is_sortable=True,
            source=SmartLink)
        source_column_smart_link_dynamic_label.add_exclude(ResolvedSmartLink)
        source_column_smart_link_enabled = SourceColumn(attribute='enabled',
                                                        include_label=True,
                                                        is_sortable=True,
                                                        source=SmartLink,
                                                        widget=TwoStateWidget)
        source_column_smart_link_enabled.add_exclude(ResolvedSmartLink)
        SourceColumn(attribute='get_full_label',
                     is_identifier=True,
                     source=SmartLinkCondition)
        SourceColumn(attribute='enabled',
                     include_label=True,
                     is_sortable=True,
                     source=SmartLinkCondition,
                     widget=TwoStateWidget)

        menu_facet.bind_links(links=(link_smart_link_instances_for_document, ),
                              sources=(Document, ))
        menu_list_facet.bind_links(links=(
            link_acl_list,
            link_events_for_object,
            link_smart_link_document_types,
            link_object_event_types_user_subcriptions_list,
            link_smart_link_condition_list,
        ),
                                   sources=(SmartLink, ))
        menu_list_facet.bind_links(links=(link_document_type_smart_links, ),
                                   sources=(DocumentType, ))
        menu_object.bind_links(links=(link_smart_link_condition_edit,
                                      link_smart_link_condition_delete),
                               sources=(SmartLinkCondition, ))
        menu_object.bind_links(links=(link_smart_link_delete,
                                      link_smart_link_edit),
                               sources=(SmartLink, ))
        menu_object.bind_links(links=(link_smart_link_instance_view, ),
                               sources=(ResolvedSmartLink, ))
        menu_object.unbind_links(links=(
            link_smart_link_delete,
            link_smart_link_edit,
        ),
                                 sources=(ResolvedSmartLink, ))
        menu_secondary.bind_links(links=(link_smart_link_list,
                                         link_smart_link_create),
                                  sources=(SmartLink,
                                           'linking:smart_link_list',
                                           'linking:smart_link_create'))
        menu_secondary.bind_links(
            links=(link_smart_link_condition_create, ),
            sources=('linking:smart_link_condition_list',
                     'linking:smart_link_condition_create',
                     'linking:smart_link_condition_edit',
                     'linking:smart_link_condition_delete'))
        menu_setup.bind_links(links=(link_smart_link_setup, ))
Esempio n. 5
0
    def ready(self):
        super(WebLinksApp, self).ready()

        Document = apps.get_model(
            app_label='documents', model_name='Document'
        )
        DocumentType = apps.get_model(
            app_label='documents', model_name='DocumentType'
        )

        ResolvedWebLink = self.get_model(model_name='ResolvedWebLink')
        WebLink = self.get_model(model_name='WebLink')

        EventModelRegistry.register(model=ResolvedWebLink)
        EventModelRegistry.register(model=WebLink)

        ModelEventType.register(
            event_types=(
                event_web_link_edited,
            ), model=WebLink
        )

        ModelPermission.register(
            model=Document, permissions=(
                permission_web_link_instance_view,
            )
        )
        ModelPermission.register(
            model=DocumentType, permissions=(
                permission_web_link_instance_view,
            )
        )
        ModelPermission.register(
            model=WebLink, permissions=(
                permission_acl_edit, permission_acl_view,
                permission_web_link_delete, permission_web_link_edit,
                permission_web_link_instance_view, permission_web_link_view
            )
        )

        SourceColumn(
            attribute='label', is_identifier=True, is_sortable=True,
            source=ResolvedWebLink
        )
        SourceColumn(
            attribute='label', is_identifier=True, is_sortable=True,
            source=WebLink
        )
        source_column_enabled = SourceColumn(
            attribute='enabled', include_label=True, is_sortable=True,
            source=WebLink,
            widget=TwoStateWidget
        )
        source_column_enabled.add_exclude(source=ResolvedWebLink)

        menu_facet.bind_links(
            links=(link_document_web_link_list,),
            sources=(Document,)
        )
        menu_list_facet.bind_links(
            links=(
                link_acl_list, link_events_for_object,
                link_web_link_document_types,
                link_object_event_types_user_subcriptions_list,
            ), sources=(WebLink,)
        )
        menu_list_facet.bind_links(
            links=(link_document_type_web_links,), sources=(DocumentType,)
        )
        menu_object.bind_links(
            links=(
                link_web_link_delete, link_web_link_edit
            ), sources=(WebLink,)
        )
        menu_object.bind_links(
            links=(link_web_link_instance_view,),
            sources=(ResolvedWebLink,)
        )
        menu_object.unbind_links(
            links=(
                link_web_link_delete, link_web_link_edit
            ), sources=(ResolvedWebLink,)
        )
        menu_secondary.bind_links(
            links=(link_web_link_list, link_web_link_create),
            sources=(
                WebLink, 'web_links:web_link_list',
                'web_links:web_link_create'
            )
        )
        menu_setup.bind_links(links=(link_web_link_setup,))