Exemplo n.º 1
0
def ConfirmManufacturerRegistration():
    Errors ={"Name": 0, "Email": 0, "Password": 0}
    Failure = False
    g.db_cursor.execute("SELECT Email FROM Manufacturers WHERE Email='"+request.form["Email"]+"';")
    if g.db_cursor.fetchone()!=None:
        Errors["Email"] = " already registered"
        Failure = True
    if request.form["Password"]!=request.form["Password2"]:
        Errors["Password"] = "******"
        Failure = True
    if len(request.form["Name"])<3:
        Errors["Name"] = " - too short"
        Failure = True
    if len(request.form["Password"])<6:
        Errors["Password"] = "******"
        Failure = True

    if Failure:
        return render_template("ManufacturerRegistration.html", Errors=Errors)

    Query = "INSERT INTO Manufacturers (Name, Email, Password) VALUES(\
        '"+g.db_escaper(unidecode(request.form["Name"]))+"',\
        '"+g.db_escaper(request.form["Email"])+"',\
        '"+g.db_escaper(request.form["Password"])+"');"
    g.db_cursor.execute(Query)
    
    return render_template("ConfirmManufacturerRegistration.html")
Exemplo n.º 2
0
def ConfirmAddFilament(ManufacturerID):
    Query = "INSERT INTO Filaments (ManufacturerID, MPN, Name, Diameter, Tolerance, Volume, Color, DateAdded, DateModified) VALUES(\
        '"+str(int(request.form["MID"]))+"',\
        '"+g.db_escaper(request.form["MPN"][:128])+"',\
        '"+g.db_escaper(unidecode(request.form["Name"][:128]))+"',\
        '"+str(float(request.form["Diameter"]))+"',\
        '"+str(float(request.form["Tolerance"]))+"',\
        '"+str(float(request.form["Volume"]))+"',\
        '"+g.db_escaper(request.form["Color"])+"',\
        NOW(), NOW());"
    g.db_cursor.execute(Query)

    g.db_cursor.execute("SELECT LAST_INSERT_ID() AS Last;")
    FilamentID = g.db_cursor.fetchone()["Last"]
    return FilamentPage(FilamentID)
Exemplo n.º 3
0
def AddProfileDo(FilamentID):
    FilamentID = str(int(FilamentID))
    Query = "INSERT INTO FilamentProfiles (FilamentID, ProfileDescription, TPrint, TMax, TMin, Tg, TBed, TChamber, Contributor, DateAdded, DateModified) VALUES(\
        '"+FilamentID+"',\
        '"+g.db_escaper(request.form["Description"])+"',\
        '"+str(float(request.form["TPrint"]))+"',\
        '"+str(float(request.form["TMax"]))+"',\
        '"+str(float(request.form["TMin"]))+"',\
        '"+str(float(request.form["Tg"]))+"',\
        '"+str(float(request.form["TBed"]))+"',\
        '"+str(float(request.form["TChamber"]))+"',\
        'Username',\
        NOW(), NOW());"
    g.db_cursor.execute(Query)
    return FilamentPage(FilamentID)
Exemplo n.º 4
0
def add_manufacturer(Name):
    g.db_cursor.execute("INSERT INTO Manufacturers (Name) VALUES('"+g.db_escaper(Name)+"');")
    return render_template("index.html", Manufacturers=g.Manufacturers)