Beispiel #1
0
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)
Beispiel #2
0
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)