summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2019-04-13 11:03:53 -0500
committerluxagraf <sng@luxagraf.net>2019-04-13 11:03:53 -0500
commitfff2d74815d0cb147e97d64c7d6bc633c308c60f (patch)
treec963468bca04d1159e92a01ac632aebfe0f7d3f2
parent55adc26c6987dc2e8585dd53ef4b8c05753b526d (diff)
added tags to links admin
-rw-r--r--app/links/admin.py2
-rw-r--r--app/links/models.py9
-rw-r--r--design/templates/admin/index.html8
3 files changed, 17 insertions, 2 deletions
diff --git a/app/links/admin.py b/app/links/admin.py
index b1aabc0..f967dde 100644
--- a/app/links/admin.py
+++ b/app/links/admin.py
@@ -11,7 +11,7 @@ from .models import Link
@admin.register(Link)
class LinkAdmin(admin.ModelAdmin):
- list_display = ('title', 'admin_link', 'pub_date', 'status')
+ list_display = ('title', 'admin_link', 'pub_date', 'admin_tags')
search_fields = ['title', 'description', 'url']
list_filter = ['status', TagListFilter]
fieldsets = (
diff --git a/app/links/models.py b/app/links/models.py
index ecea2d9..0255745 100644
--- a/app/links/models.py
+++ b/app/links/models.py
@@ -3,7 +3,7 @@ import datetime
from random import randint
from django.template.defaultfilters import striptags
from django.urls import reverse
-from django.utils.html import format_html
+from django.utils.html import format_html, format_html_join
from django.apps import apps
from django.db import models
from django.utils import timezone
@@ -86,6 +86,13 @@ class Link(models.Model):
return format_html('<a href="%s">Visit Site</a>' % (self.url))
admin_link.short_description = 'Link'
+ def admin_tags(self):
+ return format_html_join(
+ '\n', "<a href='/admin/links/link?tag={}'>{}</a>,",
+ ((tag.slug, tag.name) for tag in self.tags.all())
+ )
+ admin_tags.short_description = 'Tags'
+
@property
def get_previous_published(self):
return self.get_previous_by_pub_date(status__exact=1)
diff --git a/design/templates/admin/index.html b/design/templates/admin/index.html
index fc857f2..653ec95 100644
--- a/design/templates/admin/index.html
+++ b/design/templates/admin/index.html
@@ -70,6 +70,14 @@ td, th {
<th scope="row"><a href="/admin/pages/page/">pages</a></th>
<td><a href="/admin/pages/page/add/" class="addlink">Add</a></td>
</tr>
+ <tr>
+ <th scope="row"><a href="/admin/links/link/">link</a></th>
+ <td><a href="/admin/links/link/add/" class="addlink">Add</a></td>
+ </tr>
+ <tr>
+ <th scope="row"><a href="/admin/src/post/">src post</a></th>
+ <td><a href="/admin/src/post/add/" class="addlink">Add</a></td>
+ </tr>
</table>
</div>
{% for app in app_list %}