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)
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"))
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)
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
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")
def getById(self, id): with get_session() as session: obj = session.query(LotusAccountModel).get(id) return obj
def add(self, lotus_account_model): with get_session() as session: session.add(lotus_account_model) session.commit() return True
def getList(self): with get_session() as session: obj = session.query(LotusAccountModel).all() return obj
def get_user_by_id(self, user_id): with get_session() as session: obj = session.query(LotusUserModel).get(user_id) return obj
def add(self, user_model): with get_session() as session: session.add(user_model) return user_model
def add(self, attach_model): with get_session() as session: session.add(attach_model) session.commit() return attach_model
def getById(self, attach_id): with get_session() as session: obj = session.query(AttachModel).get(attach_id) return obj