summaryrefslogtreecommitdiff
path: root/app/links/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/links/models.py')
-rw-r--r--app/links/models.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/app/links/models.py b/app/links/models.py
index 4954a29..cdbe680 100644
--- a/app/links/models.py
+++ b/app/links/models.py
@@ -4,6 +4,7 @@ from django.template.defaultfilters import striptags
from django.urls import reverse
from django.utils.encoding import force_text
from django.utils.html import format_html
+from django.apps import apps
from django.db import models
from django.utils import timezone
from django.core.mail import EmailMessage
@@ -69,6 +70,23 @@ class Link(models.Model):
return format_html('<a href="%s">Visit Site</a>' % (self.url))
admin_link.short_description = 'Link'
+ @property
+ def get_next_published(self):
+ return self.get_next_by_pub_date(status__exact=1)
+
+ @property
+ def get_previous_admin_url(self):
+ n = self.get_previous_by_pub_date()
+ return reverse('admin:%s_%s_change' %(self._meta.app_label, self._meta.model_name), args=[n.id] )
+
+ @property
+ def get_next_admin_url(self):
+ model = apps.get_model(app_label=self._meta.app_label, model_name=self._meta.model_name)
+ try:
+ return reverse('admin:%s_%s_change' %(self._meta.app_label, self._meta.model_name), args=[self.get_next_by_pub_date().pk] )
+ except model.DoesNotExist:
+ return ''
+
@receiver(post_save, sender=Link)
def post_save_events(sender, update_fields, created, instance, **kwargs):