mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-15 02:33:22 +00:00
Use less requests in GetUserForm.clean
This commit is contained in:
parent
486047b929
commit
583d4ddfb8
@ -94,9 +94,13 @@ class GetUserForm(forms.Form):
|
|||||||
cus = None
|
cus = None
|
||||||
if cleaned_data["code"] != "":
|
if cleaned_data["code"] != "":
|
||||||
if len(cleaned_data["code"]) == StudentCard.UID_SIZE:
|
if len(cleaned_data["code"]) == StudentCard.UID_SIZE:
|
||||||
card = StudentCard.objects.filter(uid=cleaned_data["code"])
|
card = (
|
||||||
if card.exists():
|
StudentCard.objects.filter(uid=cleaned_data["code"])
|
||||||
cus = card.first().customer
|
.select_related("customer")
|
||||||
|
.first()
|
||||||
|
)
|
||||||
|
if card is not None:
|
||||||
|
cus = card.customer
|
||||||
if cus is None:
|
if cus is None:
|
||||||
cus = Customer.objects.filter(
|
cus = Customer.objects.filter(
|
||||||
account_id__iexact=cleaned_data["code"]
|
account_id__iexact=cleaned_data["code"]
|
||||||
|
Loading…
Reference in New Issue
Block a user