示例#1
0
    def put(self):
        try:
            payload = json.loads(request.data.decode())
            user_name = payload["user_name"]
            user_gmail = payload["user_gmail"]
            user_phone = payload["user_phone"]
            user_bdate = payload["user_bdate"]
            user_password = payload["user_password"]
            user_pin = payload["user_pin"]
            user_photo_url = payload["user_photo_url"]

            database.updateUser(user_name, user_gmail, user_phone, user_bdate,
                                user_password, user_pin, user_photo_url)
            return make_response(
                jsonify({
                    'title': "User updated Successfully",
                    "status": HTTPStatus.OK
                }),
                HTTPStatus.OK,
            )

        except Exception as e:
            return make_response(
                jsonify({
                    'title': "Unsuccessful from user updation",
                    "status": HTTPStatus.BAD_REQUEST,
                    "error": {
                        "message": str(e)
                    }
                }),
                HTTPStatus.BAD_REQUEST,
            )
示例#2
0
def manage():
    order = request.args.get("order")

    if request.method == "POST":
        x = request.form.get("username")
        y = request.form.get("displayName")
        z = request.form.get("password")
        w = request.form.get("rank")
        with database.connect() as conn:
            database.updateUser(conn, x, y, z, w)
        return jsonify((x, y, z, w))

    with database.connect() as conn:
        users = database.getAllUsers(conn, order)

    if order == "username":
        order = "Username"
    elif order == "displayName":
        order = "Display name"
    elif order == "password":
        order == "Password"
    elif order == "rank":
        order = "Rank"

    global user
    global ranks
    return render_template("manage.html",
                           users=users,
                           order=order,
                           ranks=ranks,
                           tab="manage",
                           user=user)
示例#3
0
 def addUserInfo(self, newUserInfo, ownerTaobaoId, max_acceptable_price):
     # Don't buy the item from yourself.
     if ownerTaobaoId == newUserInfo.taobaoId:
         return
     
     if newUserInfo.buyer_payment > max_acceptable_price:
         return
     
     # If the userInfo exists, below is the logic which allow to continue. Otherwise just return, don't add userInfo anymore.
     userInfo = database.getActiveUserByTaobaoId(newUserInfo.taobaoId)
     if userInfo:
         # Succeed buy/Confirmed order and the last status time more than 31 days will allow to continue.
         if (userInfo.status == UserInfo.Status_Succeed_Buy or userInfo.status == UserInfo.Status_Confirmed_Payment):
             if (datetime.now() - userInfo.last_status_time).days < 31:
                 return
         # NotTo buy and the last status time more than 6 days will allow to continue.
         elif userInfo.status == UserInfo.Status_NotTo_Buy:
             if (datetime.now() - userInfo.last_status_time).days < 6:
                 return
         # Failed buy and the last status time more than 1 days will allow to continue.
         elif userInfo.status == UserInfo.Status_Failed_Buy:
             if (datetime.now() - userInfo.last_status_time).days < 1:
                 return
         elif userInfo.status == UserInfo.Status_RETRY:
             pass
         else:
             return
         database.updateUser(userInfo, active = 0)
     database.saveUser(newUserInfo)
	def addSite(self):
		if self.currentUrl != None:
			parts = self.currentUrl.data.split('.')
			siteInfo = parts[1] + ' ' + self.currentUrl.data
			if siteInfo not in self.websites:
				database.updateUser(self.name, siteInfo)
				self.websites.append(siteInfo)	
				self.websitesDictionary[parts[1]] = self.currentUrl.data
示例#5
0
def parsePreference(jpost):
	if not isValid_Preference(jpost):
		# print "Preferred Times update went wrong. Not updated."
		return False

	netid = jpost["netid"]
	preferredTimes = str(jpost["preferredTimes"])

	db.updateUser(netid, preferredTimes=preferredTimes)
	return True
示例#6
0
 def update_user(mainself, id):
     import database
     from PyQt5.QtWidgets import QMessageBox
     try:
         user = database.getUserByid(id)
         if user[0][4] == 'admin':
             reply = QMessageBox.critical(
                 mainself, 'Message', '<font color="black">无权限修改管理员资料!',
                 QMessageBox.Ok, QMessageBox.Ok)
             mainself.inituser_manage_table()
             return
         else:
             row = mainself.user_manage.rowCount()
             userinfo = []
             for r in range(row):
                 if mainself.user_manage.item(r, 0).text() == str(id):
                     for i in range(1, 6):
                         userinfo.append(
                             mainself.user_manage.item(r, i).text())
                     print(userinfo)
                     break
             res = database.updateUser(userinfo, id)
     except:
         reply = QMessageBox.critical(mainself, 'Message',
                                      '<font color="black">数据更新失败!',
                                      QMessageBox.Ok, QMessageBox.Ok)
         print("update user catch exception")
     else:
         reply = QMessageBox.information(mainself, 'Message',
                                         '<font color="black">数据修改成功!',
                                         QMessageBox.Ok, QMessageBox.Ok)
     finally:
         mainself.inituser_manage_table()
