forked from hacktoolkit/django-htk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sitemaps.py
37 lines (29 loc) · 915 Bytes
/
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
# Python Standard Library Imports
from itertools import chain
# Django Imports
from django.contrib.sitemaps import Sitemap
from django.urls import reverse
# https://docs.djangoproject.com/en/1.8/ref/contrib/sitemaps/
class HtkBaseSitemap(Sitemap):
priority = 0.5
changefreq = 'daily'
def get_static_view_names(self):
static_view_names = []
return static_view_names
def get_model_instances(self):
model_instances = []
return model_instances
def items(self):
static_view_names = self.get_static_view_names()
model_instances = self.get_model_instances()
_items = list(chain(
static_view_names,
model_instances,
))
return _items
def location(self, obj):
if type(obj) == str:
path = reverse(obj)
else:
path = obj.get_absolute_url()
return path