partial revert of de1714
This commit is contained in:
Родитель
da1d4229d1
Коммит
2dd435c3d4
|
@ -2,7 +2,6 @@ from django.conf.urls import include, patterns, url
|
|||
|
||||
from lib.misc.urlconf_decorator import decorate
|
||||
|
||||
import amo
|
||||
from amo.decorators import login_required
|
||||
from . import views
|
||||
|
||||
|
@ -30,7 +29,7 @@ settings_patterns = decorate(login_required, patterns('',
|
|||
|
||||
purchases_patterns = decorate(login_required, patterns('',
|
||||
url('^$', views.purchases, name='account.purchases'),
|
||||
url(r'^%s' % amo.ADDON_UUID, views.purchases,
|
||||
url(r'^(?P<product_id>\d+)', views.purchases,
|
||||
name='account.purchases.receipt'),
|
||||
))
|
||||
|
||||
|
|
|
@ -36,20 +36,20 @@ class PurchasesFilter(BaseFilter):
|
|||
return order_by_translation(qs.filter(id__in=self.uids), 'name')
|
||||
|
||||
|
||||
def purchase_list(request, user, uuid):
|
||||
def purchase_list(request, user, product_id):
|
||||
cs = (Contribution.objects
|
||||
.filter(user=user,
|
||||
type__in=[amo.CONTRIB_PURCHASE, amo.CONTRIB_INAPP,
|
||||
amo.CONTRIB_REFUND, amo.CONTRIB_CHARGEBACK])
|
||||
.order_by('created'))
|
||||
if uuid:
|
||||
cs = cs.filter(addon__guid=uuid)
|
||||
if product_id:
|
||||
cs = cs.filter(addon__guid=product_id)
|
||||
|
||||
ids = list(cs.values_list('addon_id', flat=True))
|
||||
product_ids = []
|
||||
# If you are asking for a receipt for just one item, show only that.
|
||||
# Otherwise, we'll show all apps that have a contribution or are free.
|
||||
if not uuid:
|
||||
if not product_id:
|
||||
product_ids = list(user.installed_set
|
||||
.filter(install_type__in=
|
||||
[apps.INSTALL_TYPE_USER,
|
||||
|
@ -67,7 +67,7 @@ def purchase_list(request, user, uuid):
|
|||
ids=[ids, product_ids],
|
||||
uids=unique_ids)
|
||||
|
||||
if uuid and not listing.qs.exists():
|
||||
if product_id and not listing.qs.exists():
|
||||
# User has requested a receipt for an app he ain't got.
|
||||
raise http.Http404
|
||||
|
||||
|
|
|
@ -191,16 +191,16 @@ def preapproval(request, complete=None, cancel=None):
|
|||
return http.HttpResponseRedirect(url)
|
||||
|
||||
|
||||
def purchases(request, uuid=None, template=None):
|
||||
def purchases(request, product_id=None, template=None):
|
||||
"""A list of purchases that a user has made through the Marketplace."""
|
||||
products, contributions, listing = purchase_list(request,
|
||||
request.amo_user,
|
||||
uuid)
|
||||
product_id)
|
||||
return jingo.render(request, 'account/purchases.html',
|
||||
{'pager': products,
|
||||
'listing_filter': listing,
|
||||
'contributions': contributions,
|
||||
'single': bool(uuid),
|
||||
'single': bool(product_id),
|
||||
'show_link': True})
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче