Пример #1
0
 def get_intention_id_list(self, id_list):
     with get_session() as session:
         sql = """SELECT lu.nickname,lu.head_photo_path,lu.sex,lu.age
                     FROM lotus_user lu
                     where id in :id_list
               """
         result_proxy = session.execute(text(sql, id_list=tuple(id_list)))
         results = result_proxy.fetchall()
     return zip_sql_result(results)
Пример #2
0
 def check(*args, **kwargs):
     print("entered")
     if ('key' in session):
         username = get_session(session.get('key'))
         if (username):
             role = get_user_role(username)
             return f(username, role, *args, **kwargs)
         else:
             return redirect(url_for("login"))
     else:
         return redirect(url_for("login"))
Пример #3
0
 def get_intention_id_list(self, intention_model):
     with get_session() as session:
         sql = """SELECT lu.nickname,lu.head_photo_path,lu.sex,lu.age
                     FROM lotus_user lu
               """
         try:
             result_proxy = session.execute(text(sql))
         except Exception as e:
             print(e)
             results = []
         else:
             results = result_proxy.fetchall()
     return zip_sql_result(results)
Пример #4
0
 def update_user_info(self, user_model):
     with get_session() as session:
         sql = """
                 UPDATE lotus_user lu 
                 SET lu.nickname=:nickname
                 WHERE lu.id=:id
                       """
         try:
             result_proxy = session.execute(sql, user_model)
             result = result_proxy.rowcount
             if result > 0:
                 flag = True
             else:
                 flag = False
         except Exception as e:
             session.rollback()
             flag = False
     return flag
Пример #5
0
def login():
    if ("key" in session):
        username = get_session(session.get("key"))
        if (username):
            return redirect(url_for("upload"))
        else:
            session.clear()
            return render_template("login.html", msg="Please login again!")
    else:
        if (request.method == "POST"):
            username = request.form['name']
            password = request.form['password']
            if (sha256(password.encode()).hexdigest() == get_user_password(
                    username)):
                session.perminent = True
                session['key'] = create_session(username)
                return redirect(url_for("upload"))
            else:
                return render_template("login.html",
                                       error="Invalid password or username")
        else:
            return render_template("login.html")
Пример #6
0
 def getById(self, id):
     with get_session() as session:
         obj = session.query(LotusAccountModel).get(id)
     return obj
Пример #7
0
 def add(self, lotus_account_model):
     with get_session() as session:
         session.add(lotus_account_model)
         session.commit()
     return True
Пример #8
0
 def getList(self):
     with get_session() as session:
         obj = session.query(LotusAccountModel).all()
     return obj
Пример #9
0
 def get_user_by_id(self, user_id):
     with get_session() as session:
         obj = session.query(LotusUserModel).get(user_id)
     return obj
Пример #10
0
 def add(self, user_model):
     with get_session() as session:
         session.add(user_model)
     return user_model
Пример #11
0
 def add(self, attach_model):
     with get_session() as session:
         session.add(attach_model)
         session.commit()
     return attach_model
Пример #12
0
 def getById(self, attach_id):
     with get_session() as session:
         obj = session.query(AttachModel).get(attach_id)
     return obj