コード例 #1
0
    def __call__(self):
        paths = self.request.get('paths')
        if paths:
            for item in paths:
                obj = self.context.restrictedTraverse(item)
                if not api.user.has_permission(
                        'opengever.trash: Untrash content', obj=obj):
                    msg = _(u'Untrashing ${title} is forbidden',
                            mapping={'title': obj.Title().decode('utf-8')})
                    IStatusMessage(self.request).addStatusMessage(msg,
                                                                  type='error')
                    continue

                trasher = ITrashable(obj)
                trasher.untrash()

            return self.request.RESPONSE.redirect(
                '%s#documents' % (self.context.absolute_url()))

        else:
            msg = _(u'You have not selected any items.')
            IStatusMessage(self.request).addStatusMessage(msg, type='error')

            return self.request.RESPONSE.redirect('%s#trash' %
                                                  self.context.absolute_url())
コード例 #2
0
    def reply(self):

        # Disable CSRF protection
        alsoProvides(self.request,
                     plone.protect.interfaces.IDisableCSRFProtection)

        trasher = ITrashable(self.context)
        trasher.untrash()

        self.request.response.setStatus(204)
        return super(Untrash, self).reply()
コード例 #3
0
ファイル: trash.py プロジェクト: 4teamwork/opengever.core
    def reply(self):

        # Disable CSRF protection
        alsoProvides(self.request,
                     plone.protect.interfaces.IDisableCSRFProtection)

        trasher = ITrashable(self.context)
        trasher.untrash()

        self.request.response.setStatus(204)
        return super(Untrash, self).reply()
コード例 #4
0
ファイル: trash.py プロジェクト: lukasgraf/opengever.core
    def __call__(self):
        paths = self.request.get('paths')
        if paths:
            for item in paths:
                obj = self.context.restrictedTraverse(item)
                trasher = ITrashable(obj)
                try:
                    trasher.untrash()
                except Unauthorized:
                    msg = _(u'Untrashing ${title} is forbidden',
                            mapping={'title': obj.Title().decode('utf-8')})
                    IStatusMessage(self.request).addStatusMessage(msg,
                                                                  type='error')

            return self.request.RESPONSE.redirect(
                '%s#documents' % (self.context.absolute_url()))

        else:
            msg = _(u'You have not selected any items.')
            IStatusMessage(self.request).addStatusMessage(msg, type='error')

            return self.request.RESPONSE.redirect('%s#trash' %
                                                  self.context.absolute_url())
コード例 #5
0
ファイル: trash.py プロジェクト: 4teamwork/opengever.core
    def __call__(self):
        paths = self.request.get('paths')
        if paths:
            for item in paths:
                obj = self.context.restrictedTraverse(item)
                trasher = ITrashable(obj)
                try:
                    trasher.untrash()
                except Unauthorized:
                    msg = _(u'Untrashing ${title} is forbidden',
                            mapping={'title': obj.Title().decode('utf-8')})
                    IStatusMessage(self.request).addStatusMessage(
                        msg, type='error')

            return self.request.RESPONSE.redirect('%s#documents' % (
                self.context.absolute_url()))

        else:
            msg = _(u'You have not selected any items.')
            IStatusMessage(self.request).addStatusMessage(
                msg, type='error')

            return self.request.RESPONSE.redirect(
                '%s#trash' % self.context.absolute_url())