Skip to content

Commit

Permalink
Improve optional Traficom check logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mhieta committed Dec 14, 2023
1 parent 36a5a29 commit c54ee85
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
3 changes: 2 additions & 1 deletion parking_permits/admin_resolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@ def resolve_customers(obj, info, page_input, order_by=None, search_params=None):
)
def resolve_vehicle(obj, info, reg_number, national_id_number):
customer = Customer.objects.get_or_create(national_id_number=national_id_number)[0]
customer.fetch_driving_licence_detail()
if settings.TRAFICOM_CHECK:
customer.fetch_driving_licence_detail()
vehicle = customer.fetch_vehicle_detail(reg_number)
if not settings.TRAFICOM_CHECK:
return vehicle
Expand Down
26 changes: 14 additions & 12 deletions parking_permits/customer_permit.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,22 +206,24 @@ def create(self, address_id, registration):
primary_vehicle = not primary_permit.primary_vehicle
end_time = primary_permit.end_time

self.customer.fetch_driving_licence_detail()
if settings.TRAFICOM_CHECK:
self.customer.fetch_driving_licence_detail()

vehicle = self.customer.fetch_vehicle_detail(registration)
is_user_of_vehicle = self.customer.is_user_of_vehicle(vehicle)
if not is_user_of_vehicle:
raise TraficomFetchVehicleError(
_("Owner/holder data of a vehicle could not be verified")
)
if settings.TRAFICOM_CHECK:
is_user_of_vehicle = self.customer.is_user_of_vehicle(vehicle)
if not is_user_of_vehicle:
raise TraficomFetchVehicleError(
_("Owner/holder data of a vehicle could not be verified")
)

has_valid_licence = self.customer.has_valid_driving_licence_for_vehicle(
vehicle
)
if not has_valid_licence:
raise TraficomFetchVehicleError(
_("Customer does not have a valid driving licence")
has_valid_licence = self.customer.has_valid_driving_licence_for_vehicle(
vehicle
)
if not has_valid_licence:
raise TraficomFetchVehicleError(
_("Customer does not have a valid driving licence")
)

start_time = tz.now()
if not end_time:
Expand Down

0 comments on commit c54ee85

Please sign in to comment.