Revised the regular expression to query by the random primary key in the accounting application.

This commit is contained in:
依瑪貓 2020-09-04 19:44:48 +08:00
parent 7f8375bfe7
commit b6a5bc3166

View File

@ -780,7 +780,7 @@ def search(request: HttpRequest) -> HttpResponse:
| Q(transaction__notes__icontains=query)
if re.match("^[0-9]+(?:\\.[0-9]+)?$", query):
conditions = conditions | Q(amount=Decimal(query))
if re.match("^[0-9]{9}$", query):
if re.match("^[1-9][0-8]{9}$", query):
conditions = conditions\
| Q(pk=int(query))\
| Q(transaction__pk=int(query))\