summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/links/models.py20
-rw-r--r--app/stuff/admin.py46
2 files changed, 60 insertions, 6 deletions
diff --git a/app/links/models.py b/app/links/models.py
index 46867e7..52d6e2b 100644
--- a/app/links/models.py
+++ b/app/links/models.py
@@ -1,5 +1,6 @@
import requests
import datetime
+from random import randint
from django.template.defaultfilters import striptags
from django.urls import reverse
from django.utils.html import format_html
@@ -15,6 +16,25 @@ from taggit.managers import TaggableManager
from utils.widgets import markdown_to_html
+def random_link():
+ """
+ Emails me a random link everyday (via cron)
+ """
+ total = Link.objects.all().count()
+ pk = randint(1, total)
+ try:
+ link = Link.objects.get(pk=pk)
+ except Link.DoesNotExist:
+ try:
+ link = Link.objects.get(pk=pk+1)
+ except Link.DoesNotExist:
+ 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()
+
+
def get_source(source):
url = "http://heckyesmarkdown.com/go/?read=1&preview=0&showframe=0&output=json&u=%s" % (source)
r = requests.get(url, timeout=15.001)
diff --git a/app/stuff/admin.py b/app/stuff/admin.py
index 638b40a..dc15a1f 100644
--- a/app/stuff/admin.py
+++ b/app/stuff/admin.py
@@ -1,19 +1,53 @@
from django.contrib import admin
-from stuff.models import Item
+from .models import Item
+@admin.register(Item)
class ItemAdmin(admin.ModelAdmin):
list_display = (
'title',
- 'image_url',
'admin_thumbnail',
- 'creator',
'item_type',
- 'current_price',
+ 'creator',
+ 'purchase_price',
'item_format',
'isbn'
)
list_filter = ['item_format', 'item_type']
-
-admin.site.register(Item, ItemAdmin)
+ fieldsets = (
+ ('Item', {
+ 'fields': (
+ 'title',
+ ('date_purchased', 'date_added'),
+ 'item_format',
+ 'purchase_price',
+ 'image',
+ 'item_type',
+ 'serial_number',
+ 'isbn',
+ ),
+ 'classes': (
+ 'show',
+ 'extrapretty',
+ 'wide'
+ )
+ }
+ ),
+ ('Extra', {
+ 'fields': (
+ 'creator',
+ 'creator_sort_last_name',
+ 'creator_sort_first_name',
+ 'current_price',
+ 'retail_price',
+ 'amazon_url',
+ 'image_url',
+ ),
+ 'classes': (
+ 'collapse',
+ 'extrapretty',
+ 'wide'
+ )
+ }),
+ )