check2
This commit is contained in:
parent
12e5f291c6
commit
f79a45b470
@ -951,6 +951,22 @@ class CarColorsUpdateView( LoginRequiredMixin, PermissionRequiredMixin, SuccessM
|
||||
template_name = "inventory/add_colors.html"
|
||||
success_message = _("Car finance details updated successfully")
|
||||
permission_required = ["inventory.change_carfinance"]
|
||||
def get_object(self, queryset=None):
|
||||
"""
|
||||
Retrieves the CarColors instance associated with the Car slug from the URL.
|
||||
This ensures we are updating the colors for the correct car.
|
||||
"""
|
||||
|
||||
# Get the car_slug from the URL keywords arguments
|
||||
slug = self.kwargs.get('slug')
|
||||
|
||||
# If no car_slug is provided, it's an invalid request
|
||||
if not slug:
|
||||
# You might want to raise Http404 or a more specific error here
|
||||
raise ValueError("Car slug is required to identify the colors to update.")
|
||||
|
||||
|
||||
return get_object_or_404(models.CarColors, car__slug=slug)
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse("car_detail", kwargs={"slug": self.object.car.slug})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user