Example #1
0
def ticketmaker():
    form = TicketForm()
    if form.is_submitted():
        ticket = {}
        result = request.form
        print(result)
        alph = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        ticket["FID"] = rd.choice(alph) + rd.choice(alph) + rd.choice(
            alph) + str(random_with_N_digits(4))
        ticket["lastname"] = result["name"].split(" ")[1].upper()
        ticket["firstname"] = result["name"].split(" ")[0].upper()
        ticket["namecode"] = str(
            random_with_N_digits(5)) + "-" + ticket["lastname"]
        img = qrcode.make(ticket["namecode"])
        img.save(f"{os.getcwd()}/static/images/pict0.png", "PNG")
        if result["radio"] == "bills":
            ticket["bills"] = "X"
        else:
            ticket["coins"] = "X"
        ticket["money"] = format(float(result["money"]), '.2f')
        ticket["date"] = convertdate(result["date"]).upper()
        return render_template("tooth_ticket.html",
                               result=result,
                               ticket=ticket)
    return render_template("make_ticket.html", form=form)