Ticket #15829: sitemaps-item.3.diff

File sitemaps-item.3.diff, 2.5 KB (added by Michael Manfre, 14 years ago)

Patch with added test

  • django/contrib/sitemaps/__init__.py

    diff -r 25c7466925f7 django/contrib/sitemaps/__init__.py
    a b  
    7979                'location':   loc,
    8080                'lastmod':    self.__get('lastmod', item, None),
    8181                'changefreq': self.__get('changefreq', item, None),
    82                 'priority':   str(priority is not None and priority or '')
     82                'priority':   str(priority is not None and priority or ''),
     83                'item':       item,
    8384            }
    8485            urls.append(url_info)
    8586        return urls
  • django/contrib/sitemaps/tests/basic.py

    diff -r 25c7466925f7 django/contrib/sitemaps/tests/basic.py
    a b  
    22from datetime import date
    33from django.conf import settings
    44from django.contrib.auth.models import User
    5 from django.contrib.sitemaps import Sitemap
     5from django.contrib.sitemaps import Sitemap, GenericSitemap
    66from django.contrib.sites.models import Site
    77from django.core.exceptions import ImproperlyConfigured
    88from django.test import TestCase
     
    171171        """
    172172        Site._meta.installed = False
    173173        self.assertRaises(ImproperlyConfigured, Sitemap().get_urls)
     174
     175    def test_sitemap_item(self):
     176        """
     177        Check to make sure that the raw item is included with each
     178        Sitemap.get_url() url result.
     179        """
     180        user_sitemap = GenericSitemap({
     181          'queryset': User.objects.all()
     182        })
     183       
     184        item_in_url_info = all(map(
     185            lambda url: isinstance(url['item'], User),
     186            user_sitemap.get_urls()
     187        ))
     188
     189        self.assertTrue(item_in_url_info)
     190       
     191 No newline at end of file
  • docs/ref/contrib/sitemaps.txt

    diff -r 25c7466925f7 docs/ref/contrib/sitemaps.txt
    a b  
    313313        }),
    314314    )
    315315
     316Index
     317-----
     318
     319The variable `sitemaps` is a list of absolute URLs to each of the sitemaps.
     320
     321Sitemap
     322-------
     323
     324The variable `urlset` is a list of each URLs that should appear in the sitemap. Each URL exposes `changefreq`, `item`, `lastmod`, `location` and `priority`.
     325
     326.. versionadded:: SVN
     327
     328The `item` object has been added for each URL to allow for more flexible customization.
     329
    316330Pinging Google
    317331==============
    318332
Back to Top