Beispiel #1
0
async def test_modified_event_gathers_all_index_data(dummy_guillotina):
    container = await create_content("Container", id="guillotina", title="Guillotina")
    container.__name__ = "guillotina"
    task_vars.container.set(container)
    ob = await create_content("Item", id="foobar")
    ob.__uuid__ = "foobar"
    await notify(ObjectModifiedEvent(ob, payload={"title": "", "id": ""}))
    fut = index.get_indexer()

    assert len(fut.update["foobar"]) == 9

    await notify(ObjectModifiedEvent(ob, payload={"creation_date": ""}))
    assert "modification_date" in fut.update["foobar"]
    assert len(fut.update["foobar"]) == 10
Beispiel #2
0
async def test_modified_event_gathers_all_index_data(dummy_guillotina):
    container = await create_content('Container',
                                     id='guillotina',
                                     title='Guillotina')
    container.__name__ = 'guillotina'
    task_vars.container.set(container)
    ob = await create_content('Item', id='foobar')
    ob.__uuid__ = 'foobar'
    await notify(ObjectModifiedEvent(ob, payload={'title': '', 'id': ''}))
    fut = index.get_indexer()

    assert len(fut.update['foobar']) == 8

    await notify(ObjectModifiedEvent(ob, payload={'creation_date': ''}))
    assert len(fut.update['foobar']) == 9
Beispiel #3
0
async def cms_object_added(obj, event):
    cms = query_adapter(obj, ICMSBehavior)
    if cms is not None:
        await cms.load(create=True)
        txn = get_transaction()
        if supports_ordering(txn.storage):
            pos = await get_next_order()
            cms.position_in_parent = pos
            indexer = index.get_indexer()
            if indexer is None:
                return
            if obj.uuid not in indexer.index:
                indexer.index[obj.uuid] = {}
            indexer.index[
                obj.uuid]["position_in_parent"] = cms.position_in_parent

    if hasattr(obj, "title") and obj.title is None:
        obj.title = obj.id
Beispiel #4
0
async def cms_object_added(obj, event):
    cms = query_adapter(obj, ICMSBehavior)
    if cms is not None:
        user_id = get_authenticated_user_id()

        workflow = IWorkflow(obj)
        await cms.load(create=True)
        state = cms.review_state

        if 'set_permission' in workflow.states[state]:
            await apply_sharing(obj, workflow.states[state]['set_permission'])

        setattr(cms, 'history', [])
        cms.history.append({
            'actor': user_id,
            'comments': '',
            'time': datetime.datetime.now(),
            'title': 'Created',
            'type': 'workflow',
            'data': {
                'action': None,
                'review_state': state,
            }
        })
        cms.register()
        txn = get_transaction()
        if supports_ordering(txn.storage):
            pos = await get_next_order()
            cms.position_in_parent = pos
            indexer = index.get_indexer()
            if indexer is None:
                return
            if obj.uuid not in indexer.index:
                indexer.index[obj.uuid] = {}
            indexer.index[
                obj.uuid]['position_in_parent'] = cms.position_in_parent

    if hasattr(obj, 'title') and obj.title is None:
        obj.title = obj.id