regluit/core/sitemaps.py

24 lines
689 B
Python
Raw Normal View History

2013-03-09 22:37:33 +00:00
from django.contrib.sitemaps import Sitemap
2018-07-24 15:33:39 +00:00
from django.urls import reverse
2013-03-09 22:37:33 +00:00
from regluit.core.models import Work, Edition
class WorkSitemap(Sitemap):
protocol = 'https'
limit = 10000
2013-03-09 22:37:33 +00:00
def items(self):
return Work.objects.all()
def priority(self,work):
2016-01-19 22:28:45 +00:00
return '{:.1f}'.format(work.priority()/5.0)
2013-03-09 22:37:33 +00:00
class PublisherSitemap(Sitemap):
priority = 0.2
protocol = 'https'
def items(self):
return Edition.objects.exclude(publisher_name__isnull=True).order_by('publisher_name__name').values('publisher_name').distinct()
2013-03-09 22:37:33 +00:00
def location(self, pub):
return reverse("bypubname_list",args=[pub['publisher_name']])