From 0ea90428206d9940934b59c8b2d162f439adc4da Mon Sep 17 00:00:00 2001 From: Robert Maikher Date: Fri, 24 Aug 2018 09:31:15 +0200 Subject: [PATCH] Revert change to variable name in helper functions I thought it used the name of a builtin due to silly IDE colouring, but turns out what i changed it *to* was a builtin. oops. --- helpers.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/helpers.py b/helpers.py index 9ef0bd8..2b8354a 100644 --- a/helpers.py +++ b/helpers.py @@ -5,30 +5,30 @@ import subprocess import os import signal -def search_user(str, session, ignorethisflag=None): - str = str.lower() - exact_match = session.query(User).filter(or_(User.name == str, User.card == str, User.rfid == str)).first() +def search_user(string, session, ignorethisflag=None): + string = string.lower() + exact_match = session.query(User).filter(or_(User.name == string, User.card == string, User.rfid == string)).first() if exact_match: return exact_match - user_list = session.query(User).filter(or_(User.name.ilike(f'%{str}%'), - User.card.ilike(f'%{str}%'), - User.rfid.ilike(f'%{str}%'))).all() + user_list = session.query(User).filter(or_(User.name.ilike(f'%{string}%'), + User.card.ilike(f'%{string}%'), + User.rfid.ilike(f'%{string}%'))).all() return user_list -def search_product(str, session, find_hidden_products=True): +def search_product(string, session, find_hidden_products=True): if find_hidden_products: - exact_match = session.query(Product).filter(or_(Product.bar_code == str, Product.name == str)).first() + exact_match = session.query(Product).filter(or_(Product.bar_code == string, Product.name == string)).first() else: - exact_match = session.query(Product).filter(or_(Product.bar_code == str, - and_(Product.name == str, Product.hidden == False))).first() + exact_match = session.query(Product).filter(or_(Product.bar_code == string, + and_(Product.name == string, Product.hidden == False))).first() if exact_match: return exact_match if find_hidden_products: - product_list = session.query(Product).filter(or_(Product.bar_code.ilike(f'%{str}%'), - Product.name.ilike(f'%{str}%'))).all() + product_list = session.query(Product).filter(or_(Product.bar_code.ilike(f'%{string}%'), + Product.name.ilike(f'%{string}%'))).all() else: - product_list = session.query(Product).filter(or_(Product.bar_code.ilike(f'%{str}%'), - and_(Product.name.ilike(f'%{str}%'), + product_list = session.query(Product).filter(or_(Product.bar_code.ilike(f'%{string}%'), + and_(Product.name.ilike(f'%{string}%'), Product.hidden == False))).all() return product_list