def getcard(uid): if request.method == "GET": cardManager = CardManager() card = cardManager.getCardByUid(uid) if card: card["result_code"] = 1 return json.dumps(card, ensure_ascii=False) else: return str({"result_code" : 0})
def card(uid): myuid = session["uid"] cardManager = CardManager() card = cardManager.getCardByUid(uid) if(uid == myuid): error = request.args.get("error", "") if card == None: card = {"uid": uid, "name" : "", "info" : "", "email" : "", "phone" : "" } return render_template("mycard.html", card=card, error=error) else: if card: return render_template("card.html", card=card) else: return "false"
def setcard(): if request.method == "POST": cardManager = CardManager() uid = session["uid"] name = request.form["name"] info = request.form["info"] phone = request.form["phone"] email = request.form["email"] card = cardManager.getCardByUid(uid) error = "" if(cardManager.getCardByUid(uid)): cardManager.updateCard(uid, name, info, phone, email) else: if not cardManager.insertCard(uid, name, info, phone, email): error = u"编辑失败" if error: flash(error) return "false" return "true"
def editcard(): uid = session["uid"] cardManager = CardManager() card = cardManager.getCardByUid(uid) return render_template("edit.html", card=card)