(request, domain)
return {"sms_contacts": contacts}
A helper view for sms autocomplete
A helper view for sms autocomplete
A helper view for sms autocomplete
def get_sms_autocomplete_context(request, domain):
    """A helper view for sms autocomplete"""
    phone_users = CouchUser.view("users/phone_users_by_domain",
        startkey=[domain], endkey=[domain, {}], include_docs=True
    )
    groups = Group.by_domain(domain)

    contacts = ["[send to all]"]
    contacts.extend(['%s [group]' % group.name for group in groups])
    user_id = None
    for user in phone_users:
        if user._id == user_id:
            continue
        contacts.append(user.username)
        user_id = user._id
    return {"sms_contacts": contacts}
def get_sms_autocomplete_context ( request , domain ) : phone_users = CouchUser . view ( "users/phone_users_by_domain" , startkey = [ domain ] , endkey = [ domain , { } ] , include_docs = True ) groups = Group . by_domain ( domain ) contacts = [ "[send to all]" ] contacts . extend ( [ '%s [group]' % group . name for group in groups ] ) user_id = None for user in phone_users : if user . _id == user_id : continue contacts . append ( user . username ) user_id = user . _id return { "sms_contacts" : contacts }