Exemple #1
0
def populateSellerIDParameters(request, parameters={}, version="0"):

    accessToken = getAccessToken(request)

    sellerID = request.GET.get("sellerID", "")
    tokenPayload = get_token_payload(accessToken, "sellerID")
    parameters["isSeller"] = 0
    if "sellerID" in tokenPayload and validate_integer(
            tokenPayload["sellerID"]) and "password" in tokenPayload:
        try:
            sellerPtr = Seller.objects.get(id=int(tokenPayload["sellerID"]),
                                           password=tokenPayload["password"],
                                           delete_status=False)
        except:
            pass
        else:
            parameters["sellersArr"] = [sellerPtr.id]
            parameters["isSeller"] = 1
    elif sellerID != "":
        parameters["sellersArr"] = getArrFromString(sellerID)

    sellerShowOnline = request.GET.get("seller_show_online", "")
    if sellerShowOnline != "" and validate_bool(sellerShowOnline):
        parameters["seller_show_online"] = int(sellerShowOnline)

    return parameters
Exemple #2
0
def populateBuyerIDParameters(request, parameters={}, version="0"):

    accessToken = getAccessToken(request)

    buyerID = request.GET.get("buyerID", "")
    tokenPayload = validateBuyerAccessToken(accessToken)
    parameters["isBuyer"] = 0
    parameters["isBuyerStore"] = 0
    if "buyerID" in tokenPayload:
        parameters["buyersArr"] = [int(tokenPayload["buyerID"])]
        parameters["isBuyer"] = 1
    elif buyerID != "":
        parameters["buyersArr"] = getArrFromString(buyerID)

    storeUrl = request.GET.get("store_url", "")
    try:
        buyerPtr = Buyer.objects.get(store_url=storeUrl,
                                     delete_status=False,
                                     store_active=True)
    except Exception as e:
        pass
    else:
        parameters["buyersArr"] = [buyerPtr.id]
        parameters["isBuyerStore"] = 1

    return parameters
Exemple #3
0
def populateInternalUserIDParameters(request, parameters = {}, version = "0"):
	accessToken = getAccessToken(request)
	tokenPayload = get_token_payload(accessToken, "internaluserID")
	internalUserID = request.GET.get("internaluserID", "")

	parameters["isInternalUser"] = 0
	if "internaluserID" in tokenPayload and validate_integer(tokenPayload["internaluserID"]) and "password" in tokenPayload:
		try:
			internalUserPtr = InternalUser.objects.get(id=int(tokenPayload["internaluserID"]), password=tokenPayload["password"])
		except:
			pass
		else:
			parameters["internalusersArr"] = [internalUserPtr.id]
			parameters["isInternalUser"] = 1
	elif internalUserID != "":
		parameters["internalusersArr"] = getArrFromString(internalUserID)

	return parameters