summaryrefslogtreecommitdiff
path: root/app/posts/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/posts/models.py')
-rw-r--r--app/posts/models.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/app/posts/models.py b/app/posts/models.py
index fc40475..31e96b0 100644
--- a/app/posts/models.py
+++ b/app/posts/models.py
@@ -101,6 +101,8 @@ class Post(models.Model):
return reverse('essays:detail', kwargs={"slug": self.slug})
if self.post_type == 3:
return reverse('src:detail', kwargs={"slug": self.slug})
+ if self.post_type == 5:
+ return reverse('fieldnote:detail', kwargs={"year": self.pub_date.year, "month": self.pub_date.strftime("%m"), "slug": self.slug})
def comment_period_open(self):
return self.enable_comments and datetime.datetime.today() - datetime.timedelta(30) <= self.pub_date
@@ -142,6 +144,13 @@ class Post(models.Model):
'''Get the site's latitude.'''
return self.point.y
+ @property
+ def sitemap_priority(self):
+ if self.post_type in [0,1,4,5]:
+ return 1.0
+ else:
+ return 0.7
+
def save(self, *args, **kwargs):
created = self.pk is None
if not created:
@@ -167,11 +176,11 @@ class Post(models.Model):
self.featured_image.sizes.add(s)
self.featured_image.sizes.add(ss)
self.featured_image.save()
- #if old.title != self.title or old.slug != self.slug:
- # related, c = RelatedPost.objects.get_or_create(model_name=self.get_content_type(), entry_id = self.id, pub_date=self.pub_date)
- # related.title = self.title
- # related.slug = self.slug
- # related.save()
+ if old.title != self.title or old.slug != self.slug:
+ related, c = RelatedPost.objects.get_or_create(model_name=self.get_content_type(), entry_id = self.id, pub_date=self.pub_date)
+ related.title = self.title
+ related.slug = self.slug
+ related.save()
super(Post, self).save(*args, **kwargs)
@@ -217,7 +226,6 @@ def post_save_events(sender, update_fields, created, instance, **kwargs):
class PostSitemap(Sitemap):
changefreq = "never"
- priority = 1.0
protocol = "https"
def items(self):
@@ -226,6 +234,9 @@ class PostSitemap(Sitemap):
def lastmod(self, obj):
return obj.pub_date
+ def priority(self, obj):
+ return obj.sitemap_priority
+
"""
for p in src: