This repository has been archived by the owner on Jul 29, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sitemaps.py
102 lines (81 loc) · 3.09 KB
/
sitemaps.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
from django.contrib.auth.models import User
from django.contrib.sitemaps import Sitemap, FlatPageSitemap
from django.core.urlresolvers import reverse
from sunlightfoundation.policy.models import PolicyPaper
from sunlightfoundation.presscenter.models import PressArticle, PressRelease
from wordpress.models import Post
import itertools
class BlogSitemap(Sitemap):
changefreq = "never"
priority = 0.5
def items(self):
return Post.objects.published()
def lastmod(self, obj):
return obj.post_date
class PolicyPaperSitemap(Sitemap):
changefreq = "never"
priority = 0.5
def items(self):
return PolicyPaper.objects.filter(published=True)
def location(self, obj):
return reverse('policy_document', args=(obj.slug,))
class PressSitemap(Sitemap):
changefreq = "never"
priority = 0.3
def items(self):
return [o for o in itertools.chain(
PressRelease.objects.filter(is_public=True),
PressArticle.objects.filter(is_public=True),
)]
def lastmod(self, obj):
return obj.date_posted
class StaffSitemap(Sitemap):
changefreq = "never"
priority = 0.4
def items(self):
return User.objects.filter(is_active=True, groups__name__in=(
'Staff - Consultants',
'Staff - Founders',
'Staff - General',
'Staff - Interns',
'Staff - Strategic Consultants',
))
def location(self, obj):
return reverse('people_detail', args=(obj.username,))
class StaticSitemap(Sitemap):
pages = [
{'path': '/about/', 'priority': 0.7},
{'path': '/about/board/', 'priority': 0.6},
{'path': '/about/funding/', 'priority': 0.7, 'changefreq': 'monthly'},
{'path': '/about/grants/', 'priority': 0.7, 'changefreq': 'monthly'},
{'path': '/about/history/'},
{'path': '/contact/', 'priority': 0.3, 'changefreq': 'never'},
{'path': '/donate/', 'priority': 0.7},
{'path': '/earmarkdisclosures/2009/', 'priority': 0.4, 'changefreq': 'never'},
{'path': '/earmarkdisclosures/2010/', 'priority': 0.4, 'changefreq': 'never'},
{'path': '/mailinglist/', 'priority': 0.3, 'changefreq': 'never'},
{'path': '/people/', 'priority': 0.6},
{'path': '/policy/'},
{'path': '/policy/poia/'},
{'path': '/policy/success/'},
{'path': '/press/'},
{'path': '/press/experts/', 'priority': 0.7, 'changefreq': 'monthly'},
{'path': '/projects/', 'priority': 0.8, 'changefreq': 'weekly'},
{'path': '/', 'priority': 1.0, 'changefreq': 'hourly'},
]
def items(self):
return self.pages
def location(self, obj):
return obj.get('path')
def changefreq(self, obj):
return obj.get('changefreq', 'never')
def priority(self, obj):
return obj.get('priority', '0.5')
sitemaps = {
'blog': BlogSitemap,
'flatpages': FlatPageSitemap,
'policy': PolicyPaperSitemap,
'press': PressSitemap,
'staff': StaffSitemap,
'static': StaticSitemap,
}