当前位置: 首页>>代码示例>>Python>>正文


Python URLPath.root方法代码示例

本文整理汇总了Python中wiki.models.URLPath.root方法的典型用法代码示例。如果您正苦于以下问题:Python URLPath.root方法的具体用法?Python URLPath.root怎么用?Python URLPath.root使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wiki.models.URLPath的用法示例。


在下文中一共展示了URLPath.root方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_edit_save

# 需要导入模块: from wiki.models import URLPath [as 别名]
# 或者: from wiki.models.URLPath import root [as 别名]
 def test_edit_save(self):
     old_revision = URLPath.root().article.current_revision
     self.get_url('wiki:edit', path='')
     self.fill({
         '#id_content': 'Something 2',
         '#id_summary': 'why edited',
         '#id_title': 'wiki test'
     })
     self.submit('#id_save')
     self.assertTextPresent('Something 2')
     self.assertTextPresent('successfully added')
     new_revision = URLPath.root().article.current_revision
     self.assertIn('Something 2', new_revision.content)
     self.assertEqual(new_revision.revision_number, old_revision.revision_number + 1)
开发者ID:django-wiki,项目名称:django-wiki,代码行数:16,代码来源:test_views.py

示例2: test_revision_conflict

# 需要导入模块: from wiki.models import URLPath [as 别名]
# 或者: from wiki.models.URLPath import root [as 别名]
    def test_revision_conflict(self):
        """
        Test the warning if the same article is being edited concurrently.
        """

        example_data = {
            'content': 'More modifications',
            'current_revision': str(URLPath.root().article.current_revision.id),
            'preview': '0',
            'save': '1',
            'summary': 'why edited',
            'title': 'wiki test'
        }

        response = self.client.post(
            resolve_url('wiki:edit', path=''),
            example_data
        )

        self.assertRedirects(response, resolve_url('wiki:root'))

        response = self.client.post(
            resolve_url('wiki:edit', path=''),
            example_data
        )

        self.assertContains(
            response,
            'While you were editing, someone else changed the revision.'
        )
开发者ID:django-wiki,项目名称:django-wiki,代码行数:32,代码来源:test_views.py

示例3: get_or_create_root

# 需要导入模块: from wiki.models import URLPath [as 别名]
# 或者: from wiki.models.URLPath import root [as 别名]
def get_or_create_root():
    """
    Returns the root article, or creates it if it doesn't exist.
    """
    try:
        root = URLPath.root()
        if not root.article:
            root.delete()
            raise NoRootURL
        return root
    except NoRootURL:
        pass

    starting_content = "\n".join((
    "Welcome to the edX Wiki",
    "===",
    "Visit a course wiki to add an article."))

    root = URLPath.create_root(title="Wiki",
                        content=starting_content)
    article = root.article
    article.group = None
    article.group_read = True
    article.group_write = False
    article.other_read = True
    article.other_write = False
    article.save()

    return root
开发者ID:pelikanchik,项目名称:edx-platform,代码行数:31,代码来源:views.py

示例4: get_or_create_root

# 需要导入模块: from wiki.models import URLPath [as 别名]
# 或者: from wiki.models.URLPath import root [as 别名]
def get_or_create_root():
    """
    Returns the root article, or creates it if it doesn't exist.
    """
    try:
        root = URLPath.root()
        if not root.article:
            root.delete()
            raise NoRootURL
        return root
    except NoRootURL:
        pass

    starting_content = "\n".join((
        _("Welcome to the {platform_name} Wiki").format(platform_name=get_themed_value('PLATFORM_NAME',
                                                                                       settings.PLATFORM_NAME)),
        "===",
        _("Visit a course wiki to add an article."),
    ))

    root = URLPath.create_root(title=_("Wiki"), content=starting_content)
    article = root.article
    article.group = None
    article.group_read = True
    article.group_write = False
    article.other_read = True
    article.other_write = False
    article.save()

    return root
开发者ID:AndreySonetico,项目名称:edx-platform,代码行数:32,代码来源:views.py

示例5: setUp

# 需要导入模块: from wiki.models import URLPath [as 别名]
# 或者: from wiki.models.URLPath import root [as 别名]
 def setUp(self):
     super(RequireRootArticleMixin, self).setUp()
     self.root = URLPath.create_root()
     self.root_article = URLPath.root().article
     rev = self.root_article.current_revision
     rev.title = "Root Article"
     rev.content = "root article content"
     rev.save()
