Beispiel #1
0
def receiver_code():
    while True:
        code_id = ''.join(random.choice(string.digits) for x in range(6))
        trans = R.get_by_id(code_id)
        if not trans:
            break

    return code_id
Beispiel #2
0
    def post(self):
        trans = Transaction(id=self.request.get("trans_code"))
        trans.trans_code = self.request.get("trans_code")

        sender = User.get_by_id(self.request.get("sender_code"))
        trans.sender = sender.key.urlsafe()
        
        receiver = User.get_by_id(self.request.get("receiver_code"))
        trans.receiver = receiver.key.urlsafe()

        trans.description = self.request.get("description")
        logging.critical(self.request.get("eda"))
        date = datetime.datetime.strptime(self.request.get("eda"), '%m/%d/%Y')
        logging.critical(date)
        trans.eda = date
        p_code = ""
        r_code = ""
        while True:
            p_code = parser_code()
            parcel = P.get_by_id(p_code)    
            if not parcel:
                break;

        while True:
            r_code = receiver_code()
            receiver = R.get_by_id(r_code)
            if not receiver:
                break;

        logging.critical(p_code)
        logging.critical(r_code)

        trans.parser_code = hash_code(p_code, "PARSER")
        trans.receiver_code = hash_code(r_code, "RECEIVER")

        trans.put()

        """ save transaction for PARSEL code """
        p = P(id=p_code)
        p.codes = p_code
        p.trans_key = trans.key.urlsafe()
        p.put()
        """ ---------------------------------- """

        """ save transaction for RECEIVER code """
        r = R(id=r_code)
        r.codes = r_code
        r.trans_key = trans.key.urlsafe()
        r.put()
        """ ---------------------------------- """

        self.redirect(self.uri_for('www-login', success="Added!."))
Beispiel #3
0
def send_email_to_receiver(user, trans):
    content = {}
    content['trans'] = trans
    logging.critical(trans["key"])
    parcel = R.query(R.trans_key == trans["key"]).fetch(1)
    content['code'] = parcel[0].codes
    logging.critical(parcel[0].codes)
    
    email = send_email(receiver_name=user["name"],receiver_email=user["email"],subject="Receiver Password",content=content,email_type="receiver_code")

    if email:
        return True
    else:
        return False