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

Commit 141a685

Browse files
author
Andy McKay
committed
restrict reviewer receipts to the reviewer tools (bug 827352)
1 parent 7a25923 commit 141a685

4 files changed

Lines changed: 28 additions & 14 deletions

File tree

mkt/account/tests/test_utils_.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,20 @@ def setUp(self):
1818
self.app = Webapp.objects.get(pk=337141)
1919
self.req = RequestFactory().get('/')
2020

21-
def test_user(self):
22-
Installed.objects.create(user=self.user, addon=self.app)
23-
eq_(list(purchase_list(self.req, self.user, None)[0].object_list),
24-
[self.app])
25-
26-
def test_other(self):
27-
for t in [apps.INSTALL_TYPE_DEVELOPER, apps.INSTALL_TYPE_REVIEWER]:
28-
Installed.objects.create(user=self.user, addon=self.app,
29-
install_type=t)
21+
def _test(self, type, exists):
22+
Installed.objects.create(user=self.user, addon=self.app,
23+
install_type=type)
24+
if exists:
25+
eq_(list(purchase_list(self.req, self.user, None)[0].object_list),
26+
[self.app])
27+
else:
3028
assert not purchase_list(self.req, self.user, None)[0].object_list
29+
30+
def test_user(self):
31+
self._test(apps.INSTALL_TYPE_USER, True)
32+
33+
def test_developer(self):
34+
self._test(apps.INSTALL_TYPE_DEVELOPER, True)
35+
36+
def test_reviewer(self):
37+
self._test(apps.INSTALL_TYPE_REVIEWER, False)

mkt/account/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ def purchase_list(request, user, product_id):
5151
# Otherwise, we'll show all apps that have a contribution or are free.
5252
if not product_id:
5353
product_ids = list(user.installed_set
54-
.filter(install_type=apps.INSTALL_TYPE_USER)
54+
.filter(install_type__in=
55+
[apps.INSTALL_TYPE_USER,
56+
apps.INSTALL_TYPE_DEVELOPER])
5557
.exclude(addon__in=ids)
5658
.values_list('addon_id', flat=True))
5759

mkt/receipts/tests/test_views.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@ def test_pending_paid_for_reviewer(self):
8888
assert self.client.login(username='editor@mozilla.com',
8989
password='password')
9090
eq_(self.client.post(self.url).status_code, 200)
91+
# Because they aren't using reviewer tools, they'll get a normal
92+
# install record and receipt.
9193
eq_(self.addon.installed.all()[0].install_type,
92-
apps.INSTALL_TYPE_REVIEWER)
94+
apps.INSTALL_TYPE_USER)
9395

9496
def test_pending_paid_for_developer(self):
9597
AddonUser.objects.create(addon=self.addon, user=self.user)

mkt/receipts/views.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,12 @@ def _record(request, addon):
7474
not is_reviewer and not is_dev):
7575
raise PermissionDenied
7676

77-
# Log the install.
78-
install_type = (apps.INSTALL_TYPE_REVIEWER if is_reviewer
79-
else apps.INSTALL_TYPE_DEVELOPER if is_dev
77+
# If you are reviewer, you get a user receipt. Use the reviewer tools
78+
# to get a reviewer receipt. App developers still get their special
79+
# receipt.
80+
install_type = (apps.INSTALL_TYPE_DEVELOPER if is_dev
8081
else apps.INSTALL_TYPE_USER)
82+
# Log the install.
8183
installed, c = Installed.objects.safer_get_or_create(addon=addon,
8284
user=request.amo_user, install_type=install_type)
8385

@@ -170,6 +172,7 @@ def verify(request, uuid):
170172
return http.HttpResponse(verify.invalid(),
171173
verify.get_headers(verify.invalid()))
172174

175+
173176
@addon_all_view
174177
@json_view
175178
@post_required

0 commit comments

Comments
 (0)