summaryrefslogtreecommitdiff
path: root/app/links
diff options
context:
space:
mode:
Diffstat (limited to 'app/links')
-rw-r--r--app/links/models.py16
-rw-r--r--app/links/retriever.py14
2 files changed, 18 insertions, 12 deletions
diff --git a/app/links/models.py b/app/links/models.py
index 0255745..45d9c09 100644
--- a/app/links/models.py
+++ b/app/links/models.py
@@ -8,6 +8,7 @@ from django.apps import apps
from django.db import models
from django.utils import timezone
from django.core.mail import EmailMessage
+from django.core.mail import send_mail
from django.contrib.sitemaps import Sitemap
from django.db.models.signals import post_save
from django.dispatch import receiver
@@ -48,8 +49,12 @@ def email_link(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', ['sng+links@luxagraf.net'])
- msg.send()
+ send_mail(
+ subject,
+ body,
+ 'sng@luxagraf.net',
+ ['sng@luxagraf.net']
+ )
def get_upload_path(self, filename):
@@ -120,11 +125,8 @@ def post_save_events(sender, update_fields, created, instance, **kwargs):
if instance.body_markdown:
pass
else:
- try:
- md = get_source(instance.url)
- instance.body_markdown = md['markdown']
- except:
- pass
+ md = get_source(instance.url)
+ instance.body_markdown = md['markdown']
post_save.disconnect(post_save_events, sender=Link)
instance.save()
post_save.connect(post_save_events, sender=Link)
diff --git a/app/links/retriever.py b/app/links/retriever.py
index 8916f7c..8843557 100644
--- a/app/links/retriever.py
+++ b/app/links/retriever.py
@@ -5,6 +5,7 @@ from django.core.exceptions import ObjectDoesNotExist
from django.template.defaultfilters import striptags
from django.core.mail import EmailMessage
from django.conf import settings
+from django.core.mail import send_mail
from links.models import Link
@@ -49,12 +50,15 @@ def email_link(link):
"""
Sends an imported link to Gmail (never hurts to have backups)
"""
- subject = link.title
+ subject = "[link] %s" % 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()
+ #msg = EmailMessage(subject, striptags(body), 'sng@luxagraf.net', ['sng@luxagraf.net'])
+ send_mail(
+ subject,
+ body,
+ 'sng@luxagraf.net',
+ ['sng@luxagraf.net']
+ )
def random_link():