From f918eae5f8a749628dafdf786258088658930e52 Mon Sep 17 00:00:00 2001 From: Nikki Laude <72233907+nikkilaude@users.noreply.github.com> Date: Tue, 5 Dec 2023 19:18:14 -0800 Subject: [PATCH] Nikki/delete vehicle (#24) Co-authored-by: Lance Tan --- backend/bid/views.py | 4 +--- backend/vehicle/models.py | 27 +++++++++------------------ backend/vehicle/views.py | 8 ++++++++ 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/backend/bid/views.py b/backend/bid/views.py index 711bb18..9cccaab 100644 --- a/backend/bid/views.py +++ b/backend/bid/views.py @@ -36,9 +36,7 @@ def post(self, request, *args, **kwargs): # Check for missing fields if not all([amount, bidder_id, auction_id, content_type_name, object_id]): return Response( - { - "error": "Missing fields in request." - }, + {"error": "Missing fields in request."}, status=status.HTTP_400_BAD_REQUEST, ) diff --git a/backend/vehicle/models.py b/backend/vehicle/models.py index 5d2ac2e..8930acd 100644 --- a/backend/vehicle/models.py +++ b/backend/vehicle/models.py @@ -24,18 +24,13 @@ class Vehicle(MainModel): minimum_price = models.IntegerField(blank=True, null=True) is_sold = models.BooleanField(default=False) remarks = models.CharField(max_length=2000, blank=True, null=True) - classification_type = models.CharField( - max_length=50, blank=True, null=True) + classification_type = models.CharField(max_length=50, blank=True, null=True) engine_condition = models.CharField(max_length=100, blank=True, null=True) - transmission_condition = models.CharField( - max_length=100, blank=True, null=True) - differentials_condition = models.CharField( - max_length=100, blank=True, null=True) + transmission_condition = models.CharField(max_length=100, blank=True, null=True) + differentials_condition = models.CharField(max_length=100, blank=True, null=True) brake_condition = models.CharField(max_length=100, blank=True, null=True) - electrical_condition = models.CharField( - max_length=100, blank=True, null=True) - operating_system_condition = models.CharField( - max_length=100, blank=True, null=True) + electrical_condition = models.CharField(max_length=100, blank=True, null=True) + operating_system_condition = models.CharField(max_length=100, blank=True, null=True) chassis_condition = models.CharField(max_length=100, blank=True, null=True) body_condition = models.CharField(max_length=100, blank=True, null=True) @@ -49,16 +44,12 @@ class Equipment(MainModel): brand = models.ForeignKey(Brand, on_delete=models.PROTECT) equipment_type = models.ForeignKey(Type, on_delete=models.PROTECT) location = models.CharField(max_length=50, blank=True, null=True) - classification_type = models.CharField( - max_length=50, blank=True, null=True) + classification_type = models.CharField(max_length=50, blank=True, null=True) engine_condition = models.CharField(max_length=100, blank=True, null=True) - transmission_condition = models.CharField( - max_length=100, blank=True, null=True) - differentials_condition = models.CharField( - max_length=100, blank=True, null=True) + transmission_condition = models.CharField(max_length=100, blank=True, null=True) + differentials_condition = models.CharField(max_length=100, blank=True, null=True) brake_condition = models.CharField(max_length=100, blank=True, null=True) - electrical_condition = models.CharField( - max_length=100, blank=True, null=True) + electrical_condition = models.CharField(max_length=100, blank=True, null=True) hydraulic_cylinder_condition = models.CharField( max_length=100, blank=True, null=True ) diff --git a/backend/vehicle/views.py b/backend/vehicle/views.py index c7814ba..e51c267 100644 --- a/backend/vehicle/views.py +++ b/backend/vehicle/views.py @@ -64,6 +64,14 @@ def get(self, request, vehicle_id, *args, **kwargs): except vehicle.DoesNotExist: return Response(status=status.HTTP_404_NOT_FOUND) + def delete(self, request, vehicle_id, format=None): + """ + Delete specific vehicle + """ + vehicle = get_object_or_404(Vehicle, id=vehicle_id) + vehicle.delete() + return Response(status=status.HTTP_204_NO_CONTENT) + class VehicleFilterList(APIView): """