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

    return code_id
Example #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!."))
Example #3
0
    def get(self):
        if not self.request.get("trans_id"):
            self.tv["current_page"] = "TRANSACTION"
            self.tv["trans_id"] = get_trans_id()
            self.render("frontend/transactionpage.html")
            return

        self.tv["current_page"] = "TRANSACTION DETAILS"
        trans_id = self.request.get("trans_id")
        trans = Transaction.get_by_id(trans_id)

        parcel = P.query(P.trans_key == trans.key.urlsafe()).fetch(1)

        self.tv["parcel_code"] = parcel[0].codes
        self.tv["transaction"] = trans.to_object()
        self.render("frontend/trans-details.html")