export_ranking now exports KyuDanRankings and SeasonRankings.

This commit is contained in:
2017-11-03 07:15:28 +01:00
parent f3d44b743b
commit d5b67ffe0c
4 changed files with 226 additions and 21 deletions

View File

@@ -0,0 +1,53 @@
"""To geneate a Sitemap with all events."""
from datetime import date
from django.contrib.sitemaps import Sitemap
from django.urls import reverse
from events.models import Event
from kasu.sitemaps import GenericSitemap
from .models import SeasonRanking
class EventRankingSitemap(GenericSitemap):
@staticmethod
def items():
"""add all upcoming and archived events to the sitemap."""
return Event.objects.all().exclude(eventranking=None)
@staticmethod
def location(event):
return reverse('event-ranking', kwargs={'event': event.id})
class EventHanchanSitemap(GenericSitemap):
@staticmethod
def items():
"""add all upcoming and archived events to the sitemap."""
return Event.objects.all().exclude(eventranking=None)
@staticmethod
def location(event):
return reverse('event-hanchan-list', kwargs={'event': event.id})
class MajongSeasonSitemap(Sitemap):
priority = 0.5
@staticmethod
def items():
seasons = SeasonRanking.objects.all().distinct('season').order_by(
'season')
seasons = seasons.values_list('season', flat=True)
return seasons
@staticmethod
def location(season):
return reverse('mahjong-ladder', kwargs={'season': season})
@staticmethod
def changefreq(season):
if season == date.today().year:
return 'weekly'
else:
return 'never'