summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2018-04-05 10:54:07 -0400
committerluxagraf <sng@luxagraf.net>2018-04-05 10:54:07 -0400
commit8cbaf47761faeb45b78503e093fbbd1314194802 (patch)
tree30f3c9ce330b874f6f7f7408290f65029bb8ac02 /app
parenta26ad92062c8d1ab13727a2a4f4293d17d09808c (diff)
cleaned up links model and added datetime import
Diffstat (limited to 'app')
-rw-r--r--app/links/models.py22
1 files changed, 9 insertions, 13 deletions
diff --git a/app/links/models.py b/app/links/models.py
index 8ebc962..46867e7 100644
--- a/app/links/models.py
+++ b/app/links/models.py
@@ -1,8 +1,7 @@
import requests
-import json
+import datetime
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
@@ -25,12 +24,10 @@ def get_source(source):
def email_link(link):
"""
- Sends an imported link to Gmail (never hurts to have backups)
+ Emails me a copy of link
"""
subject = link.title
body = "%s\n\n%s\n\n\nvisit site:%s\n" % (link.title, link.description, link.url)
- msg = EmailMessage(subject, striptags(body), 'sng@luxagraf.net', ['luxagraf+links@gmail.com'])
- msg.send()
msg = EmailMessage(subject, striptags(body), 'sng@luxagraf.net', ['sng+links@luxagraf.net'])
msg.send()
@@ -65,30 +62,28 @@ class Link(models.Model):
def render_description(self):
return markdown_to_html(self.description)
- def get_previous_published(self):
- return self.get_previous_by_pub_date(status__exact=1)
-
- def get_next_published(self):
- return self.get_next_by_pub_date(status__exact=1)
-
def admin_link(self):
return format_html('<a href="%s">Visit Site</a>' % (self.url))
admin_link.short_description = 'Link'
@property
+ def get_previous_published(self):
+ return self.get_previous_by_pub_date(status__exact=1)
+
+ @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] )
+ 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] )
+ 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 ''
@@ -108,6 +103,7 @@ def post_save_events(sender, update_fields, created, instance, **kwargs):
post_save.connect(post_save_events, sender=Link)
email_link(instance)
+
class LinkSitemap(Sitemap):
changefreq = "never"
priority = 0.4