<s> from django . conf import settings <EOL> from django . contrib . contenttypes . models import ContentType <EOL> from django . contrib . sitemaps import Sitemap <EOL> from fluent_blogs . models import get_entry_model , get_category_model <EOL> from fluent_blogs . urlresolvers import blog_reverse <EOL> from fluent_utils . django_compat import get_user_model <EOL> from parler . models import TranslatableModel <EOL> User = get_user_model ( ) <EOL> EntryModel = get_entry_model ( ) <EOL> CategoryModel = get_category_model ( ) <EOL> class EntrySitemap ( Sitemap ) : <EOL> """<STR_LIT>""" <EOL> def items ( self ) : <EOL> qs = EntryModel . objects . published ( ) . order_by ( '<STR_LIT>' ) <EOL> if issubclass ( EntryModel , TranslatableModel ) : <EOL> qs = qs . active_translations ( ) <EOL> return qs . order_by ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> else : <EOL> return qs . order_by ( '<STR_LIT>' ) <EOL> def lastmod ( self , urlnode ) : <EOL> """<STR_LIT>""" <EOL> return urlnode . modification_date <EOL> def location ( self , urlnode ) : <EOL> """<STR_LIT>""" <EOL> return urlnode . url <EOL> class CategoryArchiveSitemap ( Sitemap ) : <EOL> def items ( self ) : <EOL> only_ids = EntryModel . objects . published ( ) . values ( '<STR_LIT>' ) . order_by ( ) . distinct ( ) <EOL> return CategoryModel . objects . filter ( id__in = only_ids ) <EOL> def lastmod ( self , category ) : <EOL> """<STR_LIT>""" <EOL> lastitems = EntryModel . objects . published ( ) . order_by ( '<STR_LIT>' ) . filter ( categories = category ) . only ( '<STR_LIT>' ) <EOL> return lastitems [ <NUM_LIT:0> ] . modification_date <EOL> def location ( self , category ) : <EOL> """<STR_LIT>""" <EOL> return blog_reverse ( '<STR_LIT>' , kwargs = { '<STR_LIT>' : category . slug } , ignore_multiple = True ) <EOL> class AuthorArchiveSitemap ( Sitemap ) : <EOL> def items ( self ) : <EOL> only_ids = EntryModel . objects . published ( ) . values ( '<STR_LIT>' ) . order_by ( ) . distinct ( ) <EOL> return User . objects . filter ( id__in = only_ids ) <EOL> def lastmod ( self , author ) : <EOL> """<STR_LIT>""" <EOL> lastitems = EntryModel . objects . published ( ) . order_by ( '<STR_LIT>' ) . filter ( author = author ) . only ( '<STR_LIT>' ) <EOL> return lastitems [ <NUM_LIT:0> ] . modification_date <EOL> def location ( self , author ) : <EOL> """<STR_LIT>""" <EOL> return blog_reverse ( '<STR_LIT>' , kwargs = { '<STR_LIT>' : author . username } , ignore_multiple = True ) <EOL> class TagArchiveSitemap ( Sitemap ) : <EOL> def items ( self ) : <EOL> if '<STR_LIT>' not in settings . INSTALLED_APPS : <EOL> return [ ] <EOL> from taggit . models import Tag <EOL> only_instances = EntryModel . objects . published ( ) . only ( '<STR_LIT>' ) <EOL> return Tag . objects . filter ( <EOL> taggit_taggeditem_items__object_id__in = only_instances , <EOL> taggit_taggeditem_items__content_type = ContentType . objects . get_for_model ( EntryModel ) <EOL> ) <EOL> def lastmod ( self , tag ) : <EOL> """<STR_LIT>""" <EOL> lastitems = EntryModel . objects . published ( ) . order_by ( '<STR_LIT>' ) . filter ( tags = tag ) . only ( '<STR_LIT>' ) <EOL> return lastitems [ <NUM_LIT:0> ] . modification_date <EOL> def location ( self , tag ) : <EOL> """<STR_LIT>""" <EOL> return blog_reverse ( '<STR_LIT>' , kwargs = { '<STR_LIT>' : tag . slug } , ignore_multiple = True ) </s>
