Beispiel #1
0
def list_associations():
    if not g.user:
        abort(401)
    associations = Association.find_all_for_user(g.user)
    if associations:
        return render_template('list_associations.html.jinja',
                               associations=associations)
    else:
        return redirect(url_for('new_association'))
Beispiel #2
0
    def test_find_all_for_user(self):
        session = Client().session()
        prancing_ponies = Association(name='prancing ponies')
        watercooler = Association(name='watercooler')
        rtk = Association(name='rtk')
        session.add(prancing_ponies)
        session.add(watercooler)
        session.add(rtk)

        user = User(email="*****@*****.**")
        session.add(user)
        session.flush()

        session.add(UserAssociation(
            association_id=prancing_ponies.association_id,
            user_id=user.user_id))
        session.add(UserAssociation(
            association_id=watercooler.association_id,
            user_id=user.user_id))
        session.flush()

        associations = Association.find_all_for_user(user)

        eq_(associations, [prancing_ponies, watercooler])