Пример #1
0
class ZNavigatorTreeEditedPostsNode(ZNavigatorTreeSubNode):
    def __init__(self):
        ZNavigatorTreeSubNode.__init__(self, NODE_TYPE_DRAFTED)
        self.filter = ZDocumentSearchFilter()
        self.postsCount = -1

    # end __init__()

    def getPostsCount(self):
        if self.postsCount == -1:
            self._configureFilter()
            self.postsCount = self._getPostsCount()
        return self.postsCount

    # end getPostsCount()

    def _configureFilter(self):
        self.filter.setAccountIdCriteria(
            IZDocumentSearchFilter.UNPUBLISHED_ACCOUNT_ID)
        if self.parentBlog:
            self.filter.setBlogIdCriteria(
                IZDocumentSearchFilter.UNPUBLISHED_POSTS)
        self.filter.setBlogIdCriteria(True)

    # end _configureFilter()

    def _getPostsCount(self):
        docIndex = getApplicationModel().getEngine().getService(
            IZBlogAppServiceIDs.DOCUMENT_INDEX_SERVICE_ID)
        return docIndex.getDocumentCount(self.filter)

    # end _getPostsCount()

    def getSearchFilter(self):
        return self.filter

    # end getSearchFilter()

    def getLabel(self):
        label = ZNavigatorTreeSubNode.getLabel(self)
        return u"%s (%d)" % (label, self.getPostsCount())  #$NON-NLS-1$

    # end getLabel()

    def addDocumentIDO(self, documentIDO):
        if self.postsCount != -1 and self.filter.matches(documentIDO):
            self.postsCount = self.postsCount + 1
            return True
        return False

    # end addDocumentIDO()

    def removeDocumentIDO(self, documentIDO):
        if self.postsCount != -1 and self.filter.matches(documentIDO):
            self.postsCount = self.postsCount - 1
            return True
        return False
Пример #2
0
class ZNavigatorTreeEditedPostsNode(ZNavigatorTreeSubNode):

    def __init__(self):
        ZNavigatorTreeSubNode.__init__(self, NODE_TYPE_DRAFTED)
        self.filter = ZDocumentSearchFilter()
        self.postsCount = -1
    # end __init__()

    def getPostsCount(self):
        if self.postsCount == -1:
            self._configureFilter()
            self.postsCount = self._getPostsCount()
        return self.postsCount
    # end getPostsCount()

    def _configureFilter(self):
        self.filter.setAccountIdCriteria(IZDocumentSearchFilter.UNPUBLISHED_ACCOUNT_ID)
        if self.parentBlog:
        	self.filter.setBlogIdCriteria(IZDocumentSearchFilter.UNPUBLISHED_POSTS)
        self.filter.setBlogIdCriteria(True)
    # end _configureFilter()

    def _getPostsCount(self):
        docIndex = getApplicationModel().getEngine().getService(IZBlogAppServiceIDs.DOCUMENT_INDEX_SERVICE_ID)
        return docIndex.getDocumentCount(self.filter)
    # end _getPostsCount()

    def getSearchFilter(self):
        return self.filter
    # end getSearchFilter()

    def getLabel(self):
        label = ZNavigatorTreeSubNode.getLabel(self)
        return u"%s (%d)" % (label, self.getPostsCount()) #$NON-NLS-1$
    # end getLabel()

    def addDocumentIDO(self, documentIDO):
        if self.postsCount != -1 and self.filter.matches(documentIDO):
            self.postsCount = self.postsCount + 1
            return True
        return False
    # end addDocumentIDO()

    def removeDocumentIDO(self, documentIDO):
        if self.postsCount != -1 and self.filter.matches(documentIDO):
            self.postsCount = self.postsCount - 1
            return True
        return False