adds device handling functionality from the browser
This commit is contained in:
@ -51,16 +51,30 @@ def view():
|
||||
def devices():
|
||||
if not current_user.is_authenticated:
|
||||
return flask.render_template('login.html')
|
||||
|
||||
device = Device()
|
||||
device.deviceId="Anthon-Mouse-Car"
|
||||
devices = [device]
|
||||
|
||||
# if this is a post request from the 'unlink' submittion form
|
||||
# delete this device from the list
|
||||
if request.method == 'POST':
|
||||
if request.form.get("submit") == "Unlink":
|
||||
device = db.session.query(Device).filter(Device.deviceName==request.form.get("device")).first()
|
||||
db.session.delete(device)
|
||||
db.session.commit()
|
||||
|
||||
# if this is part of the device form
|
||||
# TODO add this device to the user - do not create new device
|
||||
form = DeviceForm()
|
||||
if form.validate_on_submit():
|
||||
print(form.deviceId.data, flush=True)
|
||||
print(form.deviceName.data, flush=True)
|
||||
device = Device()
|
||||
device.deviceName = form.deviceName.data
|
||||
device.connection = False
|
||||
db.session.add(device)
|
||||
current_user.devices.append(device)
|
||||
# TODO add device to database here
|
||||
|
||||
return flask.render_template('devices.html', devices=devices, form=form)
|
||||
db.session.commit()
|
||||
return flask.render_template('devices.html',
|
||||
devices=current_user.devices,
|
||||
form=form)
|
||||
|
||||
|
||||
@app.route("/calendar")
|
||||
@ -89,6 +103,9 @@ def emaillogin():
|
||||
def register():
|
||||
if current_user.is_authenticated:
|
||||
return redirect(url_for('account'))
|
||||
|
||||
|
||||
|
||||
form = RegistrationForm()
|
||||
if form.validate_on_submit():
|
||||
user = User(userid=form.username.data,
|
||||
@ -105,16 +122,9 @@ def register():
|
||||
def deleteAccount():
|
||||
if not current_user.is_authenticated:
|
||||
return redirect(url_for('account'))
|
||||
# TODO fix google delete account
|
||||
if current_user.google_token != None:
|
||||
google.deleteAccount(current_user)
|
||||
'''
|
||||
for cal in current_user.calendars:
|
||||
db.session.delete(cal)
|
||||
for dev in current_user.devices:
|
||||
db.session.delete(dev)
|
||||
db.session.delete(current_user.google_token)
|
||||
'''
|
||||
|
||||
db.session.delete(current_user)
|
||||
db.session.commit()
|
||||
logout_user()
|
||||
@ -199,7 +209,7 @@ def generateDeviceFingerprint():
|
||||
# check not in Device Database
|
||||
# Save as new Device
|
||||
# Send to User
|
||||
return jsonify(deviceId="Carrot-Enamel-Storm")
|
||||
return jsonify(deviceName="Carrot-Enamel-Storm")
|
||||
|
||||
# POST
|
||||
|
||||
|
Reference in New Issue
Block a user