fix: fix some inconsistencies
This commit is contained in:
parent
8504ccdf1a
commit
e5fa7942c7
@ -32,8 +32,8 @@ def check_login(login: str) -> bool:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def send_scan(login: str, scanned: dict[int: int], date:str = None):
|
def send_scan(user: str, scanned: dict[int: int], date:str = None):
|
||||||
infos = {'login': login, 'items': scanned}
|
infos = {'user': user, 'items': scanned}
|
||||||
if date:
|
if date:
|
||||||
infos['date'] = date
|
infos['date'] = date
|
||||||
try:
|
try:
|
||||||
|
|||||||
@ -30,22 +30,22 @@ TIMEOUT = 60 # Number of seconds for a timeout after being logged in
|
|||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
while True:
|
while True:
|
||||||
login = input("Enter Login: ")
|
user = input("Enter Login: ")
|
||||||
if login == "quit":
|
if user == "quit":
|
||||||
break
|
break
|
||||||
if not connection.check_login(login):
|
if not connection.check_login(user):
|
||||||
LOGGER.debug("Login failed")
|
LOGGER.debug("Login failed")
|
||||||
continue # Send Error that login wasn't possible
|
continue # Send Error that login wasn't possible
|
||||||
LOGGER.debug("Login successful")
|
LOGGER.debug("Login successful")
|
||||||
scanned = scanning()
|
scanned = scanning()
|
||||||
scanned = group_scanning(scanned)
|
scanned = group_scanning(scanned)
|
||||||
result = connection.send_scan(login, scanned)
|
result = connection.send_scan(user, scanned)
|
||||||
if result != True:
|
if result != True:
|
||||||
result['date'] = str(date.today())
|
result['date'] = str(date.today())
|
||||||
TEMP.append(result)
|
TEMP.append(result)
|
||||||
if TEMP:
|
if TEMP:
|
||||||
for bought in TEMP:
|
for bought in TEMP:
|
||||||
result = connection.send_scan(bought['login'], bought['items'], bought['date'])
|
result = connection.send_scan(bought['user'], bought['items'], bought['date'])
|
||||||
TEMP.remove(bought)
|
TEMP.remove(bought)
|
||||||
if result != True:
|
if result != True:
|
||||||
TEMP.append(result)
|
TEMP.append(result)
|
||||||
|
|||||||
@ -40,13 +40,13 @@ def login():
|
|||||||
@app.route('/scan2kasse/insert', methods=['POST'])
|
@app.route('/scan2kasse/insert', methods=['POST'])
|
||||||
def insert():
|
def insert():
|
||||||
match request.json:
|
match request.json:
|
||||||
case {'login': login, 'items': items, 'date': date}:
|
case {'user': user, 'items': items, 'date': date}:
|
||||||
failed = DATABASE.insert_bought_items(login, items, date)
|
failed = DATABASE.insert_bought_items(user, items, date)
|
||||||
if failed:
|
if failed:
|
||||||
return jsonify(failed), 400
|
return jsonify(failed), 400
|
||||||
return jsonify({'inserted': True}), 201
|
return jsonify({'inserted': True}), 201
|
||||||
case {'login': login, 'items': items}:
|
case {'user': user, 'items': items}:
|
||||||
failed = DATABASE.insert_bought_items(login, items)
|
failed = DATABASE.insert_bought_items(user, items)
|
||||||
if failed:
|
if failed:
|
||||||
return jsonify(failed), 400
|
return jsonify(failed), 400
|
||||||
return jsonify({'inserted': True}), 201
|
return jsonify({'inserted': True}), 201
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user