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


Python sitemaps.CMSSitemap方法代码示例

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


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

示例1: test_sitemap_login_required_pages

# 需要导入模块: from cms import sitemaps [as 别名]
# 或者: from cms.sitemaps import CMSSitemap [as 别名]
def test_sitemap_login_required_pages(self):
        """
        Test that CMSSitemap object contains only published,public (login_required=False) pages
        """
        create_page("page", "nav_playground.html", "en", login_required=True,
                    published=True, in_navigation=True)
        self.assertEqual(CMSSitemap().items().count(), 0) 
开发者ID:farhan711,项目名称:DjangoCMS,代码行数:9,代码来源:test_page.py

示例2: test_sitemap_includes_last_modification_date

# 需要导入模块: from cms import sitemaps [as 别名]
# 或者: from cms.sitemaps import CMSSitemap [as 别名]
def test_sitemap_includes_last_modification_date(self):
        one_day_ago = tz_now() - datetime.timedelta(days=1)
        page = create_page("page", "nav_playground.html", "en", published=True, publication_date=one_day_ago)
        page.creation_date = one_day_ago
        page.save()
        page.publish('en')
        sitemap = CMSSitemap()
        self.assertEqual(sitemap.items().count(), 1)
        actual_last_modification_time = sitemap.lastmod(sitemap.items()[0])
        self.assertTrue(actual_last_modification_time > one_day_ago) 
开发者ID:farhan711,项目名称:DjangoCMS,代码行数:12,代码来源:test_page.py

示例3: test_sitemap_uses_publication_date_when_later_than_modification

# 需要导入模块: from cms import sitemaps [as 别名]
# 或者: from cms.sitemaps import CMSSitemap [as 别名]
def test_sitemap_uses_publication_date_when_later_than_modification(self):
        now = tz_now()
        now -= datetime.timedelta(microseconds=now.microsecond)
        one_day_ago = now - datetime.timedelta(days=1)
        page = create_page("page", "nav_playground.html", "en", published=True, publication_date=now)
        title = page.get_title_obj('en')
        page.creation_date = one_day_ago
        page.changed_date = one_day_ago
        sitemap = CMSSitemap()
        actual_last_modification_time = sitemap.lastmod(title)
        self.assertEqual(actual_last_modification_time.date(), now.date()) 
开发者ID:farhan711,项目名称:DjangoCMS,代码行数:13,代码来源:test_page.py

示例4: test_sitemap_count

# 需要导入模块: from cms import sitemaps [as 别名]
# 或者: from cms.sitemaps import CMSSitemap [as 别名]
def test_sitemap_count(self):
        """
        Has the sitemap the correct number of elements?
        """
        sitemap = CMSSitemap()
        # 8 pages with en and de titles published
        # 1 page published only in english(with existsing de title)
        # 1 page with both titles but unpublished
        # 1 page with only english title
        self.assertEqual(sitemap.items().count(), 18) 
开发者ID:farhan711,项目名称:DjangoCMS,代码行数:12,代码来源:test_sitemap.py

示例5: test_sitemap_items_location

# 需要导入模块: from cms import sitemaps [as 别名]
# 或者: from cms.sitemaps import CMSSitemap [as 别名]
def test_sitemap_items_location(self):
        """
        Check the correct URL in location, recreating it according to the title
        attributes (instead of using Page.get_absolute_url) for a lower level
        check
        """
        sitemap = CMSSitemap()
        urlset = sitemap.get_urls()
        for item in urlset:
            if item['item'].path:
                url = 'http://example.com/%s/%s/' % (item['item'].language, item['item'].path)
            else:
                url = 'http://example.com/%s/%s' % (item['item'].language, item['item'].path)
            self.assertEqual(item['location'], url) 
开发者ID:farhan711,项目名称:DjangoCMS,代码行数:16,代码来源:test_sitemap.py

示例6: test_sitemap_unpublished_titles

# 需要导入模块: from cms import sitemaps [as 别名]
# 或者: from cms.sitemaps import CMSSitemap [as 别名]
def test_sitemap_unpublished_titles(self):
        """
        Check that titles attached to unpublished pages are not in the urlset.
        As titles are 'published' depending on their attached page, we create a
        set of unpublished titles by checking titles attached to the draft and
        public version of each page
        """
        sitemap = CMSSitemap()
        locations = []
        urlset = sitemap.get_urls()
        unpublished_titles = set()
        for item in urlset:
            locations.append(item['location'])
        for page in Page.objects.drafts():
            if page.get_public_object():
                set1 = set(page.get_public_object().title_set.values_list('path', flat=True))
                set2 = set(page.title_set.values_list('path', flat=True))
                unpublished_titles.update(set2.difference(set1))
            else:
                unpublished_titles.update(page.title_set.values_list('path', flat=True))

        for path in unpublished_titles:
            title = Title.objects.get(path=path)
            if title.path:
                url = 'http://example.com/%s/%s/' % (title.language, title.path)
            else:
                url = 'http://example.com/%s/%s' % (title.language, title.path)
            self.assertFalse(url in locations) 
开发者ID:farhan711,项目名称:DjangoCMS,代码行数:30,代码来源:test_sitemap.py


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