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 os
|
||||||
import signal
|
import signal
|
||||||
|
|
||||||
def search_user(str, session, ignorethisflag=None):
|
def search_user(string, session, ignorethisflag=None):
|
||||||
str = str.lower()
|
string = string.lower()
|
||||||
exact_match = session.query(User).filter(or_(User.name == str, User.card == str, User.rfid == str)).first()
|
exact_match = session.query(User).filter(or_(User.name == string, User.card == string, User.rfid == string)).first()
|
||||||
if exact_match:
|
if exact_match:
|
||||||
return exact_match
|
return exact_match
|
||||||
user_list = session.query(User).filter(or_(User.name.ilike(f'%{str}%'),
|
user_list = session.query(User).filter(or_(User.name.ilike(f'%{string}%'),
|
||||||
User.card.ilike(f'%{str}%'),
|
User.card.ilike(f'%{string}%'),
|
||||||
User.rfid.ilike(f'%{str}%'))).all()
|
User.rfid.ilike(f'%{string}%'))).all()
|
||||||
return user_list
|
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:
|
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:
|
else:
|
||||||
exact_match = session.query(Product).filter(or_(Product.bar_code == str,
|
exact_match = session.query(Product).filter(or_(Product.bar_code == string,
|
||||||
and_(Product.name == str, Product.hidden == False))).first()
|
and_(Product.name == string, Product.hidden == False))).first()
|
||||||
if exact_match:
|
if exact_match:
|
||||||
return exact_match
|
return exact_match
|
||||||
if find_hidden_products:
|
if find_hidden_products:
|
||||||
product_list = session.query(Product).filter(or_(Product.bar_code.ilike(f'%{str}%'),
|
product_list = session.query(Product).filter(or_(Product.bar_code.ilike(f'%{string}%'),
|
||||||
Product.name.ilike(f'%{str}%'))).all()
|
Product.name.ilike(f'%{string}%'))).all()
|
||||||
else:
|
else:
|
||||||
product_list = session.query(Product).filter(or_(Product.bar_code.ilike(f'%{str}%'),
|
product_list = session.query(Product).filter(or_(Product.bar_code.ilike(f'%{string}%'),
|
||||||
and_(Product.name.ilike(f'%{str}%'),
|
and_(Product.name.ilike(f'%{string}%'),
|
||||||
Product.hidden == False))).all()
|
Product.hidden == False))).all()
|
||||||
return product_list
|
return product_list
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue