summaryrefslogtreecommitdiff
path: root/app/lib/django_comments
diff options
context:
space:
mode:
Diffstat (limited to 'app/lib/django_comments')
-rw-r--r--app/lib/django_comments/abstracts.py9
-rw-r--r--app/lib/django_comments/admin.py3
2 files changed, 11 insertions, 1 deletions
diff --git a/app/lib/django_comments/abstracts.py b/app/lib/django_comments/abstracts.py
index f4ff362..e74ea02 100644
--- a/app/lib/django_comments/abstracts.py
+++ b/app/lib/django_comments/abstracts.py
@@ -4,6 +4,8 @@ from django.conf import settings
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.contrib.sites.models import Site
+from django.apps import apps
+from django.utils.html import mark_safe
from django.db import models
from django.utils import timezone
from six import python_2_unicode_compatible
@@ -47,6 +49,13 @@ class BaseCommentAbstractModel(models.Model):
args=(self.content_type_id, self.object_pk)
)
+ def get_object_url(self):
+ ctype = self.content_type
+ object_pk = self.object_pk
+ model = apps.get_model(ctype.app_label, ctype.model)
+ target = model.objects.get(pk=object_pk)
+ return mark_safe("<a href='%s'>%s</a>" % (target.get_absolute_url(), target.title))
+ get_object_url.short_description = "comment item"
@python_2_unicode_compatible
class CommentAbstractModel(BaseCommentAbstractModel):
diff --git a/app/lib/django_comments/admin.py b/app/lib/django_comments/admin.py
index d4af2d9..8451c70 100644
--- a/app/lib/django_comments/admin.py
+++ b/app/lib/django_comments/admin.py
@@ -19,6 +19,7 @@ class UsernameSearch(object):
class CommentsAdmin(admin.ModelAdmin):
+
fieldsets = (
(
None,
@@ -34,7 +35,7 @@ class CommentsAdmin(admin.ModelAdmin):
),
)
- list_display = ('name', 'content_type', 'object_pk', 'ip_address', 'submit_date', 'is_public', 'is_removed')
+ list_display = ('name', 'content_type', 'get_object_url', 'object_pk', 'ip_address', 'submit_date', 'is_public', 'is_removed')
list_filter = ('submit_date', 'site', 'is_public', 'is_removed')
date_hierarchy = 'submit_date'
ordering = ('-submit_date',)