Esempio n. 1
0
File: migr.py Progetto: 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])
Esempio n. 2
0
 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
Esempio n. 3
0
    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)
Esempio n. 4
0
def setup(connection=None):
    if connection:
        AlineaComment._connection = connection
    AlineaComment.dropTable(ifExists=True)
    AlineaComment.createTable()
Esempio n. 5
0
 def getAllComments(self):
     return list(AlineaComment.select("all", orderBy="id"))
Esempio n. 6
0
 def getSize(self):
     query = AlineaComment.select()
     size = query.count()
     return size
Esempio n. 7
0
File: Atom.py Progetto: 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
Esempio n. 8
0
File: RSS2.py Progetto: 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
Esempio n. 9
0
    def getMatchedComments(self):
        from Alinea.Comments.AlineaComment import AlineaComment

        return AlineaComment.search(self.getQuery())