diff --git a/django/contrib/comments/urls.py b/django/contrib/comments/urls.py
index ae0b7ff..151f253 100644
a
|
b
|
urlpatterns = patterns('django.contrib.comments.views',
|
13 | 13 | ) |
14 | 14 | |
15 | 15 | urlpatterns += patterns('', |
16 | | url(r'^cr/(\d+)/(\w+)/$', 'django.views.defaults.shortcut', name='comments-url-redirect'), |
| 16 | url(r'^cr/(\d+)/((\w|-)+)/$', 'django.views.defaults.shortcut', name='comments-url-redirect'), |
17 | 17 | ) |
18 | 18 | |
diff --git a/tests/regressiontests/comment_tests/fixtures/comment_utils.xml b/tests/regressiontests/comment_tests/fixtures/comment_utils.xml
index a39bbf6..d874ab5 100644
a
|
b
|
|
12 | 12 | <field type="DateField" name="pub_date">2008-01-02</field> |
13 | 13 | <field type="BooleanField" name="enable_comments">False</field> |
14 | 14 | </object> |
| 15 | <object pk="1" model="comment_tests.slugpost"> |
| 16 | <field type="SlugField" name="slug">test-this</field> |
| 17 | </object> |
15 | 18 | </django-objects> |
diff --git a/tests/regressiontests/comment_tests/models.py b/tests/regressiontests/comment_tests/models.py
index 62f4168..e66fc75 100644
a
|
b
|
class Entry(models.Model):
|
28 | 28 | |
29 | 29 | def __str__(self): |
30 | 30 | return self.title |
| 31 | |
| 32 | class SlugPost(models.Model): |
| 33 | """A Post like model whos PK is a slug""" |
| 34 | slug = models.SlugField(primary_key=True,max_length=100) |
| 35 | |
| 36 | def __str__(self): |
| 37 | return self.slug |
| 38 | |
| 39 | |
| 40 | No newline at end of file |
diff --git a/tests/regressiontests/comment_tests/tests/__init__.py b/tests/regressiontests/comment_tests/tests/__init__.py
index 449fea4..7ceabfc 100644
a
|
b
|
from django.contrib.comments.models import Comment
|
4 | 4 | from django.contrib.contenttypes.models import ContentType |
5 | 5 | from django.contrib.sites.models import Site |
6 | 6 | from django.test import TestCase |
7 | | from regressiontests.comment_tests.models import Article, Author |
| 7 | from regressiontests.comment_tests.models import Article, Author, SlugPost |
8 | 8 | |
9 | 9 | # Shortcut |
10 | 10 | CT = ContentType.objects.get_for_model |
… |
… |
class CommentTestCase(TestCase):
|
55 | 55 | comment = "Damn, I wanted to be first.", |
56 | 56 | site = Site.objects.get_current(), |
57 | 57 | ) |
| 58 | |
58 | 59 | c4 = Comment.objects.create( |
59 | 60 | content_type = CT(Author), |
60 | 61 | object_pk = "2", |
… |
… |
class CommentTestCase(TestCase):
|
63 | 64 | comment = "You get here first, too?", |
64 | 65 | site = Site.objects.get_current(), |
65 | 66 | ) |
| 67 | |
| 68 | c5 = Comment.objects.create( |
| 69 | content_type = CT(SlugPost), |
| 70 | object_pk = "test-this", |
| 71 | user = user, |
| 72 | user_url = "http://example.com/~frank/", |
| 73 | comment = "Wonder how the slugs work", |
| 74 | site = Site.objects.get_current(), |
| 75 | ) |
66 | 76 | |
67 | | return c1, c2, c3, c4 |
| 77 | return c1, c2, c3, c4, c5 |
68 | 78 | |
69 | 79 | def getData(self): |
70 | 80 | return { |
diff --git a/tests/regressiontests/comment_tests/tests/comment_view_tests.py b/tests/regressiontests/comment_tests/tests/comment_view_tests.py
index 312fab6..0ee2e61 100644
a
|
b
|
from django.conf import settings
|
3 | 3 | from django.contrib.auth.models import User |
4 | 4 | from django.contrib.comments import signals |
5 | 5 | from django.contrib.comments.models import Comment |
6 | | from regressiontests.comment_tests.models import Article |
| 6 | from django.core import urlresolvers |
| 7 | from regressiontests.comment_tests.models import Article, SlugPost |
7 | 8 | from regressiontests.comment_tests.tests import CommentTestCase |
8 | 9 | |
9 | 10 | post_redirect_re = re.compile(r'^http://testserver/posted/\?c=(?P<pk>\d+$)') |
… |
… |
class CommentViewTests(CommentTestCase):
|
206 | 207 | response = self.client.get(location) |
207 | 208 | self.assertTemplateUsed(response, "comments/posted.html") |
208 | 209 | self.assertEqual(response.context[0]["comment"], Comment.objects.get(pk=pk)) |
209 | | |
| 210 | |
| 211 | #---------------------------------------------------------------------- |
| 212 | def testCommentUrlLookup(self): |
| 213 | """""" |
| 214 | c1, c2, c3, c4, c5 = self.createSomeComments() |
| 215 | c5.save() |
| 216 | sp = Comment.objects.get(object_pk='test-this') |
| 217 | url = urlresolvers.reverse("comments-url-redirect", |
| 218 | args=(c5.content_type_id, c5.object_pk)) |
| 219 | self.assertEqual(url,'/cr/%i/%s/' % (c5.content_type_id,c5.object_pk) ) |
diff --git a/tests/regressiontests/comment_tests/tests/model_tests.py b/tests/regressiontests/comment_tests/tests/model_tests.py
index 17797bb..99e6d08 100644
a
|
b
|
class CommentModelTests(CommentTestCase):
|
9 | 9 | self.failIfEqual(c.submit_date, None) |
10 | 10 | |
11 | 11 | def testUserProperties(self): |
12 | | c1, c2, c3, c4 = self.createSomeComments() |
| 12 | c1, c2, c3, c4, c5 = self.createSomeComments() |
13 | 13 | self.assertEqual(c1.name, "Joe Somebody") |
14 | 14 | self.assertEqual(c2.email, "jsomebody@example.com") |
15 | 15 | self.assertEqual(c3.name, "Frank Nobody") |
… |
… |
class CommentManagerTests(CommentTestCase):
|
21 | 21 | |
22 | 22 | def testInModeration(self): |
23 | 23 | """Comments that aren't public are considered in moderation""" |
24 | | c1, c2, c3, c4 = self.createSomeComments() |
| 24 | c1, c2, c3, c4, c5 = self.createSomeComments() |
25 | 25 | c1.is_public = False |
26 | 26 | c2.is_public = False |
27 | 27 | c1.save() |
… |
… |
class CommentManagerTests(CommentTestCase):
|
31 | 31 | |
32 | 32 | def testRemovedCommentsNotInModeration(self): |
33 | 33 | """Removed comments are not considered in moderation""" |
34 | | c1, c2, c3, c4 = self.createSomeComments() |
| 34 | c1, c2, c3, c4, c5 = self.createSomeComments() |
35 | 35 | c1.is_public = False |
36 | 36 | c2.is_public = False |
37 | 37 | c2.is_removed = True |
… |
… |
class CommentManagerTests(CommentTestCase):
|
41 | 41 | self.assertEqual(moderated_comments, [c1]) |
42 | 42 | |
43 | 43 | def testForModel(self): |
44 | | c1, c2, c3, c4 = self.createSomeComments() |
| 44 | c1, c2, c3, c4, c5 = self.createSomeComments() |
45 | 45 | article_comments = list(Comment.objects.for_model(Article).order_by("id")) |
46 | 46 | author_comments = list(Comment.objects.for_model(Author.objects.get(pk=1))) |
47 | 47 | self.assertEqual(article_comments, [c1, c3]) |
diff --git a/tests/regressiontests/comment_tests/tests/moderation_view_tests.py b/tests/regressiontests/comment_tests/tests/moderation_view_tests.py
index b9eadd7..739c7d6 100644
a
|
b
|
class ApproveViewTests(CommentTestCase):
|
130 | 130 | |
131 | 131 | def testApprovePost(self): |
132 | 132 | """POSTing the delete view should mark the comment as removed""" |
133 | | c1, c2, c3, c4 = self.createSomeComments() |
| 133 | c1, c2, c3, c4, c5 = self.createSomeComments() |
134 | 134 | c1.is_public = False; c1.save() |
135 | 135 | |
136 | 136 | makeModerator("normaluser") |
… |
… |
class ModerationQueueTests(CommentTestCase):
|
174 | 174 | |
175 | 175 | def testModerationQueueContents(self): |
176 | 176 | """Moderation queue should display non-public, non-removed comments.""" |
177 | | c1, c2, c3, c4 = self.createSomeComments() |
| 177 | c1, c2, c3, c4, c5 = self.createSomeComments() |
178 | 178 | makeModerator("normaluser") |
179 | 179 | self.client.login(username="normaluser", password="normaluser") |
180 | 180 | |
diff --git a/tests/regressiontests/comment_tests/tests/templatetag_tests.py b/tests/regressiontests/comment_tests/tests/templatetag_tests.py
index a1187ca..ae400f2 100644
a
|
b
|
class CommentTemplateTagTests(CommentTestCase):
|
52 | 52 | self.testGetCommentCount("{% get_comment_count for a as cc %}") |
53 | 53 | |
54 | 54 | def testGetCommentList(self, tag=None): |
55 | | c1, c2, c3, c4 = self.createSomeComments() |
| 55 | c1, c2, c3, c4, c5 = self.createSomeComments() |
56 | 56 | t = "{% load comments %}" + (tag or "{% get_comment_list for comment_tests.author a.id as cl %}") |
57 | 57 | ctx, out = self.render(t, a=Author.objects.get(pk=1)) |
58 | 58 | self.assertEqual(out, "") |