diff --git a/src/olympia/users/models.py b/src/olympia/users/models.py index a188ba101c..cffa3e400c 100644 --- a/src/olympia/users/models.py +++ b/src/olympia/users/models.py @@ -410,12 +410,9 @@ class UserProfile(OnChangeMixin, ModelBase, AbstractBaseUser): return not self.display_name and self.has_anonymous_username @cached_property - def reviews(self): - """All reviews that are not dev replies.""" - qs = self._ratings_all.filter(reply_to=None) - # Force the query to occur immediately. Several - # reviews-related tests hang if this isn't done. - return qs + def ratings(self): + """All ratings that are not dev replies.""" + return self._ratings_all.filter(reply_to=None) def delete(self, hard=False): # Recursive import diff --git a/src/olympia/users/tests/test_models.py b/src/olympia/users/tests/test_models.py index 1b14d06616..b26725a46c 100644 --- a/src/olympia/users/tests/test_models.py +++ b/src/olympia/users/tests/test_models.py @@ -217,25 +217,25 @@ class TestUserProfile(TestCase): def test_review_replies(self): """ Make sure that developer replies are not returned as if they were - original reviews. + original ratings. """ addon = Addon.objects.get(id=3615) - u = UserProfile.objects.get(pk=2519) + user = UserProfile.objects.get(pk=2519) version = addon.find_latest_public_listed_version() - new_rating = Rating(version=version, user=u, rating=2, body='hello', + new_rating = Rating(version=version, user=user, rating=2, body='hello', addon=addon) new_rating.save() - new_reply = Rating(version=version, user=u, reply_to=new_rating, + new_reply = Rating(version=version, user=user, reply_to=new_rating, addon=addon, body='my reply') new_reply.save() - review_list = [r.pk for r in u.reviews] + review_list = [rating.pk for rating in user.ratings] assert len(review_list) == 1 assert new_rating.pk in review_list, ( - 'Original review must show up in review list.') + 'Original review must show up in ratings list.') assert new_reply.pk not in review_list, ( - 'Developer reply must not show up in review list.') + 'Developer reply must not show up in ratings list.') def test_num_addons_listed(self): """Test that num_addons_listed is only considering add-ons for which diff --git a/src/olympia/users/tests/test_views.py b/src/olympia/users/tests/test_views.py index 3df51349c8..fa6ab4ce82 100644 --- a/src/olympia/users/tests/test_views.py +++ b/src/olympia/users/tests/test_views.py @@ -636,37 +636,37 @@ class TestProfileSections(TestCase): assert pq(self.client.get(self.url).content)( '.num-addons a').length == 0 - a = amo.tests.addon_factory(type=amo.ADDON_PERSONA) + addon = amo.tests.addon_factory(type=amo.ADDON_PERSONA) - AddonUser.objects.create(user=self.user, addon=a) + AddonUser.objects.create(user=self.user, addon=addon) - r = self.client.get(self.url) + response = self.client.get(self.url) - doc = pq(r.content) + doc = pq(response.content) items = doc('#my-themes .persona') assert items.length == 1 - assert items('a[href="%s"]' % a.get_url_path()).length == 1 + assert items('a[href="%s"]' % addon.get_url_path()).length == 1 def test_my_reviews(self): - r = Rating.objects.filter(reply_to=None)[0] - r.update(user=self.user) + rating = Rating.objects.filter(reply_to=None)[0] + rating.update(user=self.user) cache.clear() - self.assertSetEqual(set(self.user.reviews), {r}) + self.assertSetEqual(set(self.user.ratings), {rating}) - r = self.client.get(self.url) - doc = pq(r.content)('#reviews') + response = self.client.get(self.url) + doc = pq(response.content)('#reviews') assert not doc.hasClass('full'), ( 'reviews should not have "full" class when there are collections') assert doc('.item').length == 1 assert doc('#review-218207').length == 1 # Edit Review form should be present. - self.assertTemplateUsed(r, 'ratings/edit_review.html') + self.assertTemplateUsed(response, 'ratings/edit_review.html') def _get_reviews(self, username): self.client.login(email=username) - r = self.client.get(reverse('users.profile', args=[999])) - doc = pq(r.content)('#reviews') + response = self.client.get(reverse('users.profile', args=[999])) + doc = pq(response.content)('#reviews') return doc('#review-218207 .item-actions a.delete-review') def test_my_reviews_delete_link(self): diff --git a/src/olympia/users/views.py b/src/olympia/users/views.py index 1f4443c49f..08ae493aec 100644 --- a/src/olympia/users/views.py +++ b/src/olympia/users/views.py @@ -255,7 +255,7 @@ def profile(request, user): '-weekly_downloads') addons = amo.utils.paginate(request, addons, 5) - reviews = amo.utils.paginate(request, user.reviews.all()) + reviews = amo.utils.paginate(request, user.ratings.all()) data = {'profile': user, 'own_coll': own_coll, 'reviews': reviews, 'fav_coll': fav_coll, 'edit_any_user': edit_any_user,