Example #1
0
def get_current_transaction(user):
    db = Database(os.environ["SCHEMA"]).get_schema()
    transactions = db.transactions.find({
        "sender": user["id"],
        "status": {
            "$gte": 2,
            "$lte": 3
        }
    })
    ccurr_transaction = {"status": 0, "observation": "Not Transaction found"}
    if transactions is None:
        return ccurr_transaction

    for transaction in transactions:
        print(transaction)
        transactionTime = datetime.now() - transaction["status-date"]
        print(transactionTime.seconds)
        if transactionTime.seconds > 180:
            db.transactions.update({"_id": ObjectId(transaction["_id"])},
                                   {"$set": {
                                       "status": 0
                                   }})
        else:
            return transaction

    return ccurr_transaction
Example #2
0
def create_user_card(user, event):
    event.update("PRO", datetime.now(), "Processing validate_user_document")
    db = Database("venny").get_schema()
    user = db.users.find_one({"id": user["id"]})
    account = db.accountPool.find_one({"_id": user["accountId"]})
    headers = {"Content-Type": "application/json"}
    img_proc_url = os.environ["IMG_PROC"] + os.environ["FACES_API"] + "card"
    data = {
        "firstName": user["first_name"],
        "lastName": user["last_name"],
        "account": account["cardNumber"],
        "faceId": user["faceId"]
    }
    return requests.post(url=img_proc_url,
                         headers=headers,
                         data=json.dumps(data))
Example #3
0
	def __init__(self, subm):
		"""
		subm : class
			The class subm is defined in objects.Submission and has the 
			following fields as attributes:
				- reference_code 	- title  	- authors  	- affils
				- contact 			- text 		- ref 		- figurl
				- table 			- caption
		"""

		self.subm = subm



tex = Texparse()
db = Database()


def post_get(name, default=''):
    return bottle.request.forms.get(name)


def skeleton(hook, layout='front', var=None):
    return bottle.template(
        layout,
        content=hook,
        header=bottle.template('header', hook=Conference()),
        var=var
    )