def dbchangepwd(): pwd = request.json loginuser = session.get('loginUser') userinfo = Users.query.filter(Users.user_no == loginuser['userid']).first() print(">>>>>>>>>>>>>>", pwd['pwd']) u = Users(userinfo.email, pwd['pwd'], userinfo.name, userinfo.phone_number, userinfo.nickname, userinfo.address) u.user_no = loginuser["userid"] # u.email = userinfo.email # u.password = pwd # u.name = userinfo.name # u.phone_number = userinfo.phone_number # u.nickname = userinfo.nickname # u.address = userinfo.address print(u) try: db_session.merge(u) db_session.commit() except Exception as err: print(err) db_session.rollback() if "Duplicate" in str(err): data = {} data['error'] = 'error' return jsonify(data) return jsonify("OK")
def editmemolist(userid, id): req = request.json userid = session['loginUser']['userid'] name = req['name'] content = req['content'] print("name>>", name, "content>>", content) memo = Memo(userid, name, content) memo.id = id try: db_session.merge(memo) db_session.commit() print("Update Success!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") return jsonify({'status':'success'}) except Exception as err: db_session.rollback() print("\n \n \n Error!!!!!!!!!!!!!!!!!!!!!!", err) return jsonify({'status':'fail'})
def editchecklist(userid, id): req = request.json userid = session['loginUser']['userid'] name = req['name'] content = ",".join(req['content']) print("name>>", name, "content>>", content) check = Checklist(userid, name, content) print("check>>>>>",check) check.id = id try: db_session.merge(check) db_session.commit() print("Update Success!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") return jsonify({'status':'success'}) except Exception as err: db_session.rollback() print("\n \n \n Error!!!!!!!!!!!!!!!!!!!!!!", err) return jsonify({'status':'fail'})
def edit(userid, id): userid=session['loginUser']['userid'] title = request.form.get('title') print("title>>", title) content = request.form.get('content') print("content>>", content) post = Post(title, content, userid) print(post) post.postid = id try: db_session.merge(post) db_session.commit() print("Update Success!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") return redirect('/posting') except Exception as err: db_session.rollback() print("\n \n \n Error!!!!!!!!!!!!!!!!!!!!!!", err) return render_template('writelayout.htm', title="Revise", userid=userid, postid=id, action="/write/edit/{}/{}".format(userid, id), mode="revision")
def upload(): upfile = request.files['file'] # aa.jpg myalbumid = request.form.get('myalbumid') print("mmmmmmmmmmmmmmmmmm>>", myalbumid) try: filename = upfile.filename.replace('..', '') path = rename(os.path.join("./helloflask/static/upfiles", filename)) upfile.save(path) path = path[12:] myalbum = Myalbum.query.filter("id=:id").params(id=myalbumid).first() myalbum.upfile = path db_session.merge(myalbum) db_session.commit() except SQLAlchemyError as err: db_session.rollback() print("Error >>", err) return jsonify({"path": path})
def mycoms_post(myalbumid): if not session.get('loginUser'): session['next'] = request.url return redirect('/login') loginUser = session.get('loginUser') content = request.form.get('content') cmt = Mycom(myalbumid, loginUser.get('userid'), content) cmt.content = content # cmt.id = 7 print("77777777777777777777777777777777777777777777777>>", cmt.id) try: # db_session.add(cmt) db_session.merge(cmt) db_session.commit() except SQLAlchemyError as err: db_session.rollback() print("Error!!", err) return jsonify({"result": 'OK'})
def sendboard(): all_data = request.json print(all_data) practice_sche = all_data["practice_sche"] perform_sche = all_data["perform_sche"] board_id = all_data["board_id"] userinfo = session.get('loginUser') userid = userinfo["userid"] title = all_data['title'] # duedate = all_data['duedate'] money = all_data['money'] practice = all_data['practice_time'] perform = all_data['perform_time'] prac_address = all_data['practice_address'] perf_address = all_data['perform_address'] detail_textarea = all_data['detail_info'] song_textarea = all_data['song_info'] costume = all_data['costume'] qualification = all_data["qualification"] gender = all_data["gen"] instruments = all_data["instruments"] practice_mapx = all_data["practice_mapx"] practice_mapy = all_data["practice_mapy"] perform_mapx = all_data["perform_mapx"] perform_mapy = all_data["perform_mapy"] isdone = 0 area_number = check_area(perf_address) print(title, money, practice, perform, prac_address, perf_address, detail_textarea, song_textarea, costume, qualification, gender, instruments, practice_mapx, practice_mapy, perform_mapx, perform_mapy, area_number) if (board_id != ""): b = Board(title, qualification, gender, money, practice_sche, practice, perform_sche, perform, costume, prac_address, practice_mapx, practice_mapy, perf_address, area_number, perform_mapx, perform_mapy, detail_textarea, song_textarea, userid, isdone) b.board_id = board_id try: db_session.merge(b) BoardInstrument.query.filter(BoardInstrument.id > 0).filter( BoardInstrument.board_id == board_id).delete() for j in instruments: iid = j['iid'] person = j['person'] inst = BoardInstrument(b.board_id, iid, person) db_session.merge(inst) db_session.commit() # inst = BoardInstrument(b.board_id, instruments.in) except Exception as err: print(err) db_session.rollback() return str(b.board_id) else: b = Board(title, qualification, gender, money, practice_sche, practice, perform_sche, perform, costume, prac_address, practice_mapx, practice_mapy, perf_address, area_number, perform_mapx, perform_mapy, detail_textarea, song_textarea, userid, isdone) print("else>>>>") try: db_session.add(b) db_session.commit() for j in instruments: iid = j['iid'] person = j['person'] inst = BoardInstrument(b.board_id, iid, person) db_session.add(inst) db_session.commit() except Exception as err: print(err) db_session.rollback() return str(b.board_id)