當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。