def get_payment_provider_portals(app=None, user=None):
 provider_portals = []
 if app:
  q = dict(addon=app)
 elif user:
  q = dict(payment_account__user=user)
 else:
  raise ValueError('user or app is required')
 for acct in AddonPaymentAccount.objects.filter(**q).select_related('payment_account'):
  provider = get_provider(id=acct.payment_account.provider)
  portal_url = provider.get_portal_url(acct.addon.app_slug)
  if portal_url:
   provider_portals.append({'provider': provider, 'app': acct.addon, 'portal_url': portal_url, 'payment_account': acct.payment_account})
 return provider_portals

def get_payment_provider_portals ( app = None , user = None ) : provider_portals = [ ] if app : q = dict ( addon = app ) elif user : q = dict ( payment_account__user = user ) else : raise ValueError ( 'user or app is required' ) for acct in AddonPaymentAccount . objects . filter ( ** q ) . select_related ( 'payment_account' ) : provider = get_provider ( id = acct . payment_account . provider ) portal_url = provider . get_portal_url ( acct . addon . app_slug ) if portal_url : provider_portals . append ( { 'provider' : provider , 'app' : acct . addon , 'portal_url' : portal_url , 'payment_account' : acct . payment_account } ) return provider_portals
get a list of dicts describing the payment portals for this app or user .