summaryrefslogtreecommitdiff
path: root/app/gtd/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/gtd/models.py')
-rw-r--r--app/gtd/models.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/app/gtd/models.py b/app/gtd/models.py
index f99c41c..5b058b2 100644
--- a/app/gtd/models.py
+++ b/app/gtd/models.py
@@ -149,7 +149,7 @@ class WiredPost(models.Model):
body = models.TextField(blank=True, null=True)
url = models.CharField(max_length=512, blank=True, null=True)
edit_url = models.CharField(max_length=512, blank=True, null=True)
- date_last_pub = models.DateField()
+ date_last_pub = models.DateField(blank=True, null=True)
guid = models.CharField(max_length=512, blank=True, null=True, db_index=True)
author = models.CharField(max_length=255, blank=True, null=True)
post_type = models.IntegerField(choices=PostType.choices, default=PostType.GUIDE)
@@ -187,12 +187,16 @@ class WiredPost(models.Model):
return format_html('<a target="_blank" href="%s">%s</a>' % (self.url, self.url))
admin_link.short_description = 'Link'
+ def get_absolute_url(self):
+ return reverse('gtd:wiredpost-detail', kwargs={"pk": self.id})
+
def save(self, *args, **kwargs):
- td = timezone.localdate() - self.date_last_pub
- if td.days > self.update_frequency and self.post_status != 1:
- self.needs_update = True
- else:
- self.needs_update = False
+ if self.date_last_pub:
+ td = timezone.localdate() - self.date_last_pub
+ if td.days > self.update_frequency and self.post_status != 1:
+ self.needs_update = True
+ else:
+ self.needs_update = False
super(WiredPost, self).save()