Exemplo n.º 1
0
def test_users():
    for d in UNIQUE_USERS:
        user = User()
        user.first_name = d[0]
        user.last_name = d[1]
        user.email = d[2]
        user.access = d[3]
        user.salcie = d[4]
        user.incie = d[5]
        user.mucie = d[6]
        user.is_active = True
        user.set_password(user.first_name)
        db.session.add(user)
        db.session.commit()
    for i, d in enumerate(USERS):
        user = User()
        user.first_name = f"{d[0]}{i}"
        user.last_name = d[1]
        user.email = f"{user.first_name}{d[2]}"
        user.access = d[3]
        user.salcie = d[4]
        user.incie = d[5]
        user.mucie = d[6]
        user.is_active = True
        user.set_password(user.first_name)
        db.session.add(user)
        db.session.commit()
Exemplo n.º 2
0
 def create_admin(email, password, first_name, last_name):
     a = User()
     a.email = email
     a.set_password(password)
     a.access = values.AL_ADMIN
     a.is_active = True
     a.first_name = first_name
     a.last_name = last_name
     db.session.add(a)
     db.session.commit()
Exemplo n.º 3
0
 def create_admin(email, password, first_name, last_name, incie=False, salcie=False, mucie=False):
     if len(User.query.filter(User.access == values.ACCESS[values.ADMIN]).all()) == 0:
         a = User()
         a.email = email
         a.set_password(password)
         a.access = values.ACCESS[values.ADMIN]
         a.is_active = True
         a.first_name = first_name
         a.last_name = last_name
         a.incie = incie
         a.salcie = salcie
         a.mucie = mucie
         db.session.add(a)
         db.session.commit()
Exemplo n.º 4
0
def create():
    form = json.loads(request.data)
    u = User.query.filter(User.email.ilike(form["email"])).first()
    if u is None:
        u = User()
        u.first_name = form["first_name"]
        u.last_name = form["last_name"]
        u.email = form["email"]
        u.access = form["account"]
        u.auth_code = auth_token()
        db.session.add(u)
        db.session.commit()
        send_account_activation_email(u)
        return OK
    return BAD_REQUEST
Exemplo n.º 5
0
def create():
    form = json.loads(request.data)
    u = User.query.filter(User.email.ilike(form["email"])).first()
    if u is None:
        u = User()
        u.first_name = form["first_name"]
        u.last_name = form["last_name"]
        u.email = form["email"]
        u.incie = form["incie"]
        u.salcie = form["salcie"]
        u.mucie = form["mucie"]
        u.access = form["account"]
        u.auth_code = auth_token()
        db.session.add(u)
        db.session.commit()
        send_account_activation_email(u)
        return jsonify(u.created())
    return json_error("Email address already in use.")