示例#1
0
文件: views.py 项目: strafrecht/app
def old_create_wiki(wiki):
    tags = wiki['tags']
    admin = User.objects.first()
    root = Article.objects.first().urlpath_set.first()

    slug_list = deque(wiki["root"].split("/")[1:])
    parent = traverse_ancestors(root, slug_list)

    # create Article
    article = Article(owner=admin, )
    article.save()

    # create URLPath
    urlpath = URLPath(parent=parent,
                      article=article,
                      slug=wiki['slug'],
                      site_id=1)
    urlpath.save()

    # add URLPath to Article
    article.urlpath_set.add(urlpath)

    article_revision = ArticleRevision(
        article=article,
        title=wiki['name'],
        #long_name=wiki['long_name'],
        content=wiki['content'],
        revision_number=1)

    # save wiki
    article_revision.save()
示例#2
0
    def test_articlerevision_presave_signals(self):
        a = Article.objects.create()
        ar1 = ArticleRevision(article=a, title="revision1")

        a.add_revision(ar1)
        self.assertEqual(ar1, a.current_revision)

        ar2 = ArticleRevision(article=a, title="revision2")

        ar2.save()

        self.assertEqual(ar2.previous_revision, ar1)