diff options
-rw-r--r-- | sitemaps.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/sitemaps.py b/sitemaps.py index 958d1f4..177555f 100644 --- a/sitemaps.py +++ b/sitemaps.py @@ -1,3 +1,5 @@ +from datetime import datetime, timedelta + from django.contrib.sitemaps import Sitemap from django.core.urlresolvers import reverse @@ -17,8 +19,8 @@ class PackagesSitemap(Sitemap): class PackageFilesSitemap(PackagesSitemap): - changefreq = "monthly" - priority = "0.3" + changefreq = "weekly" + priority = "0.2" def location(self, obj): return PackagesSitemap.location(self, obj) + 'files/' @@ -57,15 +59,26 @@ class SplitPackagesSitemap(Sitemap): class NewsSitemap(Sitemap): - changefreq = "never" priority = "0.8" + def __init__(self): + now = datetime.utcnow() + self.one_day_ago = now - timedelta(days=1) + self.one_week_ago = now - timedelta(days=7) + def items(self): return News.objects.all() def lastmod(self, obj): return obj.last_modified + def changefreq(self, obj): + if obj.last_modified > self.one_day_ago: + return 'daily' + if obj.last_modified > self.one_week_ago: + return 'weekly' + return 'yearly' + class BaseSitemap(Sitemap): base_viewnames = ( |