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