Example #1
0
 def get_user(self, _userID):
     con = None
     try:
         con = self.database_connector
         with con:
             con.rollback()
             cur = con.cursor()
             cur.execute("SELECT * FROM user WHERE userID = ?", (_userID,))
             con.commit()
             single_user_data = cur.fetchone()
             if single_user_data != None:
                 return user_bean(single_user_data[1],single_user_data[2], single_user_data[3], single_user_data[4], single_user_data[5], single_user_data[6], single_user_data[0])
             return single_user_data
     except lite.Error, e:
         return False,str(e)
Example #2
0
 def get_all_users(self):
     con = None
     try:
         con = self.database_connector
         with con:
             con.rollback()
             cur = con.cursor()
             cur.execute("SELECT * FROM user")
             con.commit()
             multiple_user_data = cur.fetchall()
             user_list = []
             for user in multiple_user_data:
                 user_list.append(user_bean(user[1],user[2],user[3],user[4],user[5],user[6],user[0]))
             return user_list
     except lite.Error, e:
         return str(e)
Example #3
0
 def get_registered_user(self, _username, _password):
     con = None
     try:
         con = self.database_connector
         with con:
             con.rollback()
             cur = con.cursor()
             cur.execute("SELECT * FROM user WHERE username = ? AND password = ?", (_username,_password))
             con.commit()
             single_user_data = cur.fetchone()
             #print single_user_data
             if single_user_data != None:
                 return user_bean(single_user_data[1],single_user_data[2], single_user_data[3], single_user_data[4], single_user_data[5], single_user_data[6], single_user_data[0])
             return single_user_data
     except lite.Error, e:
         return False,str(e)
Example #4
0
def register_new_user():
    first_name = request.form["first_name"]
    last_name = request.form["last_name"]
    username = request.form["username"]
    email = request.form["email"]
    password = request.form["password"]
    results = factory.get_user_dao().add_new_user(
        user_bean(
            first_name,
            last_name,
            time.strftime("%m/%d/%Y"),
            email,
            username,
            hashlib.sha256(password.encode()).hexdigest(),
        )
    )
    if False not in results:
        factory.get_user_info_dao().add_new_user_info(user_info_bean("", "", "", ""))
    return_message = results[1]
    return_error = not results[0]
    return render_template("index.html", message=return_message, error=return_error)
    def setUp(self):
        global factory 
        global example_user_1
        factory = dao_factory.get_instance(life_score_test_database)
        example_user_1 = user_bean("Gregory","Daniels","*****@*****.**", "Papa2k15", "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8")
        try:
            con = lite.connect(life_score_test_database)
            with con:
                cur = con.cursor()
                cur.executescript(
                    """
                    DROP TABLE IF EXISTS "user";

                    CREATE TABLE "user" (
                    `userID`    INTEGER UNIQUE,
                    `name`    TEXT NOT NULL,
                    `username`    TEXT NOT NULL,
                    `email`    TEXT NOT NULL,
                    `password`    TEXT NOT NULL,
                    PRIMARY KEY(userID)
                    )""")
                con.commit()
        except lite.Error, e:
            return str(e)