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.
This commit is contained in:
parent
ab0a218f8e
commit
0ea9042820
28
helpers.py
28
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
|
||||
|
||||
|
|
Loading…
Reference in New Issue