'Return a cloudsearch appropriate query string that restricts
results to only contain results from sr'

@staticmethod
def _restrict_sr(sr):

    if isinstance(sr, MultiReddit):
        if (not sr.sr_ids):
            raise InvalidQuery
        srs = [('sr_id:%s' % sr_id) for sr_id in sr.sr_ids]
        return ('(or    %s)' % '    '.join(srs))
    elif isinstance(sr, DomainSR):
        return ('site:\'"%s"\'' % sr.domain)
    elif isinstance(sr, FriendsSR):
        if ((not c.user_is_loggedin) or (not c.user.friends)):
            raise InvalidQuery
        friend_ids = c.user.friends[:200]
        friends = [("author_fullname:'%s'" % Account._fullname_from_id36(r2utils.to36(id_))) for id_ in friend_ids]
        return ('(or    %s)' % '    '.join(friends))
    elif isinstance(sr, AllMinus):
        if (not sr.exclude_sr_ids):
            raise InvalidQuery
        exclude_srs = [('sr_id:%s' % sr_id) for sr_id in sr.exclude_sr_ids]
        return ('(not    (or    %s))' % '    '.join(exclude_srs))
    elif (not isinstance(sr, FakeSubreddit)):
        return ('sr_id:%s' % sr._id)
    return None