开发者ID:Arken94,项目名称:django-wiki,代码行数:10,代码来源:base.py

示例6: get_article

# 需要导入模块: from wiki.models import URLPath [as 别名]
# 或者: from wiki.models.URLPath import root [as 别名]
 def get_article(self, cont):
     urlpath = URLPath.create_urlpath(
         URLPath.root(),
         "html_attach",
         title="TestAttach",
         content=cont
     )
     self._create_test_attachment(urlpath.path)
     return urlpath.article.render()
开发者ID:azaghal,项目名称:django-wiki,代码行数:11,代码来源:test_views.py

示例7: get_article

# 需要导入模块: from wiki.models import URLPath [as 别名]
# 或者: from wiki.models.URLPath import root [as 别名]
 def get_article(self, cont, image):
     urlpath = URLPath.create_urlpath(
         URLPath.root(),
         "html_image",
         title="TestImage",
         content=cont
     )
     if image:
         self._create_test_image(urlpath.path)
     return urlpath.article.render()
开发者ID:Arken94,项目名称:django-wiki,代码行数:12,代码来源:test_views.py

示例8: test_preview_and_save

# 需要导入模块: from wiki.models import URLPath [as 别名]
# 或者: from wiki.models.URLPath import root [as 别名]
 def test_preview_and_save(self):
     self.get_url('wiki:edit', path='')
     self.fill({
         '#id_content': 'Some changed stuff',
         '#id_summary': 'why edited',
         '#id_title': 'wiki test'
     })
     self.click('#id_preview')
     self.submit('#id_preview_save_changes')
     new_revision = URLPath.root().article.current_revision
     self.assertIn("Some changed stuff", new_revision.content)
开发者ID:django-wiki,项目名称:django-wiki,代码行数:13,代码来源:test_views.py

示例9: test_history

# 需要导入模块: from wiki.models import URLPath [as 别名]
# 或者: from wiki.models.URLPath import root [as 别名]
    def test_history(self):
        url = reverse('wiki:globalhistory')

        response = self.c.get(url)
        expected = (
            '(?s)<title>Global history.*'
            '>Global history</.*'
            'List of all <strong>1 changes</strong>.*'
            'Root Article.*no log message.*'
            '</table>'
        )
        self._assertRegex(response.rendered_content, expected)

        URLPath.create_article(URLPath.root(), "testhistory1",
                               title="TestHistory1", content="a page",
                               user_message="Comment 1")
        response = self.c.get(url)
        expected = (
            '(?s)<title>Global history.*'
            '>Global history</.*'
            'List of all <strong>2 changes</strong>.*'
            'TestHistory1.*Comment 1.*'
            'Root Article.*no log message.*'
            '</table>'
        )
        self._assertRegex(response.rendered_content, expected)

        URLPath.create_article(URLPath.root(), "testhistory2",
                               title="TestHistory2", content="a page",
                               user_message="Comment 2")
        response = self.c.get(url)
        expected = (
            '(?s)<title>Global history.*'
            '>Global history</.*'
            'List of all <strong>3 changes</strong>.*'
            'TestHistory2.*Comment 2.*'
            'TestHistory1.*Comment 1.*'
            'Root Article.*no log message.*'
            '</table>'
        )
        self._assertRegex(response.rendered_content, expected)
开发者ID:jandebleser,项目名称:django-wiki,代码行数:43,代码来源:test_globalhistory.py

示例10: setUp

# 需要导入模块: from wiki.models import URLPath [as 别名]
# 或者: from wiki.models.URLPath import root [as 别名]
    def setUp(self):

        super(ArticleWebTestBase, self).setUp()

        response = self.c.post(
            reverse('wiki:root_create'),
            {'content': 'root article content', 'title': 'Root Article'},
            follow=True
        )

        self.assertEqual(response.status_code, 200)  # sanity check
        self.root_article = URLPath.root().article
开发者ID:Omosofe,项目名称:django-wiki,代码行数:14,代码来源:base.py

示例11: setUp

# 需要导入模块: from wiki.models import URLPath [as 别名]
# 或者: from wiki.models.URLPath import root [as 别名]
 def setUp(self):
     super(ArticleTestBase, self).setUp()
     response = self.c.post(
         reverse('wiki:root_create'),
         {'content': 'root article content', 'title': 'Root Article'},
         follow=True)
     self.assertEqual(response.status_code, 200)  # sanity check
     self.root_article = URLPath.root().article
     self.example_data = {
         'content': 'The modified text',
         'current_revision': '1',
         'preview': '1',
         # 'save': '1',  # probably not too important
         'summary': 'why edited',
         'title': 'wiki test'}
开发者ID:DavideyLee,项目名称:django-wiki,代码行数:17,代码来源:base.py

示例12: test_article_list_update

# 需要导入模块: from wiki.models import URLPath [as 别名]
# 或者: from wiki.models.URLPath import root [as 别名]
    def test_article_list_update(self):
        """
        Test automatic adding and removing the new article to/from article_list.
        """

        root_data = {
            'content': '[article_list depth:2]',
            'current_revision': str(URLPath.root().article.current_revision.id),
            'preview': '1',
            'title': 'Root Article'
        }

        response = self.client.post(resolve_url('wiki:edit', path=''), root_data)
        self.assertRedirects(response, resolve_url('wiki:root'))

        # verify the new article is added to article_list
        response = self.client.post(
            resolve_url('wiki:create', path=''),
            {'title': 'Sub Article 1', 'slug': 'SubArticle1'}
        )

        self.assertRedirects(
            response,
            resolve_url('wiki:get', path='subarticle1/')
        )
        self.assertContains(self.get_by_path(''), 'Sub Article 1')
        self.assertContains(self.get_by_path(''), 'subarticle1/')

        # verify the deleted article is removed from article_list
        response = self.client.post(
            resolve_url('wiki:delete', path='SubArticle1/'),
            {'confirm': 'on',
             'purge': 'on',
             'revision': str(URLPath.objects.get(slug='subarticle1').article.current_revision.id),
             }
        )

        message = getattr(self.client.cookies['messages'], 'value')

        self.assertRedirects(
            response,
            resolve_url('wiki:get', path='')
        )
        self.assertIn(
            'This article together with all '
            'its contents are now completely gone',
            message)
        self.assertNotContains(self.get_by_path(''), 'Sub Article 1')
开发者ID:django-wiki,项目名称:django-wiki,代码行数:50,代码来源:test_views.py

示例13: test_root_article

# 需要导入模块: from wiki.models import URLPath [as 别名]
# 或者: from wiki.models.URLPath import root [as 别名]
 def test_root_article(self):
     """
     Test redirecting to /create-root/,
     creating the root article and a simple markup.
     """
     self.get_url('wiki:root')
     self.assertUrlsEqual(resolve_url('wiki:root_create'))
     self.fill({
         '#id_content': 'test heading h1\n====\n',
         '#id_title': 'Wiki Test',
     })
     self.submit('input[name="save_changes"]')
     self.assertUrlsEqual('/')
     self.assertTextPresent('test heading h1')
     article = URLPath.root().article
     self.assertIn('test heading h1', article.current_revision.content)
开发者ID:django-wiki,项目名称:django-wiki,代码行数:18,代码来源:test_views.py

示例14: test_preview_xframe_options_sameorigin

# 需要导入模块: from wiki.models import URLPath [as 别名]
# 或者: from wiki.models.URLPath import root [as 别名]
    def test_preview_xframe_options_sameorigin(self):
        """Ensure that preview response has X-Frame-Options: SAMEORIGIN"""

        example_data = {
            'content': 'The modified text',
            'current_revision': str(URLPath.root().article.current_revision.id),
            'preview': '1',
            'summary': 'why edited',
            'title': 'wiki test'
        }

        response = self.client.post(
            resolve_url('wiki:preview', path=''),
            example_data
        )

        self.assertEquals(response.get('X-Frame-Options'), 'SAMEORIGIN')
开发者ID:django-wiki,项目名称:django-wiki,代码行数:19,代码来源:test_views.py

示例15: wiki_articles_in_menu

# 需要导入模块: from wiki.models import URLPath [as 别名]
# 或者: from wiki.models.URLPath import root [as 别名]
def wiki_articles_in_menu(request):
    wiki_root = URLPath.root()

    urls = [wiki_root]
    for subroot in wiki_root.children.all():
        urls.append(subroot)

    items = []

    for url in urls:
        if url.article.can_read(request.user):
            items.append({
                'url_regex': r'^' + str(url) + ('$' if url.parent is None else ''),
                'text': url.article.current_revision.title,
                'link': url.article.get_absolute_url(),
            })

    return items
开发者ID:maaario,项目名称:testovac-front-end,代码行数:20,代码来源:menu_tags.py


注:本文中的wiki.models.URLPath.root方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。