Skip to content

Commit

Permalink
Nikki/delete vehicle (#24)
Browse files Browse the repository at this point in the history
Co-authored-by: Lance Tan <[email protected]>
  • Loading branch information
nikkilaude and ltan02 authored Dec 6, 2023
1 parent c8b6c03 commit f918eae
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
4 changes: 1 addition & 3 deletions backend/bid/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down
27 changes: 9 additions & 18 deletions backend/vehicle/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
)
Expand Down
8 changes: 8 additions & 0 deletions backend/vehicle/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down

0 comments on commit f918eae

Please sign in to comment.