def regist_post(): username = request.form.get('username') pw = request.form.get('pw') pw2 = request.form.get('pw2') birthyear = request.form.get('birthyear') birthmonth = request.form.get('birthmonth') birthday = request.form.get('birthday') birthdate = birthyear + getzero(birthmonth) + getzero(birthday) sidogun = request.form.get('sidogun') city = request.form.get('city') addr = sidogun + ' ' + city gender = request.form.get('gender') job = request.form.get('job') email = request.form.get('email') img = None u = Users(username, generate_password_hash(pw), birthdate, addr, gender, job, email, img) try: db_session.add(u) db_session.commit() flash("%s 님, 가입을 환영합니다!" % username) except Exception as err: print("Error on users>>>", err) db_session.rollback() return redirect('/boo')
def comment_post(): global user u = Users.query.filter(Users.username == user).first() list_id = request.values.get('list_id') cmt_txt = request.values.get('cmt_txt') (cmt_date, cmt_like, cmt_hate) = (None, None, None) c = Cmt(u.userno, cmt_txt, cmt_date, list_id, cmt_like, cmt_hate) try: db_session.add(c) db_session.commit() except Exception as err: print("Error on users>>>", err) db_session.rollback() return redirect('/boo')
def follow_post(): username = request.values.get('user') following = request.values.get('following') host = Users.query.filter(Users.username == username).first() guest = Users.query.filter(Users.username == following).first() f = Follow(host.userno, guest.userno) try: db_session.add(f) db_session.commit() except Exception as err: print("Error on users>>>", err) db_session.rollback() rd = 'boo/mypage/' + username return redirect(rd)
def write(): global user list_title = request.form.get('list_title') list_txt = request.form.get('list_txt') public = request.form.get('public') (cmt_count, like_cnt, hate_cnt, list_date, isdelete) = (None, None, None, None, None) lid = request.form.get('editId') u = Users.query.filter(Users.username == user).first() lists = Lists(u.userno, list_title, list_txt, cmt_count, like_cnt, hate_cnt, public, list_date, isdelete) l = Lists.query.filter(Lists.list_id == lid).first() print('#########', 'lid====', lid) print('@@@@@@@@@', l) try: if l == None: db_session.add(lists) else: l.list_title = list_title l.list_txt = list_txt if public == 0: l.public = 0 else: l.public = 1 db_session.commit() except Exception as err: print("Error on users>>>", err) db_session.rollback() return redirect('/boo')