summaryrefslogtreecommitdiff
path: root/app/links
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2015-08-21 14:05:21 +0000
committerluxagraf <sng@luxagraf.net>2015-08-21 14:05:21 +0000
commitb98a093e737cc367bb8fbd714038e17882fe1ec5 (patch)
tree2bba4e6f40ff18aea9dffde2660b6ab36ed4acc6 /app/links
parent4556c9b6a6e0698491541060670a36404c764931 (diff)
fixed link retriever
Diffstat (limited to 'app/links')
-rw-r--r--app/links/admin.py2
-rw-r--r--app/links/models.py6
-rw-r--r--app/links/retriever.py8
-rw-r--r--app/links/sync_links.py3
4 files changed, 11 insertions, 8 deletions
diff --git a/app/links/admin.py b/app/links/admin.py
index 68efe9e..f80e665 100644
--- a/app/links/admin.py
+++ b/app/links/admin.py
@@ -3,7 +3,7 @@ from links.models import Link
class LinkAdmin(admin.ModelAdmin):
- list_display = ('title', 'rating', 'pub_date', 'status')
+ list_display = ('title', 'admin_link', 'rating', 'pub_date', 'status')
search_fields = ['title', 'description', 'url']
list_filter = ['rating', 'status']
fieldsets = (
diff --git a/app/links/models.py b/app/links/models.py
index c6b502c..11a6798 100644
--- a/app/links/models.py
+++ b/app/links/models.py
@@ -1,4 +1,5 @@
import datetime
+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
@@ -52,6 +53,11 @@ class Link(models.Model):
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
+ admin_link.short_description = 'Link'
+
class LinkSitemap(Sitemap):
changefreq = "never"
diff --git a/app/links/retriever.py b/app/links/retriever.py
index f807820..9aec34d 100644
--- a/app/links/retriever.py
+++ b/app/links/retriever.py
@@ -13,10 +13,9 @@ import requests
import json
def sync_pinboard_links():
- PB_URL = "https://api.pinboard.in/v1/posts/all?results=150&format=json"
+ PB_URL = "https://api.pinboard.in/v1/posts/all?results=70&format=json"
r = requests.get(PB_URL, auth=((settings.PIN_USER, settings.PIN_PASS)))
links = json.loads(r.text)
- print(links)
for link in links:
try:
#check to see if link exists
@@ -32,12 +31,11 @@ def sync_pinboard_links():
pub_date=datetime.datetime.strptime(link['time'], "%Y-%m-%dT%H:%M:%SZ"),
status=0
)
- print(l.title)
if created:
print(l.title)
- for t in link['tags']:
+ for t in link['tags'].split(" "):
l.tags.add(t)
-
+ email_link(l)
"""
def sync_pinboard_links_old():
diff --git a/app/links/sync_links.py b/app/links/sync_links.py
index b61395c..7a0cd9c 100644
--- a/app/links/sync_links.py
+++ b/app/links/sync_links.py
@@ -3,12 +3,11 @@ import os
from os.path import dirname, abspath
PROJECT_ROOT = abspath(dirname(dirname(dirname(__file__)))) + '/'
#PROJECT_ROOT = abspath(dirname(dirname(__file__)))
-print PROJECT_ROOT
sys.path.append(PROJECT_ROOT)
sys.path.append(PROJECT_ROOT + '/app')
sys.path.append(PROJECT_ROOT + '/app/lib')
sys.path.append(PROJECT_ROOT + '/config')
sys.path.append('/home/luxagraf/apps/venv/bin/python2.7/')
-os.environ['DJANGO_SETTINGS_MODULE'] = 'settings.settings'
+os.environ['DJANGO_SETTINGS_MODULE'] = 'config.settings'
from links import retriever
retriever.sync_pinboard_links()