Ticket #9800: rss-guid_is_permalink-attribute.diff

File rss-guid_is_permalink-attribute.diff, 2.2 KB (added by andreiko, 5 years ago)

my version of patch

  • django/utils/feedgenerator.py

     
    7171    "Base class for all syndication feeds. Subclasses should provide write()"
    7272    def __init__(self, title, link, description, language=None, author_email=None,
    7373            author_name=None, author_link=None, subtitle=None, categories=None,
    74             feed_url=None, feed_copyright=None, feed_guid=None, ttl=None, **kwargs):
     74            feed_url=None, feed_copyright=None, feed_guid=None, ttl=None, guid_is_permalink=None, **kwargs):
    7575        to_unicode = lambda s: force_unicode(s, strings_only=True)
    7676        if categories:
    7777            categories = [force_unicode(c) for c in categories]
     
    9292            'feed_copyright': to_unicode(feed_copyright),
    9393            'id': feed_guid or link,
    9494            'ttl': ttl,
     95            'guid_is_permalink': guid_is_permalink,
    9596        }
    9697        self.feed.update(kwargs)
    9798        self.items = []
     
    264265        if item['comments'] is not None:
    265266            handler.addQuickElement(u"comments", item['comments'])
    266267        if item['unique_id'] is not None:
    267             handler.addQuickElement(u"guid", item['unique_id'])
     268            guid_attrs = {}
     269            if isinstance(self.feed['guid_is_permalink'], bool):
     270                guid_attrs['isPermalink'] = str(self.feed['guid_is_permalink']).lower()
     271            handler.addQuickElement(u"guid", item['unique_id'], guid_attrs)
    268272        if item['ttl'] is not None:
    269273            handler.addQuickElement(u"ttl", item['ttl'])
    270274
  • django/contrib/syndication/views.py

     
    118118            feed_copyright = self.__get_dynamic_attr('feed_copyright', obj),
    119119            feed_guid = self.__get_dynamic_attr('feed_guid', obj),
    120120            ttl = self.__get_dynamic_attr('ttl', obj),
     121            guid_is_permalink = self.__get_dynamic_attr('guid_is_permalink', obj),
    121122            **self.feed_extra_kwargs(obj)
    122123        )
    123124
Back to Top