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=mkt.REFUND_APPROVED_INSTANT) refund_summary = {'approved': appr.count(), 'requested': req.count()} user_addons = user.addons.order_by('-created') user_addons = paginate(request, user_addons, per_page=15) 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=mkt.LOG.DELETE_USER_LOOKUP.id)[0] except IndexError: delete_log = None group_membership_formset = APIGroupMembershipFormSet() 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, 'provider_portals': provider_portals, 'group_membership_formset': group_membership_formset})
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) 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, '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()} user_addons = user.addons.order_by("-created") user_addons = paginate(request, user_addons, per_page=15) 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, "provider_portals": provider_portals, }, )