forked from apluslms/a-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sitemaps.py
50 lines (37 loc) · 1.17 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
from django.contrib import sitemaps
from django.urls.base import reverse
from django.utils import timezone
from lib.sitemaps import AplusSitemap
from .models import CourseInstance, CourseModule
class CourseStaticViewSitemap(sitemaps.Sitemap):
priority = 0.5
changefreq = 'monthly'
def items(self):
return [
'home',
'archive',
]
def location(self, item):
return reverse(item)
class InstanceSitemap(AplusSitemap):
changefreq = 'daily'
base_priority = 0.4
def items(self):
return CourseInstance.objects.filter(
view_content_to=CourseInstance.VIEW_ACCESS.PUBLIC,
visible_to_students=True,
)
class ModuleSitemap(AplusSitemap):
changefreq = 'daily'
base_priority = 0.2
def items(self):
return CourseModule.objects.filter(
course_instance__view_content_to=CourseInstance.VIEW_ACCESS.PUBLIC,
course_instance__visible_to_students=True,
opening_time__lte=timezone.now(),
)
all_sitemaps = {
'course_static': CourseStaticViewSitemap,
'course_instance': InstanceSitemap,
'course_module': ModuleSitemap,
}