diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/links/models.py | 20 | ||||
-rw-r--r-- | app/links/retriever.py | 18 |
2 files changed, 19 insertions, 19 deletions
diff --git a/app/links/models.py b/app/links/models.py index a343604..0a82366 100644 --- a/app/links/models.py +++ b/app/links/models.py @@ -1,9 +1,7 @@ -import datetime from django.core.urlresolvers import reverse from django.utils.encoding import force_text from django.db import models from django.contrib.sitemaps import Sitemap -from django.contrib.syndication.views import Feed from taggit.managers import TaggableManager from utils.widgets import markdown_to_html @@ -25,7 +23,7 @@ class Link(models.Model): class Meta: ordering = ['-pub_date'] - def __unicode__(self): + def __str__(self): return self.title def get_absolute_url(self): @@ -40,12 +38,6 @@ class Link(models.Model): def get_next_published(self): return self.get_next_by_pub_date(status__exact=1) - def get_thumbnail_url(self): - return "http://images.luxagraf.net/magnolia_thumbs/%s" % (self.screen_url) - - def comment_period_open(self): - return self.enable_comments and datetime.datetime.today() - datetime.timedelta(30) <= self.pub_date - def admin_link(self): return force_text('<a href="%s">Visit Site</a>' % (self.url)) admin_link.allow_tags = True @@ -61,13 +53,3 @@ class LinkSitemap(Sitemap): def lastmod(self, obj): return obj.pub_date - - -class LatestLinks(Feed): - title = "Luxagraf: Links" - link = "http://ma.gnolia.com/people/luxagraf/bookmarks" - description = "Links to interesting stuff" - description_template = 'feeds/links_description.html' - - def items(self): - return Link.objects.filter(status__exact=1).order_by('-pub_date')[:10] diff --git a/app/links/retriever.py b/app/links/retriever.py index ec7f834..8916f7c 100644 --- a/app/links/retriever.py +++ b/app/links/retriever.py @@ -1,4 +1,5 @@ import datetime +from random import randint from django.core.exceptions import ObjectDoesNotExist from django.template.defaultfilters import striptags @@ -54,3 +55,20 @@ def email_link(link): msg.send() msg = EmailMessage(subject, striptags(body), 'sng@luxagraf.net', ['sng+links@luxagraf.net']) msg.send() + + +def random_link(): + total = Link.objects.all().count() + pk = randint(1, total) + try: + link = Link.objects.get(pk=pk) + except: + try: + link = Link.objects.get(pk=pk+1) + except: + link = Link.objects.get(pk=pk+91) + subject = "today's link: %s" % link.title + body = "%s\n\n%s\n\n\nvisit site:%s\n\n\ndelete link: https://live.luxagraf.net/admin/links/link/%s/" % (link.title, link.description, link.url, link.pk) + + msg = EmailMessage(subject, striptags(body), 'sng@luxagraf.net', ['sng@luxagraf.net']) + msg.send() |