forked from apluslms/a-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sitemaps.py
55 lines (42 loc) · 1.75 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
from django.urls.base import reverse
from django.utils import timezone
from course.models import CourseInstance
from lib.sitemaps import AplusSitemap
from .models import BaseExercise, CourseChapter, LearningObject
class BaseExerciseSitemap(AplusSitemap):
changefreq = 'daily'
base_priority = 0.5
def items(self):
return BaseExercise.objects.filter(
course_module__course_instance__view_content_to=CourseInstance.VIEW_ACCESS.PUBLIC,
course_module__course_instance__visible_to_students=True,
course_module__opening_time__lte=timezone.now(),
status=LearningObject.STATUS.READY,
audience=LearningObject.AUDIENCE.COURSE_AUDIENCE,
parent__isnull=True,
)
class CourseChapterSitemap(AplusSitemap):
changefreq = 'daily'
def items(self):
return CourseChapter.objects.filter(
course_module__course_instance__view_content_to=CourseInstance.VIEW_ACCESS.PUBLIC,
course_module__course_instance__visible_to_students=True,
course_module__opening_time__lte=timezone.now(),
status__in=[LearningObject.STATUS.READY, LearningObject.STATUS.UNLISTED],
audience=LearningObject.AUDIENCE.COURSE_AUDIENCE,
)
class TableOfContentsSitemap(AplusSitemap):
changefreq = 'monthly'
base_priority = 0.2
def items(self):
return CourseInstance.objects.filter(
view_content_to=CourseInstance.VIEW_ACCESS.PUBLIC,
visible_to_students=True,
)
def location(self, item):
return reverse('toc', kwargs=item.get_url_kwargs())
all_sitemaps = {
'exercise_exercise': BaseExerciseSitemap,
'exercise_chapter': CourseChapterSitemap,
'exercise_toc': TableOfContentsSitemap,
}