code cleanup and comments

This commit is contained in:
2020-07-10 10:11:31 +02:00
parent 016e52f1e7
commit 208e3a7b49
12 changed files with 37 additions and 162 deletions

View File

@ -13,7 +13,7 @@ from flask_login import (
login_user,
logout_user,
)
from random_word import RandomWords
from random_words import RandomWords
import requests
import server.googleHandler as google
@ -74,18 +74,19 @@ def devices():
# if this is a post request from the 'unlink' submittion form
# delete this device from the list
form = DeviceForm()
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
form = DeviceForm()
if form.validate_on_submit():
device = db.session.query(Device).filter(Device.deviceName==form.deviceName.data).first()
current_user.devices.append(device)
db.session.commit()
elif form.validate_on_submit():
device = db.session.query(Device).filter(Device.deviceName==form.deviceName.data).first()
current_user.devices.append(device)
db.session.commit()
return flask.render_template('devices.html',
devices=current_user.devices,
@ -222,9 +223,7 @@ def generateDeviceFingerprint():
while True:
fingerprint = ""
length = 3
randos = r.get_random_words(limit=length, hasDictionaryDef="true",
includePartOfSpeech="noun", minDictionaryCount=1,
maxDictionaryCount=10, minLength=5, maxLength=10)
randos = r.random_words(count=length)
for i in range(len(randos)):
fingerprint += randos[i]
if i < length-1: