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


Python RichTextPage.save方法代码示例

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


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

示例1: update_cms_page

# 需要导入模块: from mezzanine.pages.models import RichTextPage [as 别名]
# 或者: from mezzanine.pages.models.RichTextPage import save [as 别名]
 def update_cms_page(self, title=None, content='', parent_title=None, draft=False):
     if not title:
         title = 'Untitled'
     
     from mezzanine.pages.models import Page, RichTextPage
     
     page = get_cms_page_from_title(title)
     
     in_menus = [2,3]
     
     # create the page
     from mezzanine.core.models import CONTENT_STATUS_PUBLISHED, CONTENT_STATUS_DRAFT
     
     if not page:
         parent_page = get_cms_page_from_title(parent_title)
         page = RichTextPage(title=title, content_model='richtextpage', parent=parent_page, content=content, status=CONTENT_STATUS_PUBLISHED)
         page.save()
         page.status = CONTENT_STATUS_DRAFT if draft else CONTENT_STATUS_PUBLISHED
         page.in_menus = in_menus
     else:
         # Can't find an easy way to edit page.richtextpage.content, so let's write directly to the DB!
         from django.db import connection
         cursor = connection.cursor()
         cursor.execute('''update pages_richtextpage set content = %s where page_ptr_id = %s''', [content, page.id])
         
     page.save()
     
     return page
开发者ID:MCadeStewart,项目名称:digipal,代码行数:30,代码来源:dpdoc.py

示例2: test_copy_default_minimal

# 需要导入模块: from mezzanine.pages.models import RichTextPage [as 别名]
# 或者: from mezzanine.pages.models.RichTextPage import save [as 别名]
 def test_copy_default_minimal(self):
     """Copy all CMS models from the default site (minimal example)."""
     # This will be created with the default site
     # TODO: .create fails somehow related to django-concurrency
     page = RichTextPage(title='Learn', content='<h1>Title</h1>')
     page.save()
     site = Site.objects.create(name='zh-cn', domain='example.com')
     utils.build_site_content(site)
     self.assertCopied(page, site)
开发者ID:Osmose,项目名称:fxoss,代码行数:11,代码来源:test_utils.py

示例3: test_copy_multiple_models

# 需要导入模块: from mezzanine.pages.models import RichTextPage [as 别名]
# 或者: from mezzanine.pages.models.RichTextPage import save [as 别名]
 def test_copy_multiple_models(self):
     """CMS Pages, RichTextPage, Links should all be copied."""
     # TODO: .create fails somehow related to django-concurrency
     page = RichTextPage(title='Learn', content='<h1>Title</h1>')
     page.save()
     link = Link.objects.create(title='External Link')
     site = Site.objects.create(name='zh-cn', domain='example.com')
     utils.build_site_content(site)
     self.assertCopied(page, site)
     self.assertCopied(link, site)
开发者ID:Osmose,项目名称:fxoss,代码行数:12,代码来源:test_utils.py

示例4: test_nested_pages

# 需要导入模块: from mezzanine.pages.models import RichTextPage [as 别名]
# 或者: from mezzanine.pages.models.RichTextPage import save [as 别名]
 def test_nested_pages(self):
     """Page hierarchy should be preserved on copy."""
     # TODO: .create fails somehow related to django-concurrency
     page = RichTextPage(title='Learn', content='<h1>Title</h1>')
     page.save()
     subpage = RichTextPage(title='Sub Learn', content='<h1>Title</h1>', parent=page)
     subpage.save()
     site = Site.objects.create(name='zh-cn', domain='example.com')
     utils.build_site_content(site)
     self.assertCopied(page, site)
     self.assertCopied(subpage, site)
     copy = QuerySet(RichTextPage).get(slug=page.slug, site=site)
     subcopy = QuerySet(RichTextPage).get(slug=subpage.slug, site=site)
     self.assertEqual(subcopy.parent_id, copy.pk)
开发者ID:Osmose,项目名称:fxoss,代码行数:16,代码来源:test_utils.py

示例5: test_nested_forms_links

# 需要导入模块: from mezzanine.pages.models import RichTextPage [as 别名]
# 或者: from mezzanine.pages.models.RichTextPage import save [as 别名]
 def test_nested_forms_links(self):
     """Page hierarchy for forms and links should be preserved on copy."""
     # TODO: .create fails somehow related to django-concurrency
     page = RichTextPage(title='Learn', content='<h1>Title</h1>')
     page.save()
     form = Form(title='Contact Us', parent=page)
     form.save()
     link = Link(title='Foo', parent=page)
     link.save()
     site = Site.objects.create(name='zh-cn', domain='example.com')
     utils.build_site_content(site)
     self.assertCopied(page, site)
     self.assertCopied(form, site)
     self.assertCopied(link, site)
     copy = QuerySet(RichTextPage).get(slug=page.slug, site=site)
     formcopy = QuerySet(Form).get(slug=form.slug, site=site)
     linkcopy = QuerySet(Link).get(slug=link.slug, site=site)
     self.assertEqual(formcopy.parent_id, copy.pk)
     self.assertEqual(linkcopy.parent_id, copy.pk)
开发者ID:Osmose,项目名称:fxoss,代码行数:21,代码来源:test_utils.py

示例6: test_update_site

# 需要导入模块: from mezzanine.pages.models import RichTextPage [as 别名]
# 或者: from mezzanine.pages.models.RichTextPage import save [as 别名]
    def test_update_site(self):
        from django.conf import settings
        from mezzanine.utils.sites import current_site_id

        # setup
        try:
            old_site_id = settings.SITE_ID
        except:
            old_site_id = None

        site1 = Site.objects.create(domain="site1.com")
        site2 = Site.objects.create(domain="site2.com")

        # default behaviour, page gets assigned current site
        settings.SITE_ID = site2.pk
        self.assertEqual(settings.SITE_ID, current_site_id())
        page = RichTextPage()
        page.save()
        self.assertEqual(page.site_id, site2.pk)

        # Subsequent saves do not update site to current site
        page.site = site1
        page.save()
        self.assertEqual(page.site_id, site1.pk)

        # resave w/ update_site=True, page gets assigned current site
        settings.SITE_ID = site1.pk
        page.site = site2
        page.save(update_site=True)
        self.assertEqual(page.site_id, site1.pk)

        # resave w/ update_site=False, page does not update site
        settings.SITE_ID = site2.pk
        page.save(update_site=False)
        self.assertEqual(page.site_id, site1.pk)

        # When update_site=True, new page gets assigned current site
        settings.SITE_ID = site2.pk
        page = RichTextPage()
        page.site = site1
        page.save(update_site=True)
        self.assertEqual(page.site_id, site2.pk)

        # When update_site=False, new page keeps current site
        settings.SITE_ID = site2.pk
        page = RichTextPage()
        page.site = site1
        page.save(update_site=False)
        self.assertEqual(page.site_id, site1.pk)

        # When site explicitly assigned, new page keeps assigned site
        settings.SITE_ID = site2.pk
        page = RichTextPage()
        page.site = site1
        page.save()
        self.assertEqual(page.site_id, site1.pk)

        # tear down
        if old_site_id:
            settings.SITE_ID = old_site_id
        else:
            del settings.SITE_ID

        site1.delete()
        site2.delete()
开发者ID:tiktuk,项目名称:mezzanine,代码行数:67,代码来源:tests.py


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