summaryrefslogtreecommitdiff
path: root/app/lib/django_comments/abstracts.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/lib/django_comments/abstracts.py')
-rw-r--r--app/lib/django_comments/abstracts.py9
1 files changed, 9 insertions, 0 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):