Exemplo n.º 1
0
    def update(self):
        if self.updated:
            return

        context = self.context
        request = self.request

        if 'form.buttons.apply' in request:
            self.environ['applyButton'] = True

        elif 'form.buttons.rename' in request:
            if not request.get("ids"):
                IStatusMessage(request).add(
                    _("You didn't specify any ids to rename."), 'warning')
            else:
                interface.alsoProvides(self, IRenameContainerContents)

        elif "form.buttons.delete" in request:
            self.removeObjects()

        elif "form.buttons.copy" in request:
            self.copyObjects()

        elif "form.buttons.cut" in request:
            self.cutObjects()

        elif "form.buttons.paste" in request:
            self.pasteObjects()

        elif "form.buttons.pasteLink" in request:
            self.pasteObjectLinks()

        order = IOrder(context, None)
        if order is not None and IReordable.providedBy(order):
            self.orderButtons = len(order) > 1

            changed = False
            selected = request.get('ids', [])

            if 'form.buttons.moveup' in request:
                changed = order.moveUp(selected)

            elif 'form.buttons.movetop' in request:
                changed = order.moveTop(selected)

            elif 'form.buttons.movedown' in request:
                changed = order.moveDown(selected)

            elif 'form.buttons.movebottom' in request:
                changed = order.moveBottom(selected)

            if changed:
                notifyContainerModified(context)
                IStatusMessage(request).add(
                    _(u'Items order have been changed.'))
        else:
            self.orderButtons = False

        super(ContainerContents, self).update()

        self.setupButtons()

        self.updated = True