Another Step in the Quest to clean up the code base.
This commit is contained in:
@@ -1,24 +1,31 @@
|
||||
"""Add News and static pages to the global sitemap."""
|
||||
from django.contrib.sitemaps import Sitemap
|
||||
from .models import Article, Page
|
||||
|
||||
|
||||
class ArticleSitemap(Sitemap):
|
||||
"""Add the news artivles to the Sitemap"""
|
||||
changefreq = "never"
|
||||
priority = 0.6
|
||||
|
||||
def items(self):
|
||||
"""only add published articles to the sitemap"""
|
||||
return Article.objects.published()
|
||||
|
||||
def lastmod(self, article):
|
||||
"""return the last modification date of the article."""
|
||||
return article.date_modified
|
||||
|
||||
|
||||
class PageSitemap(Sitemap):
|
||||
"""add the static pages to the sitemap."""
|
||||
changefreq = "monthly"
|
||||
priority = 0.4
|
||||
|
||||
def items(self):
|
||||
return Page.objects.all() # filter(status__gt=0)
|
||||
"""add all pages to the sitemap."""
|
||||
return Page.objects.all()
|
||||
|
||||
def lastmod(self, page):
|
||||
"""return the last modification date of the page."""
|
||||
return page.date_modified
|
||||
|
||||
Reference in New Issue
Block a user