Esempio n. 1
0
def publish_vote(phone_id, id, db):
    """Publishes vote."""
    user = controller.get_user(db, phone_id)
    try:
        id = int(id)
    except TypeError:
        abort(400, "Invalid vote id")

    if not user:
        abort(400, "Invalid or unregistered phone id")

    vote = controller.publish_vote(db, id, user)
    response.content_type = "application/json"
    return json_encode(vote)
Esempio n. 2
0
                 'Lyndon B. Johnson',
                 'Woodrow Wilson',
                 'Richard M. Nixon',
                 'Warren G. Harding',
                 'Gerald R. Ford',
                 'Calvin Coolidge',
                 'James Carter',
                 'Herbert Hoover',
                 'Ronald Reagan',
                 'Franklin D. Roosevelt',
                 'George H. W. Bush',
                 'Harry S. Truman',
                 'William J. Clinton',
                 'Dwight D. Eisenhower'])
    db.commit()
    controller.publish_vote(db, vote1.id, user1)

    if current_user:
        # create vote for a user
        logger.debug('Creating user vote')
        vote_2 = controller.create_vote(db=db,
            author=current_user,
            title='Color You Like',
            text='Choose any color that suits you best at the moment. FYI, my favorite color is red.',
            is_private=False,
            is_multiple_choice=False,
            start_date=datetime.now() - timedelta(hours=2),
            end_date=datetime.now() + timedelta(hours=10))
        db.commit()

        # create vote options