Coverage for website/thabloid/sitemaps.py: 93.75%

16 statements  

« prev     ^ index     » next       coverage.py v7.6.7, created at 2025-08-14 10:31 +0000

1from django.contrib import sitemaps 

2from django.urls import reverse 

3 

4from .models import Thabloid 

5 

6 

7class StaticViewSitemap(sitemaps.Sitemap): 

8 """Sitemap of the static thabloid index page.""" 

9 

10 changefreq = "monthly" 

11 

12 def items(self): 

13 """Return the index url name.""" 

14 return ["thabloid:index"] 

15 

16 def location(self, item): 

17 """Return the index url.""" 

18 return reverse(item) 

19 

20 

21class ThabloidSitemap(sitemaps.Sitemap): 

22 """Sitemap of the thabloid pages.""" 

23 

24 changefreq = "never" 

25 

26 def items(self): 

27 """Return all Thabloids.""" 

28 return Thabloid.objects.all() 

29 

30 def location(self, item): 

31 """Return the url of a Thabloid.""" 

32 return item.get_absolute_url() 

33 

34 

35sitemap = { 

36 "thabloid-static": StaticViewSitemap, 

37 "thabloid-thabloids": ThabloidSitemap, 

38}