sitemaps.py 1.12 KB
Newer Older
Thom Wiggers's avatar
Thom Wiggers committed
1
2
3
4
5
6
7
8
9
10
11
from django.contrib import sitemaps
from django.urls import reverse

from . import models


class StaticViewSitemap(sitemaps.Sitemap):
    priority = 0.5
    changefreq = 'daily'

    def items(self):
12
13
        return ['activemembers:committees', 'activemembers:societies',
                'activemembers:boards']
Thom Wiggers's avatar
Thom Wiggers committed
14
15
16
17
18
19
20
21

    def location(self, item):
        return reverse(item)


class CommitteeSitemap(sitemaps.Sitemap):

    def items(self):
22
23
24
25
26
27
28
29
30
31
        return models.Committee.active_objects.all()

    def location(self, item):
        return item.get_absolute_url()


class SocietySitemap(sitemaps.Sitemap):

    def items(self):
        return models.Society.active_objects.all()
Thom Wiggers's avatar
Thom Wiggers committed
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

    def location(self, item):
        return item.get_absolute_url()


class BoardSitemap(sitemaps.Sitemap):
    changefreq = 'yearly'

    def items(self):
        return models.Board.objects.all()

    def location(self, item):
        return item.get_absolute_url()


sitemap = {
48
49
    'activemembers-static': StaticViewSitemap,
    'activemembers-committees': CommitteeSitemap,
50
    'activemembers-societies': SocietySitemap,
51
    'activemembers-boards': BoardSitemap,
Thom Wiggers's avatar
Thom Wiggers committed
52
}