Code

Ticket #4189: djt-4189-combined.diff

File djt-4189-combined.diff, 3.2 KB (added by Jeremy Dunck <jdunck@…>, 7 years ago)

Supercedes previous 2 patches.

Line 
1Index: django/contrib/comments/templatetags/comments.py
2===================================================================
3--- django/contrib/comments/templatetags/comments.py    (revision 5178)
4+++ django/contrib/comments/templatetags/comments.py    (working copy)
5@@ -111,9 +111,9 @@
6             'site__id__exact': settings.SITE_ID,
7         }
8         kwargs.update(self.extra_kwargs)
9+        comment_list = get_list_function(**kwargs).order_by(self.ordering + 'submit_date').select_related()
10         if not self.free and settings.COMMENTS_BANNED_USERS_GROUP:
11-            kwargs['select'] = {'is_hidden': 'user_id IN (SELECT user_id FROM auth_user_groups WHERE group_id = %s)' % settings.COMMENTS_BANNED_USERS_GROUP}
12-        comment_list = get_list_function(**kwargs).order_by(self.ordering + 'submit_date').select_related()
13+            comment_list = comment_list.extra(select={'is_hidden': 'user_id IN (SELECT user_id FROM auth_user_groups WHERE group_id = %s)' % settings.COMMENTS_BANNED_USERS_GROUP})
14 
15         if not self.free:
16             if 'user' in context and context['user'].is_authenticated():
17Index: django/contrib/comments/models.py
18===================================================================
19--- django/contrib/comments/models.py   (revision 5178)
20+++ django/contrib/comments/models.py   (working copy)
21@@ -106,7 +106,10 @@
22         return "%s: %s..." % (self.user.username, self.comment[:100])
23 
24     def get_absolute_url(self):
25-        return self.get_content_object().get_absolute_url() + "#c" + str(self.id)
26+        try:
27+            return self.get_content_object().get_absolute_url() + "#c" + str(self.id)
28+        except AttributeError:
29+            return ""
30 
31     def get_crossdomain_url(self):
32         return "/r/%d/%d/" % (self.content_type_id, self.object_id)
33@@ -191,7 +194,10 @@
34         return "%s: %s..." % (self.person_name, self.comment[:100])
35 
36     def get_absolute_url(self):
37-        return self.get_content_object().get_absolute_url() + "#c" + str(self.id)
38+        try:
39+            return self.get_content_object().get_absolute_url() + "#c" + str(self.id)
40+        except AttributeError:
41+            return ""
42 
43     def get_content_object(self):
44         """
45Index: django/contrib/comments/views/comments.py
46===================================================================
47--- django/contrib/comments/views/comments.py   (revision 5178)
48+++ django/contrib/comments/views/comments.py   (working copy)
49@@ -112,7 +112,7 @@
50                 'This comment was posted by a user who has posted fewer than %(count)s comments:\n\n%(text)s', settings.COMMENTS_FIRST_FEW) % \
51                 {'count': settings.COMMENTS_FIRST_FEW, 'text': c.get_as_text()}
52             mail_managers("Comment posted by rookie user", message)
53-        if settings.COMMENTS_SKETCHY_USERS_GROUP and settings.COMMENTS_SKETCHY_USERS_GROUP in [g.id for g in self.user_cache.get_group_list()]:
54+        if settings.COMMENTS_SKETCHY_USERS_GROUP and settings.COMMENTS_SKETCHY_USERS_GROUP in [g.id for g in self.user_cache.groups.all()]:
55             message = _('This comment was posted by a sketchy user:\n\n%(text)s') % {'text': c.get_as_text()}
56             mail_managers("Comment posted by sketchy user (%s)" % self.user_cache.username, c.get_as_text())
57         return c