(app, user, upstream_app_id=None)
Get the upstream url if the user has access
    :param user: couch_user from a request
Get the upstream url if the user has access
    :param user: couch_user from a request
Get the upstream url if the user has access : param user : couch_user from a request
def _get_upstream_url(app, user, upstream_app_id=None):
    """
    Get the upstream url if the user has access
    :param user: couch_user from a request
    """
    if not app.domain_link:
        return None

    is_member_of_local_domain = user.is_member_of(app.domain_link.master_domain) and not app.domain_link.is_remote
    user_has_access = is_member_of_local_domain or user.is_superuser

    if user_has_access:
        upstream_app_id = upstream_app_id or app.upstream_app_id
        url = reverse('view_app', args=[app.domain_link.master_domain, upstream_app_id])
        if app.domain_link.is_remote:
            url = '{}{}'.format(app.domain_link.remote_base_url, url)
        return url
def _get_upstream_url ( app , user , upstream_app_id = None ) : if not app . domain_link : return None is_member_of_local_domain = user . is_member_of ( app . domain_link . master_domain ) and not app . domain_link . is_remote user_has_access = is_member_of_local_domain or user . is_superuser if user_has_access : upstream_app_id = upstream_app_id or app . upstream_app_id url = reverse ( 'view_app' , args = [ app . domain_link . master_domain , upstream_app_id ] ) if app . domain_link . is_remote : url = '{}{}' . format ( app . domain_link . remote_base_url , url ) return url