Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

assert set_content_ratings triggers es reindex (bug 932324) #1696

Merged
merged 1 commit into from
Jan 28, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions mkt/search/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,15 @@ def test_pagination(self):
eq_(data['meta']['offset'], 2)
eq_(data['meta']['next'], None)

def test_content_ratings_reindex(self):
self.webapp.set_content_ratings({
mkt.ratingsbodies.ESRB: mkt.ratingsbodies.ESRB_T
})
self.refresh('webapp')
res = self.client.get(self.url)
obj = res.json['objects'][0]
ok_(obj['content_ratings']['ratings'])


class TestApiFeatures(RestOAuth, ESTestCase):
fixtures = fixture('webapp_337141')
Expand Down
5 changes: 5 additions & 0 deletions mkt/webapps/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1177,11 +1177,14 @@ def set_content_ratings(self, data):
{<ratingsbodies class>: <rating class>, ...}

"""
from . import tasks
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

circular dependency?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, I saw it was being done everywhere else. I'll remove it later if it doesn't circle.


for ratings_body, rating in data.items():
cr, created = self.content_ratings.safer_get_or_create(
ratings_body=ratings_body.id, defaults={'rating': rating.id})
if not created:
cr.update(rating=rating.id, modified=datetime.datetime.now())

self.set_iarc_storefront_data() # Ratings updated, sync with IARC.

if self.content_ratings.filter(
Expand All @@ -1197,6 +1200,8 @@ def set_content_ratings(self, data):
if geodatas.exists():
geodatas.update(region_de_usk_exclude=False)

tasks.index_webapps.delay([self.id])

def set_descriptors(self, data):
"""
Sets IARC rating descriptors on this app.
Expand Down