def async_contact_search(part): try: g.user.username except AttributeError: abort(401) c = Contacts(redis=g.r, user=g.user) return json.dumps(c.search(part))
def del_contact(contact, redirect_url=None): try: g.user.username except AttributeError: abort(401) c = Contacts(redis=g.r, user=g.user) c.delete(contact) t = g.user.timeline t.rebuild() flash('Deleted contact "%s".' % contact, 'success') if not redirect_url: redirect_url = url_for('frontend.contacts') return redirect(redirect_url)
def add_contact(contact, redirect_url=None): try: g.user.username except AttributeError: abort(401) try: c = Contacts(redis=g.r, user=g.user) c.add(contact) flash('Added user "%s" to address book.' % contact, 'success') except KeyError: flash('No user specified.', 'error') except ContactInvalidError: flash('User "%s" does not exist.' % contact, 'error') except ContactExistsError: flash('User "%s" is already in your address book.' % contact, 'error') t = g.user.timeline t.rebuild() if not redirect_url: redirect_url = url_for('frontend.contacts') return redirect(redirect_url)