diff options
Diffstat (limited to 'app/gtd')
-rw-r--r-- | app/gtd/models.py | 16 | ||||
-rw-r--r-- | app/gtd/urls.py | 2 | ||||
-rw-r--r-- | app/gtd/views.py | 6 |
3 files changed, 17 insertions, 7 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() diff --git a/app/gtd/urls.py b/app/gtd/urls.py index ec4c474..6467299 100644 --- a/app/gtd/urls.py +++ b/app/gtd/urls.py @@ -100,7 +100,7 @@ urlpatterns = [ ), path( r'wiredpost/create', - views.WiredPostNewView.as_view(), + views.WiredPostCreateView.as_view(), name="wiredpost-create" ), path( diff --git a/app/gtd/views.py b/app/gtd/views.py index 8aa2c30..67a8b4e 100644 --- a/app/gtd/views.py +++ b/app/gtd/views.py @@ -209,6 +209,12 @@ class WiredPostNewView(ListView): return context +class WiredPostCreateView(CreateView): + model = WiredPost + fields = ['title', 'post_status', 'url', 'template_type', 'update_frequency', 'edit_url', 'date_last_pub'] + template_name = "gtd/wiredpost_form.html" + + class WiredPostTodoView(ListView): template_name = 'gtd/wiredpost_table.html' |