summaryrefslogtreecommitdiff
path: root/app/links
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2018-04-05 09:30:44 -0400
committerluxagraf <sng@luxagraf.net>2018-04-05 09:30:44 -0400
commita26ad92062c8d1ab13727a2a4f4293d17d09808c (patch)
treef40e6d729fab874fb80376f32be9da84d13120d5 /app/links
parent2d440f0c309f49803ec95c46d9f586a7305780cd (diff)
added image to links for screencaptures
Diffstat (limited to 'app/links')
-rw-r--r--app/links/admin.py6
-rw-r--r--app/links/migrations/0004_link_image.py19
-rw-r--r--app/links/models.py5
3 files changed, 27 insertions, 3 deletions
diff --git a/app/links/admin.py b/app/links/admin.py
index 1811b3f..3bec927 100644
--- a/app/links/admin.py
+++ b/app/links/admin.py
@@ -9,6 +9,8 @@ from utils.widgets import TagListFilter
from .models import Link
from .forms import LinkForm
+
+@admin.register(Link)
class LinkAdmin(admin.ModelAdmin):
form = LinkForm
list_display = ('title', 'admin_link', 'pub_date', 'status')
@@ -26,7 +28,7 @@ class LinkAdmin(admin.ModelAdmin):
('Details', {
'fields': (
'pub_date',
- 'tags',
+ ('tags', 'image'),
'status'
),
'classes': 'collapse'
@@ -35,5 +37,3 @@ class LinkAdmin(admin.ModelAdmin):
class Media:
js = ('next-prev-links.js',)
-
-admin.site.register(Link, LinkAdmin)
diff --git a/app/links/migrations/0004_link_image.py b/app/links/migrations/0004_link_image.py
new file mode 100644
index 0000000..9fe6ab1
--- /dev/null
+++ b/app/links/migrations/0004_link_image.py
@@ -0,0 +1,19 @@
+# Generated by Django 2.0.1 on 2018-04-05 09:06
+
+from django.db import migrations, models
+import links.models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('links', '0003_auto_20171214_2239'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='link',
+ name='image',
+ field=models.FileField(blank=True, null=True, upload_to=links.models.get_upload_path),
+ ),
+ ]
diff --git a/app/links/models.py b/app/links/models.py
index cdbe680..8ebc962 100644
--- a/app/links/models.py
+++ b/app/links/models.py
@@ -35,6 +35,10 @@ def email_link(link):
msg.send()
+def get_upload_path(self, filename):
+ return "images/links/%s/%s" % (datetime.datetime.today().strftime("%Y"), filename)
+
+
class Link(models.Model):
title = models.CharField(max_length=400)
url = models.CharField(max_length=400)
@@ -47,6 +51,7 @@ class Link(models.Model):
)
status = models.IntegerField(choices=PUB_STATUS, default=0)
tags = TaggableManager(blank=True)
+ image = models.FileField(blank=True, null=True, upload_to=get_upload_path)
class Meta:
ordering = ['-pub_date']