Another Step in the Quest to clean up the code base.
This commit is contained in:
@@ -1,20 +1,23 @@
|
||||
"""To geneate a Sitemap with all events."""
|
||||
from django.contrib.sitemaps import Sitemap
|
||||
from django.utils import timezone
|
||||
from .models import Event
|
||||
from .models import Photo
|
||||
|
||||
|
||||
class EventSitemap(Sitemap):
|
||||
"""To add an event to the global sitemap."""
|
||||
changefreq = "never"
|
||||
protocol = 'https'
|
||||
|
||||
def items(self):
|
||||
"""add all events to the sitemap."""
|
||||
return Event.objects.all()
|
||||
|
||||
def priority(self, event):
|
||||
delta = timezone.now() - event.start
|
||||
delta = abs(delta.days / 300.0)
|
||||
"""give events closer to the present a higer priority for crawlers."""
|
||||
delta = abs((timezone.now() - event.start) / 300.0)
|
||||
return max(1 - delta, 0.1)
|
||||
|
||||
def lastmod(self, event):
|
||||
"""return the last modification date."""
|
||||
return event.date_modified
|
||||
|
||||
Reference in New Issue
Block a user