Exemplo n.º 1
0
def object_moved_event(obj, evt):
    """ """
    request = getattr(obj, 'REQUEST', None)
    if not request:
        return
    if not IStickyStatusMessagesLayer.providedBy(request):
        return

    if obj.isTemporary() or not evt.newParent or not evt.oldParent:
        return

    if 'portal_factory' in evt.oldParent.getPhysicalPath():
        return

    folder = evt.newParent
    folder_title = folder.Title() or ''
    obj_title = obj.Title() or ''
    message = _(
                u'%s <em>%s</em> moved into <a href="%s">%s</a>' \
                                        % ( obj.portal_type,
                                            safe_unicode(obj_title),
                                            '/'.join(folder.getPhysicalPath()),
                                            safe_unicode(folder_title),
                                            )
                )
    utils.set_sticky_status_message(obj, message)
Exemplo n.º 2
0
def object_state_changed_event(obj, evt):
    """ """
    request = getattr(obj, 'REQUEST', None)
    if not request:
        return
    if not IStickyStatusMessagesLayer.providedBy(request):
        return

    folder = obj.aq_parent
    folder_title = folder.Title() or ''
    obj_title = obj.Title() or ''
    workflowTool = getToolByName(obj, "portal_workflow")
    chain = workflowTool.getChainFor(obj)
    status = workflowTool.getStatusOf(chain[0], obj)
    state = status["review_state"]
    message = _(
                u'The workflow state of %s <a href="%s">%s</a> ' \
                'in <a href="%s">%s</a> has been changed to <em>%s</em>' \
                    % ( obj.portal_type,
                        '/'.join(obj.getPhysicalPath()),
                        safe_unicode(obj_title),
                        '/'.join(folder.getPhysicalPath()),
                        safe_unicode(folder_title),
                        state,
                        )
                )

    utils.set_sticky_status_message(obj, message)
Exemplo n.º 3
0
def object_removed_event(obj, evt):
    """ """
    request = getattr(obj, 'REQUEST', None)
    if not request:
        return
    if not IStickyStatusMessagesLayer.providedBy(request):
        return

    folder = obj.aq_parent
    folder_title = folder.Title() or ''
    obj_title = obj.Title() or ''
    message = _(
                u'%s <em>%s</em> removed from <a href="%s">%s</a>' \
                                        % ( obj.portal_type,
                                            safe_unicode(obj_title),
                                            '/'.join(folder.getPhysicalPath()),
                                             safe_unicode(folder_title),
                                            )
                )
    utils.set_sticky_status_message(obj, message)
Exemplo n.º 4
0
def object_parent_edited_event(obj, evt):
    """ Notify children when the parent is edited
    """
    request = getattr(obj, 'REQUEST', None)
    if not request:
        return
    if not IStickyStatusMessagesLayer.providedBy(request):
        return

    folder = obj.aq_parent
    folder_title = folder.Title() or ''
    obj_title = obj.Title() or ''
    message = _(
                u'%s <a href="%s">%s</a> edited in <a href="%s">%s</a>' \
                                    % ( obj.portal_type,
                                        '/'.join(obj.getPhysicalPath()),
                                        safe_unicode(obj_title),
                                        '/'.join(folder.getPhysicalPath()),
                                        safe_unicode(folder_title),
                                        )
                )
    for child in obj.objectIds():
        utils.set_sticky_status_message(obj[child], message)