def user_summary(request, user_id): user = get_object_or_404(UserProfile, pk=user_id) is_admin = acl.action_allowed(request, 'Users', 'Edit') app_summary = _app_summary(user.pk) # All refunds that this user has requested (probably as a consumer). req = Refund.objects.filter(contribution__user=user) # All instantly-approved refunds that this user has requested. appr = req.filter(status=amo.REFUND_APPROVED_INSTANT) refund_summary = {'approved': appr.count(), 'requested': req.count()} # TODO: This should return all `addon` types and not just webapps. # -- currently get_details_url() fails on non-webapps so this is a # temp fix. user_addons = (user.addons.filter( type=amo.ADDON_WEBAPP).order_by('-created')) user_addons = paginate(request, user_addons, per_page=15) paypal_ids = set( user.addons.exclude(paypal_id='').values_list('paypal_id', flat=True)) payment_data = (AddonPaymentData.objects.filter( addon__authors=user).values( *AddonPaymentData.address_fields()).distinct()) return jingo.render( request, 'lookup/user_summary.html', { 'account': user, 'app_summary': app_summary, 'is_admin': is_admin, 'refund_summary': refund_summary, 'user_addons': user_addons, 'payment_data': payment_data, 'paypal_ids': paypal_ids })
def user_summary(request, user_id): user = get_object_or_404(UserProfile, pk=user_id) is_admin = acl.action_allowed(request, 'Users', 'Edit') app_summary = _app_summary(user.pk) # All refunds that this user has requested (probably as a consumer). req = Refund.objects.filter(contribution__user=user) # All instantly-approved refunds that this user has requested. appr = req.filter(status=amo.REFUND_APPROVED_INSTANT) refund_summary = {'approved': appr.count(), 'requested': req.count()} # TODO: This should return all `addon` types and not just webapps. # -- currently get_details_url() fails on non-webapps so this is a # temp fix. user_addons = (user.addons.filter(type=amo.ADDON_WEBAPP) .order_by('-created')) user_addons = paginate(request, user_addons, per_page=15) paypal_ids = set(user.addons.exclude(paypal_id='') .values_list('paypal_id', flat=True)) payment_data = (AddonPaymentData.objects.filter(addon__authors=user) .values(*AddonPaymentData.address_fields()) .distinct()) return jingo.render(request, 'lookup/user_summary.html', {'account': user, 'app_summary': app_summary, 'is_admin': is_admin, 'refund_summary': refund_summary, 'user_addons': user_addons, 'payment_data': payment_data, 'paypal_ids': paypal_ids})
def user_summary(request, user_id): user = get_object_or_404(UserProfile, pk=user_id) is_admin = acl.action_allowed(request, "Users", "Edit") app_summary = _app_summary(user.pk) # All refunds that this user has requested (probably as a consumer). req = Refund.objects.filter(contribution__user=user) # All instantly-approved refunds that this user has requested. appr = req.filter(status=amo.REFUND_APPROVED_INSTANT) refund_summary = {"approved": appr.count(), "requested": req.count()} # TODO: This should return all `addon` types and not just webapps. # -- currently get_details_url() fails on non-webapps so this is a # temp fix. user_addons = user.addons.filter(type=amo.ADDON_WEBAPP).order_by("-created") user_addons = paginate(request, user_addons, per_page=15) paypal_ids = set(user.addons.exclude(paypal_id="").values_list("paypal_id", flat=True)) payment_data = ( AddonPaymentData.objects.filter(addon__authors=user).values(*AddonPaymentData.address_fields()).distinct() ) return jingo.render( request, "lookup/user_summary.html", { "account": user, "app_summary": app_summary, "is_admin": is_admin, "refund_summary": refund_summary, "user_addons": user_addons, "payment_data": payment_data, "paypal_ids": paypal_ids, }, )
def user_summary(request, user_id): user = get_object_or_404(UserProfile, pk=user_id) is_admin = acl.action_allowed(request, "Users", "Edit") app_summary = _app_summary(user.pk) # All refunds that this user has requested (probably as a consumer). req = Refund.objects.filter(contribution__user=user) # All instantly-approved refunds that this user has requested. appr = req.filter(status=amo.REFUND_APPROVED_INSTANT) refund_summary = {"approved": appr.count(), "requested": req.count()} # TODO: This should return all `addon` types and not just webapps. # -- currently get_details_url() fails on non-webapps so this is a # temp fix. user_addons = user.addons.filter(type=amo.ADDON_WEBAPP).order_by("-created") user_addons = paginate(request, user_addons, per_page=15) paypal_ids = set(user.addons.exclude(paypal_id="").values_list("paypal_id", flat=True)) payment_data = ( AddonPaymentData.objects.filter(addon__authors=user).values(*AddonPaymentData.address_fields()).distinct() ) # If the user is deleted, get the log detailing the delete. try: delete_log = ActivityLog.objects.for_user(user).filter(action=amo.LOG.DELETE_USER_LOOKUP.id)[0] except IndexError: delete_log = None provider_portals = get_payment_provider_portals(user=user) return render( request, "lookup/user_summary.html", { "account": user, "app_summary": app_summary, "delete_form": DeleteUserForm(), "delete_log": delete_log, "is_admin": is_admin, "refund_summary": refund_summary, "user_addons": user_addons, "payment_data": payment_data, "paypal_ids": paypal_ids, "provider_portals": provider_portals, }, )
def user_summary(request, user_id): user = get_object_or_404(UserProfile, pk=user_id) is_admin = acl.action_allowed(request, 'Users', 'Edit') app_summary = _app_summary(user.pk) # All refunds that this user has requested (probably as a consumer). req = Refund.objects.filter(contribution__user=user) # All instantly-approved refunds that this user has requested. appr = req.filter(status=amo.REFUND_APPROVED_INSTANT) refund_summary = {'approved': appr.count(), 'requested': req.count()} # TODO: This should return all `addon` types and not just webapps. # -- currently get_details_url() fails on non-webapps so this is a # temp fix. user_addons = (user.addons.filter( type=amo.ADDON_WEBAPP).order_by('-created')) user_addons = paginate(request, user_addons, per_page=15) paypal_ids = set( user.addons.exclude(paypal_id='').values_list('paypal_id', flat=True)) payment_data = (AddonPaymentData.objects.filter( addon__authors=user).values( *AddonPaymentData.address_fields()).distinct()) # If the user is deleted, get the log detailing the delete. try: delete_log = ActivityLog.objects.for_user(user).filter( action=amo.LOG.DELETE_USER_LOOKUP.id)[0] except IndexError: delete_log = None payment_accounts = user.paymentaccount_set.all() return render( request, 'lookup/user_summary.html', { 'account': user, 'app_summary': app_summary, 'delete_form': DeleteUserForm(), 'delete_log': delete_log, 'is_admin': is_admin, 'refund_summary': refund_summary, 'user_addons': user_addons, 'payment_data': payment_data, 'paypal_ids': paypal_ids, 'payment_accounts': payment_accounts })
def user_summary(request, user_id): user = get_object_or_404(UserProfile, pk=user_id) is_admin = acl.action_allowed(request, 'Users', 'Edit') app_summary = _app_summary(user.pk) # All refunds that this user has requested (probably as a consumer). req = Refund.objects.filter(contribution__user=user) # All instantly-approved refunds that this user has requested. appr = req.filter(status=amo.REFUND_APPROVED_INSTANT) refund_summary = {'approved': appr.count(), 'requested': req.count()} # TODO: This should return all `addon` types and not just webapps. # -- currently get_details_url() fails on non-webapps so this is a # temp fix. user_addons = (user.addons.filter(type=amo.ADDON_WEBAPP) .order_by('-created')) user_addons = paginate(request, user_addons, per_page=15) paypal_ids = set(user.addons.exclude(paypal_id='') .values_list('paypal_id', flat=True)) payment_data = (AddonPaymentData.objects.filter(addon__authors=user) .values(*AddonPaymentData.address_fields()) .distinct()) # If the user is deleted, get the log detailing the delete. try: delete_log = ActivityLog.objects.for_user(user).filter( action=amo.LOG.DELETE_USER_LOOKUP.id)[0] except IndexError: delete_log = None payment_accounts = user.paymentaccount_set.all() return render(request, 'lookup/user_summary.html', {'account': user, 'app_summary': app_summary, 'delete_form': DeleteUserForm(), 'delete_log': delete_log, 'is_admin': is_admin, 'refund_summary': refund_summary, 'user_addons': user_addons, 'payment_data': payment_data, 'paypal_ids': paypal_ids, 'payment_accounts': payment_accounts})