示例#7
0
def save_changes():
    username = request.form["username"]
    password = request.form["password"]
    email = request.form["email"]
    sessionhash = session.get('hash')
    if database.updateUser(username, password, email, sessionhash):
        return redirect("/profile", code=302)
    else:
        return "Fehler."
示例#8
0
def findDetails(message, userid):
    details_found = False
    userdata = database.getUserData(userid)
    message = message.decode('unicode-escape')
    reg = re.compile("[a-zA-Z0-9._-]*@[a-zA-Z0-9._-]*")
    emails = reg.findall(message)
    for email in emails:
        print(email)
        if userdata.get("email", False) == False:
            details_found = True
            database.updateUser(userid, {"email": email})
            print(email)
    reg = re.compile("([0-9]{4} [0-9]{3} [0-9]{3})")
    phones = reg.findall(message)
    if len(phones) == 0:
        reg = re.compile("([0-9]{10})")
        phones = reg.findall(message)
    for phone in phones:
        phone = phone.replace(" ", "")
        if userdata.get("phone", False) == False:
            details_found = True
            database.updateUser(userid, {"phone": phone})
    return details_found
def put_user(id):
    # Check if specified ID is an integer
    if not function.isInt(id):
        return jsonify({"error": "id is not an integer"}), 400

    # Check if token identity corresponds to the user being updated
    if not (int(id) == get_jwt_identity()):
        return jsonify(
            {"error": "Not allowed to update this users information"}), 403

    # Fetch form data
    userDetails = request.get_json()
    name = userDetails.get('name')
    password = userDetails.get('password')

    # Check if all data is supplied
    if name is None:
        return jsonify({"error": "Username not specified"}), 400
    if password is None:
        return jsonify({"error": "Password not specified"}), 400

    # Check if user actually exists
    user = database.getUserByID(id)
    if user is None:
        return jsonify({"error": "Specified user does not exist"})

    # Check is username and password comply to the requirements
    username_message = function.check_username(name)
    password_message = function.check_password(password)
    if (username_message is not "ok"):
        return jsonify({"error": username_message}), 400
    elif (password_message is not "ok"):
        return jsonify({"error": password_message}), 400

    # Hash the userpassword for secure storage
    hashedpass = function.hash_password(password)

    data = database.updateUser(id, name, hashedpass)
    if data is not None:
        return jsonify(data), 200
    else:
        return jsonify({"error": "No results found"}), 404
示例#10
0
def jsonListener():
    while(True):
        res = request_data()
        database.updateUser(res['user'])
 def put(self):
     dataDict = json.loads(request.data)
     uid = request.args.get('user_id')
     data = updateUser(uid, dataDict)
     return 200
示例#12
0
assert rsp1.preferredTimes == sample1
assert rsp2.preferredTimes == sample1
assert rsp3.preferredTimes == sample2

assert rsp4.preferredTimes == sample2
assert rsp5.preferredTimes == sample2

assert rsp6.preferredTimes == sample3
assert rsp7.preferredTimes == sample3
assert rsp8.preferredTimes == sample3

## Update a user, check if it worked ##############################################################


db.updateUser('hsolis', 'Tear', 'Swag', pref2, \
	sample3, sample4)

hector = db.getUser('hsolis')

assert hector.uid == 1 and hector.firstName == 'Tear' and \
	hector.lastName == 'Swag' and hector.preferredTimes == pref2 \
	and hector.acceptableTimes == sample3 and \
	hector.unacceptableTimes == sample4

db.updateUser(netid='hsolis', firstName='Hector', lastName='Solis')

hector = db.getUser('hsolis')

assert hector.uid == 1 and hector.firstName == 'Hector' and \
	hector.lastName == 'Solis' and hector.preferredTimes == pref2 \
	and hector.acceptableTimes == sample3 and \
示例#13
0
 def setUserInfoStatus(self, userInfo, status):
     database.updateUser(userInfo, status = status, last_status_time = datetime.now())