예제 #1
0
파일: migr.py 프로젝트: philn/alinea
def migrateSections(sections):

    for section in sections:
        parent = section.parent
        if not parent:
            newParent = rootSection
        else:
            newParent = AlineaSection.select(AlineaSection.q.publicID == parent.id)[0]

        newSection = AlineaSection(name=section.name)
        rgt = AlineaNode.openHole(newParent)
        newSection.set(lft=rgt, rgt=rgt + 1)
        newSection.publicID = section.id
        AlineaNode.clearCache()

        print "%s - %s" % (newSection.publicID, newSection.name)

        # Articles of section
        for article in section.alineaArticles:
            print "   - %s : %s" % (article.id, article.title)

            newArticle = AlineaArticle(
                title=article.title,
                data=article.data,
                format=article.format,
                date=article.date,
                lastModified=article.date,
                hits=0,
                published=article.published,
                html=article.html,
                alineaUser=article.alineaUser,
            )
            rgt = AlineaNode.openHole(newSection)
            newArticle.set(lft=rgt, rgt=rgt + 1, publicID=article.id)
            AlineaNode.clearCache()
            assert newArticle.publicID == article.id

            # Comments of the article
            for comment in article.comments:
                newComment = AlineaComment(
                    author=comment.author,
                    email=comment.email,
                    url=comment.url,
                    ip=comment.ip,
                    comment=comment.comment,
                    date=comment.date,
                )

                rgt = AlineaNode.openHole(newArticle)
                newComment.set(lft=rgt, rgt=rgt + 1, publicID=comment.id)
                AlineaNode.clearCache()
                print "      - %s | %s" % (newComment.publicID, newComment.comment[:20])
예제 #2
0
파일: Comments.py 프로젝트: philn/alinea
 def getComments(self):
     """ Return the list of articles """
     begin = self.getBegin()
     end = begin + self.getRange()
     orderBy = self.getOrderBy()
     reverse = self.getReverse()
     comments = list(AlineaComment.select("all", orderBy=AlineaComment.q.date, reversed=reverse)[begin:end])
     return comments
예제 #3
0
파일: Comments.py 프로젝트: philn/alinea
    def delete(self, request):
        comments = self.requestValue("comments")

        if comments is None:
            comments = []
        elif type(comments) != type([]):
            comments = [comments]

        deleted = [AlineaComment.delete(int(commentID)) for commentID in comments]
        self.setMessage("Deleted %d comments" % len(deleted))
        begin = self.getBegin()
        return self.redirect(request)
예제 #4
0
파일: install.py 프로젝트: philn/alinea
def setup(connection=None):
    if connection:
        AlineaComment._connection = connection
    AlineaComment.dropTable(ifExists=True)
    AlineaComment.createTable()
예제 #5
0
파일: Comments.py 프로젝트: philn/alinea
 def getAllComments(self):
     return list(AlineaComment.select("all", orderBy="id"))
예제 #6
0
파일: Comments.py 프로젝트: philn/alinea
 def getSize(self):
     query = AlineaComment.select()
     size = query.count()
     return size
예제 #7
0
파일: Atom.py 프로젝트: philn/alinea
 def getComments(self, orderBy=AlineaComment.q.date):
     " return the last 10 comments "
     comments = list(AlineaComment.select("all", orderBy=orderBy, reversed=True)[0:10])
     return comments
예제 #8
0
파일: RSS2.py 프로젝트: philn/alinea
 def getComments(self, orderBy='date'):
     " return the last 10 comments "
     comments = list(AlineaComment.select('all',orderBy=orderBy, reversed=True)[0:10] )
     return comments
예제 #9
0
파일: Search.py 프로젝트: philn/alinea
    def getMatchedComments(self):
        from Alinea.Comments.AlineaComment import AlineaComment

        return AlineaComment.search(self.getQuery())