Django Sitemap Framework integriert

This commit is contained in:
2016-10-11 23:54:18 +02:00
parent 07db651002
commit 4659eced63
22 changed files with 249 additions and 176 deletions

22
src/events/sitemaps.py Normal file
View File

@@ -0,0 +1,22 @@
from django.contrib.sitemaps import Sitemap
from django.utils import timezone
from .models import Event, Photo
class EventSitemap(Sitemap):
changefreq = "never"
priority = 0.6
protocol = 'https'
def items(self):
return Event.objects.all()
def priority(self, event):
delta = timezone.now() - event.start
delta = abs(delta.days / 300.0 )
return max(1 - delta, 0.1)
def lastmod(self, event):
return event.end
return min(event.end, timezone.now())