summaryrefslogtreecommitdiff
path: root/app/src/models.py
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2015-10-31 21:14:08 -0400
committerluxagraf <sng@luxagraf.net>2015-10-31 21:14:08 -0400
commit0d26984b8f8ba1d51e58367e1b2ce42a062c1e85 (patch)
treef7763324e5dc9c81719967f36797df56f67e9386 /app/src/models.py
parentf00a7a4cd1e1e22412fd34d3977ff22c92ee681b (diff)
added src to sitemap and fixed a url error in location sitemap. whoops.
Diffstat (limited to 'app/src/models.py')
-rw-r--r--app/src/models.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/app/src/models.py b/app/src/models.py
index 9b596b1..6b5f476 100644
--- a/app/src/models.py
+++ b/app/src/models.py
@@ -1,6 +1,8 @@
from django.db import models
+from django.contrib.sitemaps import Sitemap
from blog.models import image_url_replace, extract_images
import markdown
+import datetime
class Topic(models.Model):
name = models.CharField(max_length=60)
@@ -10,6 +12,12 @@ class Topic(models.Model):
def __str__(self):
return self.name
+ def get_absolute_url(self):
+ return "/src/topic/%s" % (self.slug)
+
+ @property
+ def pub_date(self):
+ return datetime.datetime.now()
class Entry(models.Model):
title = models.CharField(max_length=200)
@@ -94,3 +102,17 @@ class Book(models.Model):
def get_absolute_url(self):
return "/src/books/%s" % (self.slug)
+
+from itertools import chain
+
+class SrcSitemap(Sitemap):
+ changefreq = "never"
+ priority = 0.7
+ protocol = "https"
+
+ def items(self):
+ return list(chain(Entry.objects.all(), Book.objects.all(), Topic.objects.all()))
+
+
+ def lastmod(self, obj):
+ return obj.pub_date