Skip to content

Commit

Permalink
When fetching customer info from DVV, look up active permits from
Browse files Browse the repository at this point in the history
database.

PV-720
  • Loading branch information
danjacob-anders authored and mhieta committed Dec 7, 2023
1 parent d292ea0 commit 5c73b38
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion parking_permits/services/dvv.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from django.utils.translation import gettext_lazy as _

from parking_permits.exceptions import ObjectNotFound
from parking_permits.models import ParkingZone
from parking_permits.models import Customer, ParkingZone
from parking_permits.services.kami import get_address_details, parse_street_data

logger = logging.getLogger("db")
Expand Down Expand Up @@ -168,6 +168,12 @@ def get_person_info(national_id_number) -> Optional[DvvPersonInfo]:
other_address = format_address(temporary_address)
other_apartment = other_address.get("apartment", "")

customer = Customer.objects.filter(
national_id_number=national_id_number, user__is_active=True
).first()

active_permits = customer.active_permits if customer else []

return {
"national_id_number": national_id_number,
"first_name": first_name,
Expand All @@ -180,4 +186,5 @@ def get_person_info(national_id_number) -> Optional[DvvPersonInfo]:
"email": "",
"address_security_ban": False,
"driver_license_checked": False,
"active_permits": active_permits,
}

0 comments on commit 5c73b38

Please sign in to comment.