Beispiel #1
0
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()
Beispiel #2
0
    def test_manager(self):

        article = Article()
        article.add_revision(ArticleRevision(title="Root",
                                             content="Hello\nworld"),
                             save=True)
        self.assertEqual("Hello\r\nworld", article.current_revision.content)
Beispiel #3
0
    def create_bot_wiki_article(self):
        article_kwargs = {'owner': self.user,
                          'group': None,
                          'group_read': True,
                          'group_write': False,
                          'other_read': True,
                          'other_write': False}
        article = Article(**article_kwargs)
        article.add_revision(ArticleRevision(title=self.name), save=True)
        article.save()

        self.wiki_article = article
Beispiel #4
0
    def __create_redirect_page(self):
        # Verify we're changing more than case
        if self.kwargs['namespace'].lower() == self.object.namespace.lower():
            if self.kwargs['slug'].lower() == self.object.slug.lower():
                return

        redirect = Article(
            title=self.object.title,
            is_published=self.object.is_published,
            is_nsfw=self.object.is_nsfw,
            is_spoiler=self.object.is_spoiler,
            **self.kwargs,
        )
        redirect.markdown = '[[REDIRECT:/{article}]]'.format(
            article=utils.join_path(self.object.namespace, self.object.slug), )
        redirect.save()