diff options
| author | Jannis Leidel <jannis@leidel.info> | 2010-01-04 02:28:09 +0000 |
|---|---|---|
| committer | Jannis Leidel <jannis@leidel.info> | 2010-01-04 02:28:09 +0000 |
| commit | abcf997713fe87a68c8ce7035c9e9dc2266145ea (patch) | |
| tree | 46ef96ac38d39316f618c43652f7f8b4b6d588d2 /tests/regressiontests/comment_tests | |
| parent | 936c99b7c745a3e104d274f6e0dabb68e3086ca0 (diff) | |
Fixed #11100 - Added get_comment_permalink template tag to comments app to be able to customize the anchor pattern of a comment from the template. Thanks to Idan Gazit for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12080 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/comment_tests')
| -rw-r--r-- | tests/regressiontests/comment_tests/tests/templatetag_tests.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/regressiontests/comment_tests/tests/templatetag_tests.py b/tests/regressiontests/comment_tests/tests/templatetag_tests.py index a1187ca732..7cb2148b54 100644 --- a/tests/regressiontests/comment_tests/tests/templatetag_tests.py +++ b/tests/regressiontests/comment_tests/tests/templatetag_tests.py @@ -1,5 +1,6 @@ from django.contrib.comments.forms import CommentForm from django.contrib.comments.models import Comment +from django.contrib.contenttypes.models import ContentType from django.template import Template, Context from regressiontests.comment_tests.models import Article, Author from regressiontests.comment_tests.tests import CommentTestCase @@ -63,3 +64,23 @@ class CommentTemplateTagTests(CommentTestCase): def testGetCommentListFromObject(self): self.testGetCommentList("{% get_comment_list for a as cl %}") + + def testGetCommentPermalink(self): + self.createSomeComments() + t = "{% load comments %}{% get_comment_list for comment_tests.author author.id as cl %}" + t += "{% get_comment_permalink cl.0 %}" + ct = ContentType.objects.get_for_model(Author) + author = Author.objects.get(pk=1) + ctx, out = self.render(t, author=author) + self.assertEqual(out, "/cr/%s/%s/#c2" % (ct.id, author.id)) + + def testGetCommentPermalinkFormatted(self): + self.createSomeComments() + t = "{% load comments %}{% get_comment_list for comment_tests.author author.id as cl %}" + t += "{% get_comment_permalink cl.0 '#c%(id)s-by-%(user_name)s' %}" + ct = ContentType.objects.get_for_model(Author) + author = Author.objects.get(pk=1) + ctx, out = self.render(t, author=author) + self.assertEqual(out, "/cr/%s/%s/#c2-by-Joe Somebody" % (ct.id, author.id)) + + |
