﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
1709	[patch] [magic-removal] updated comments module's view/model to use the new m-r apis	EricHsu<nkeric@…>	Adrian Holovaty	"guys,

today while I'm using the comments module to implement something, I
guess I found two bugs:

 * in the models.py, the get_list_with_karma method should be updated to use the extra() method to inject the ""select"" kwargs, otherwise, the templatetag get_comment_list won't work;
 * in the views/comments.py, self.user_cache.get_comments_comment_count()  - the get_comments_comment_count() api doesn't exist now, should be updated to use the self.user_cache.comment_set.count() to get the comments count. 

I've done some debug work to check the patch for models.py, pls check
the the following sqls to confirm if my patch work as expected:

before patching:

{{{
{'sql': 'SELECT
""comments_comment"".""id"",""comments_comment"".""user_id"",""comments_comment"".""content_type_id"",
""comments_comment"".""object_id"",""comments_comment"".""headline"",""comments_comment"".""comment"",
""comments_comment"".""rating1"",""comments_comment"".""rating2"",""comments_comment"".""rating3"",
""comments_comment"".""rating4"",""comments_comment"".""rating5"",""comments_comment"".""rating6"",
""comments_comment"".""rating7"",""comments_comment"".""rating8"",""comments_comment"".""valid_rating"",
""comments_comment"".""submit_date"",""comments_comment"".""is_public"",""comments_comment"".""ip_address"",
""comments_comment"".""is_removed"",""comments_comment"".""site_id""
FROM ""comments_comment"" INNER JOIN ""django_content_type"" AS
""comments_comment__content_type"" ON
""comments_comment"".""content_type_id"" =
""comments_comment__content_type"".""id"" WHERE
(""comments_comment__content_type"".""model"" = article AND
""comments_comment"".""site_id"" = 1 AND
""comments_comment__content_type"".""app_label"" = aiyo AND
""comments_comment"".""object_id"" = 32) ORDER BY
""comments_comment"".""submit_date"" DESC',
  'time': '0.001'},

}}}

patched:

{{{
{'sql': 'SELECT
""comments_comment"".""id"",""comments_comment"".""user_id"",""comments_comment"".""content_type_id"",
""comments_comment"".""object_id"",""comments_comment"".""headline"",""comments_comment"".""comment"",
""comments_comment"".""rating1"",""comments_comment"".""rating2"",""comments_comment"".""rating3"",
""comments_comment"".""rating4"",""comments_comment"".""rating5"",""comments_comment"".""rating6"",
""comments_comment"".""rating7"",""comments_comment"".""rating8"",""comments_comment"".""valid_rating"",
""comments_comment"".""submit_date"",""comments_comment"".""is_public"",""comments_comment"".""ip_address"",
""comments_comment"".""is_removed"",""comments_comment"".""site_id"",(SELECT
COUNT(*) FROM comments_karmascore, comments_comment WHERE
comments_karmascore.comment_id=comments_comment.id AND score=1) AS
""_karma_total_good"",(SELECT COUNT(*) FROM comments_karmascore,
comments_comment WHERE
comments_karmascore.comment_id=comments_comment.id AND score=-1) AS
""_karma_total_bad"" FROM ""comments_comment"" INNER JOIN
""django_content_type"" AS ""comments_comment__content_type"" ON
""comments_comment"".""content_type_id"" =
""comments_comment__content_type"".""id"" WHERE
(""comments_comment__content_type"".""model"" = article AND
""comments_comment"".""site_id"" = 1 AND
""comments_comment__content_type"".""app_label"" = aiyo AND
""comments_comment"".""object_id"" = 32) ORDER BY
""comments_comment"".""submit_date"" DESC',
  'time': '0.001'},
}}}"	defect	closed	Core (Other)	magic-removal	normal	fixed			Unreviewed	1	0	0	0	0	0
