Ticket #11358: 11358_with_test.patch
File 11358_with_test.patch, 3.7 KB (added by , 14 years ago) |
---|
-
django/contrib/sitemaps/tests/basic.py
1 1 from datetime import date 2 2 from django.conf import settings 3 3 from django.contrib.auth.models import User 4 from django.contrib.flatpages.models import FlatPage 4 5 from django.test import TestCase 5 6 from django.utils.formats import localize 6 7 from django.utils.translation import activate … … 51 52 <url><loc>http://example.com/users/testuser/</loc></url> 52 53 </urlset> 53 54 """) 55 56 def test_flatpage_sitemap(self): 57 "Basic FlatPage sitemap test" 58 public = FlatPage.objects.create( 59 url=u'/public/', 60 title=u'Public Page', 61 enable_comments=True, 62 registration_required=False, 63 ) 64 public.sites.add(settings.SITE_ID) 65 private = FlatPage.objects.create( 66 url=u'/private/', 67 title=u'Public Page', 68 enable_comments=True, 69 registration_required=True 70 ) 71 private.sites.add(settings.SITE_ID) 72 response = self.client.get('/flatpages/sitemap.xml') 73 # Public flatpage should be in the sitemap 74 self.assertContains(response, '<loc>http://example.com%s</loc>' % public.url) 75 # Private flatpage should not be in the sitemap 76 self.assertNotContains(response, '<loc>http://example.com%s</loc>' % private.url) 77 -
django/contrib/sitemaps/tests/urls.py
1 1 from datetime import datetime 2 2 from django.conf.urls.defaults import * 3 from django.contrib.sitemaps import Sitemap, GenericSitemap 3 from django.contrib.sitemaps import Sitemap, GenericSitemap, FlatPageSitemap 4 4 from django.contrib.auth.models import User 5 5 6 6 class SimpleSitemap(Sitemap): … … 22 22 }), 23 23 } 24 24 25 flatpage_sitemaps = { 26 'flatpages': FlatPageSitemap, 27 } 28 25 29 urlpatterns = patterns('django.contrib.sitemaps.views', 26 30 (r'^simple/sitemap\.xml$', 'sitemap', {'sitemaps': simple_sitemaps}), 27 31 (r'^generic/sitemap\.xml$', 'sitemap', {'sitemaps': generic_sitemaps}), 32 (r'^flatpages/sitemap\.xml$', 'sitemap', {'sitemaps': flatpage_sitemaps}), 28 33 ) -
django/contrib/sitemaps/__init__.py
79 79 def items(self): 80 80 from django.contrib.sites.models import Site 81 81 current_site = Site.objects.get_current() 82 return current_site.flatpage_set. all()82 return current_site.flatpage_set.filter(registration_required=False) 83 83 84 84 class GenericSitemap(Sitemap): 85 85 priority = None -
docs/ref/contrib/sitemaps.txt
215 215 .. class:: FlatPageSitemap 216 216 217 217 The :class:`django.contrib.sitemaps.FlatPageSitemap` class looks at all 218 :mod:`flatpages <django.contrib.flatpages>` defined for the current219 :setting:`SITE_ID` (see the218 publicly visible :mod:`flatpages <django.contrib.flatpages>` 219 defined for the current :setting:`SITE_ID` (see the 220 220 :mod:`sites documentation <django.contrib.sites>`) and 221 221 creates an entry in the sitemap. These entries include only the 222 222 :attr:`~Sitemap.location` attribute -- not :attr:`~Sitemap.lastmod`,