Example #1
0
def manual():
    switch_led(4)
    print "DETECTED MANUAL"
    #Manually added
        
    user = User("Manually Added")
    #user = User.query.get(user_id)
    user.forename = request.form['forename']
    user.surname = request.form['surname']
    user.city = request.form['city']
        
    db.session.add(user)
    db.session.commit()
        
    #user_id = user.id
    print "RENDER TEMPLATE"
    return render_template('license_alt.html', user=user)
Example #2
0
def license():
    switch_led(4)
    
    # Check if first letter is % or ;
    # If CA format: lines[0][1:3] = CA
    
    # GET USER ID
    # print("Pretesting for manual")
    # DECODE LICENSE
    data = request.form['license_data']
    
    # print data
    # print data[1:3] == "CA"
    # 
    # print("Testing for manual")
    
    # RECORD data TO MYSQL ANYWAY?

    if data[1:3] == "CA":
        user = User(data)
        
        lines = data.split('\n')
        line_one = lines[0].split('^')

        # # ADDRESS
        user.street = line_one[2].title()
        user.state = lines[0][1:3]
        user.city = line_one[0][3:].title()
        user.zipcode = lines[2][3:8]
        
        #googleImage(user.city)
        
        # NAME
        name = line_one[1].split('$')
        user.forename = name[1].capitalize()
        user.surname = name[0].capitalize()
        if len(name) > 2:
            user.middle_name = name[2].capitalize()
    
        # OTHER DETAILS
        month = int(lines[1][25:27])
        if month > 12: month = 9
        # user.dob = datetime.strptime(lines[1][21:29],"%Y%m%d")
        user.dob = "%s-%02d-%s" % (lines[1][21:25], month, lines[1][27:29])
        if lines[2][30:31] == 'M':
            user.gender = 'Male'
        else: user.gender = 'Female'
        user.height = int(lines[2][31])*12 + int(lines[2][32:34])
        user.weight = lines[2][34:37]
        user.hair = lines[2][37:40]
        user.eyes = lines[2][40:43]
        user.drivers_license = lines[1][9:16]
        
        db.session.add(user)
        db.session.commit()
        
        return render_template('license.html', user=user)
    else:
        switch_led(3)
        # TODO: Fall back if not read correctly?
        
        return render_template('manual.html')