示例#1
0
def register_user(phone_id, db):
    """Registers user. If user already created, request will be ignored"""
    logging.info("Serving register_user()")
    if controller.get_user(db, phone_id):
        return

    fullname = request.query.fullname
    email = request.query.email
    if not fullname or not email:
        abort(400, "User name or email are not specified in request")

    # TODO: check email
    # TODO: check phone_id
    logging.info(u"Creating new user {0:>s}, {1:>s}, {2:>s}".format(phone_id, fullname, email))
    controller.create_user(db, phone_id, fullname, email)
示例#2
0
def register_post():
    if controller.create_user() == True:
        return jsonify(result="account created")
    else:
        return jsonify(error="account already exists")
示例#3
0
def register_post():
    if controller.create_user() == True:
        return redirect('signin')
    else:
        return render_template("form.html", error="Username already taken")
示例#4
0
        if current_user:
            session.query(User).filter(User.id != current_user.id).delete()
        else:
            session.query(User).delete()
        session.query(Vote).delete()
        session.query(VoteOption).delete()
        session.commit()
    except SQLAlchemyError, e:
        session.rollback()
        raise
    finally:
        session.close()

    # create users
    logger.debug('Creating users')
    user1 = controller.create_user(db, 'test_id_1', 'Barak Obama', '*****@*****.**')
    user2 = controller.create_user(db, 'test_id_2', 'John Smith', '*****@*****.**')
    user3 = controller.create_user(db, 'test_id_3', 'Ivan Petrov', '*****@*****.**')
    db.commit()

    # create vote and options
    logger.debug('Creating vote and options')
    vote1 = controller.create_vote(db=db,
        author=user1,
        title='USA President Election',
        text='Choose new USA president',
        is_private=False,
        is_multiple_choice=False,
        start_date=datetime.now() - timedelta(hours=2),
        end_date=datetime.now() + timedelta(hours=10))
    db.commit()