update
This commit is contained in:
parent
7588db4922
commit
7ff243d6df
@ -29,6 +29,8 @@ from django.contrib.auth.models import User
|
|||||||
from django_q.tasks import async_task
|
from django_q.tasks import async_task
|
||||||
import secrets
|
import secrets
|
||||||
|
|
||||||
|
import logging
|
||||||
|
logger=logging.getLogger(__name__)
|
||||||
|
|
||||||
def make_random_password(
|
def make_random_password(
|
||||||
length=10, allowed_chars="abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"
|
length=10, allowed_chars="abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"
|
||||||
@ -60,11 +62,19 @@ def get_jwt_token():
|
|||||||
"api_token": settings.CAR_API_TOKEN,
|
"api_token": settings.CAR_API_TOKEN,
|
||||||
"api_secret": settings.CAR_API_SECRET,
|
"api_secret": settings.CAR_API_SECRET,
|
||||||
}
|
}
|
||||||
|
logger.debug(f"Attempting to fetch JWT token from: {url}")
|
||||||
try:
|
try:
|
||||||
response = requests.post(url, headers=headers, json=data)
|
response = requests.post(url, headers=headers, json=data)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
#logging for success
|
||||||
|
logger.info("Successfully fetched JWT token.")
|
||||||
return response.text
|
return response.text
|
||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
|
#logging for error
|
||||||
|
logger.error(
|
||||||
|
f"HTTP error fetching JWT token from {url}: ",
|
||||||
|
exc_info=True
|
||||||
|
)
|
||||||
print(f"Error obtaining JWT token: {e}")
|
print(f"Error obtaining JWT token: {e}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -218,8 +228,22 @@ def reserve_car(car, request):
|
|||||||
)
|
)
|
||||||
car.status = models.CarStatusChoices.RESERVED
|
car.status = models.CarStatusChoices.RESERVED
|
||||||
car.save()
|
car.save()
|
||||||
|
# --- Logging for Success ---
|
||||||
|
logger.info(
|
||||||
|
f"Car {car.id} ('{car.make} {car.model}') reserved successfully "
|
||||||
|
f"by user {request.user.id} ('{request.user.username}'). "
|
||||||
|
f"Reserved until: {reserved_until}."
|
||||||
|
)
|
||||||
|
|
||||||
messages.success(request, _("Car reserved successfully."))
|
messages.success(request, _("Car reserved successfully."))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
# --- Logging for Error ---
|
||||||
|
logger.error(
|
||||||
|
f"Error reserving car {car.id} ('{car.make} {car.model}') "
|
||||||
|
f"for user {request.user.id} ('{request.user.username}'). "
|
||||||
|
f"Error: {e}",
|
||||||
|
exc_info=True
|
||||||
|
)
|
||||||
messages.error(request, f"Error reserving car: {e}")
|
messages.error(request, f"Error reserving car: {e}")
|
||||||
|
|
||||||
return redirect("car_detail", dealer_slug=request.dealer.slug, slug=car.slug)
|
return redirect("car_detail", dealer_slug=request.dealer.slug, slug=car.slug)
|
||||||
@ -1264,7 +1288,13 @@ def handle_account_process(invoice, amount, finance_data):
|
|||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
car.item_model.for_inventory = False
|
car.item_model.for_inventory = False
|
||||||
|
logger.debug(f"Set item_model.for_inventory to False for car {car.vin}.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
logger.error(
|
||||||
|
f"Error updating item_model.for_inventory for car {car.vin} (Invoice {invoice.invoice_number}): {e}",
|
||||||
|
exc_info=True
|
||||||
|
)
|
||||||
|
|
||||||
print(e)
|
print(e)
|
||||||
car.finances.is_sold = True
|
car.finances.is_sold = True
|
||||||
car.finances.save()
|
car.finances.save()
|
||||||
|
|||||||
@ -2861,6 +2861,7 @@ def GroupPermissionView(request, dealer_slug, pk):
|
|||||||
("inventory", "tasks"),
|
("inventory", "tasks"),
|
||||||
("inventory", "activity"),
|
("inventory", "activity"),
|
||||||
|
|
||||||
|
|
||||||
("django_ledger", "purchaseordermodel"),
|
("django_ledger", "purchaseordermodel"),
|
||||||
("django_ledger", "bankaccountmodel"),
|
("django_ledger", "bankaccountmodel"),
|
||||||
("django_ledger", "estimatemodel"),
|
("django_ledger", "estimatemodel"),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user