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

Commit

Permalink
Added version status to RT search result output (bug 857204)
Browse files Browse the repository at this point in the history
  • Loading branch information
robhudson committed Apr 4, 2013
1 parent 6b97a32 commit d925092
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
3 changes: 3 additions & 0 deletions media/js/mkt/reviewers.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@
$.each(data.objects, function(i, item) {
item.review_url = review_url.replace('__slug__', item.app_slug);
item.status = statuses[item.status];
if (item.latest_version_status) {
item.status += format(' | {0}', statuses[item.latest_version_status]);
}
results.push(search_result_row(item));
});
$searchIsland.html(
Expand Down
8 changes: 8 additions & 0 deletions mkt/search/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,12 @@ def dehydrate_slug(self, bundle):
def dehydrate(self, bundle):
bundle = super(SearchResource, self).dehydrate(bundle)
bundle.data['absolute_url'] = absolutify(bundle.obj.get_detail_url())

# Add latest version status for reviewers.
# TODO: When this no longer hits the db, use the field in ES.
if acl.action_allowed(bundle.request, 'Apps', 'Review'):
bundle.data['latest_version_status'] = (
bundle.obj.versions.latest().all_files[0].status
if bundle.obj.is_packaged else None)

return bundle
20 changes: 19 additions & 1 deletion mkt/search/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,15 @@ def test_status_anon(self):
eq_(json.loads(res.content)['reason'],
'Unauthorized to filter by status.')

def test_status_value_packaged(self):
# When packaged and not a reviewer we exclude latest version status.
self.webapp.update(is_packaged=True)
res = self.client.get(self.list_url)
eq_(res.status_code, 200)
obj = json.loads(res.content)['objects'][0]
eq_(obj['status'], amo.STATUS_PUBLIC)
eq_('latest_version_status' in obj, False)

def test_addon_type_anon(self):
res = self.client.get(self.list_url + ({'type': 'app'},))
eq_(res.status_code, 200)
Expand Down Expand Up @@ -209,14 +218,23 @@ def test_status_reviewer(self):

res = self.client.get(self.list_url + ({'status': 'any'},))
eq_(res.status_code, 200)
objs = json.loads(res.content)['objects']
obj = json.loads(res.content)['objects'][0]
eq_(obj['slug'], self.webapp.app_slug)

res = self.client.get(self.list_url + ({'status': 'vindaloo'},))
eq_(res.status_code, 400)
error = json.loads(res.content)['error_message']
eq_(error.keys(), ['status'])

def test_status_value_packaged(self):
# When packaged we also include the latest version status.
self.webapp.update(is_packaged=True)
res = self.client.get(self.list_url)
eq_(res.status_code, 200)
obj = json.loads(res.content)['objects'][0]
eq_(obj['status'], amo.STATUS_PUBLIC)
eq_(obj['latest_version_status'], amo.STATUS_PUBLIC)

def test_addon_type_reviewer(self):
res = self.client.get(self.list_url + ({'type': 'app'},))
eq_(res.status_code, 200)
Expand Down

0 comments on commit d925092

Please sign in to comment.