Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions backend/market/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def create(self, request, *args, **kwargs):
item_id = int(self.kwargs["item_id"])
queryset = self.get_queryset()
if queryset.filter(id=item_id).exists():
raise exceptions.NotAcceptable("Favorite already exists")
raise exceptions.ValidationError("Favorite already exists")
item = get_object_or_404(Item, id=item_id)
self.get_queryset().add(item)
return Response(status=status.HTTP_201_CREATED)
Expand Down Expand Up @@ -289,7 +289,7 @@ def create(self, request, *args, **kwargs):
data = request.data
request.POST._mutable = True
if self.get_queryset().filter(user=self.request.user).exists():
raise exceptions.NotAcceptable("Offer already exists")
raise exceptions.ValidationError("Offer already exists")
data["item"] = int(self.kwargs["item_id"])
data["user"] = self.request.user.id
serializer = self.get_serializer(data=request.data)
Expand All @@ -299,7 +299,10 @@ def create(self, request, *args, **kwargs):

def destroy(self, request, *args, **kwargs):
queryset = self.get_queryset()
filter = {"user": self.request.user, "item": int(self.kwargs["item_id"])}
filter = {
"user": self.request.user,
"item": int(self.kwargs["item_id"]),
}
obj = get_object_or_404(queryset, **filter)
self.check_object_permissions(self.request, obj)
self.perform_destroy(obj)
Expand Down
8 changes: 4 additions & 4 deletions backend/tests/market/mock_items.json
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove before merge

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"price": 20.0,
"negotiable": true,
"created_at": "2024-11-13T20:14:34.604238-05:00",
"expires_at": "2025-12-12T00:00:00-05:00"
"expires_at": "3000-12-12T00:00:00-05:00"
},
{
"tags": ["New"],
Expand All @@ -19,7 +19,7 @@
"price": 5.0,
"negotiable": false,
"created_at": "2024-11-13T20:14:34.604238-05:00",
"expires_at": "2025-10-12T00:00:00-05:00"
"expires_at": "3000-10-12T00:00:00-05:00"
},
{
"tags": ["Laptop", "New"],
Expand All @@ -30,7 +30,7 @@
"price": 2000.0,
"negotiable": true,
"created_at": "2024-11-13T20:14:34.604238-05:00",
"expires_at": "2025-08-12T00:00:00-05:00"
"expires_at": "3000-08-12T00:00:00-05:00"
},
{
"tags": ["Couch"],
Expand All @@ -41,6 +41,6 @@
"price": 400.0,
"negotiable": true,
"created_at": "2024-11-13T20:14:34.604238-05:00",
"expires_at": "2025-12-12T00:00:00-05:00"
"expires_at": "3000-12-12T00:00:00-05:00"
}
]
8 changes: 4 additions & 4 deletions backend/tests/market/mock_sublets.json
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove before merge

Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
"price": 1350.0,
"negotiable": false,
"created_at": "2024-11-13T20:14:34.604238-05:00",
"expires_at": "2025-12-12T00:00:00-05:00"
"expires_at": "3000-12-12T00:00:00-05:00"
},
"address": "Cira Green, Philadelphia, PA",
"beds": 3.0,
"baths": 1.0,
"start_date": "2024-01-01T00:00:00-05:00",
"end_date": "2025-05-31T00:00:00-04:00"
"end_date": "3000-05-31T00:00:00-04:00"
},
{
"item": {
Expand All @@ -31,12 +31,12 @@
"price": 1350.0,
"negotiable": false,
"created_at": "2024-11-13T20:14:34.604238-05:00",
"expires_at": "2025-12-12T00:00:00-05:00"
"expires_at": "3000-12-12T00:00:00-05:00"
},
"address": "3901 Locust Walk, Philadelphia, PA",
"beds": 4.0,
"baths": 1.0,
"start_date": "2024-01-01T00:00:00-05:00",
"end_date": "2025-05-31T00:00:00-04:00"
"end_date": "3000-05-31T00:00:00-04:00"
}
]
2 changes: 1 addition & 1 deletion backend/tests/market/self_user_items.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"price": 20.0,
"negotiable": true,
"created_at": "2024-11-13T20:14:34.604238-05:00",
"expires_at": "2025-12-12T00:00:00-05:00"
"expires_at": "3000-12-12T00:00:00-05:00"
}
]
4 changes: 2 additions & 2 deletions backend/tests/market/self_user_sublets.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
"price": 1350.0,
"negotiable": false,
"created_at": "2024-11-13T20:14:34.604238-05:00",
"expires_at": "2025-12-12T00:00:00-05:00"
"expires_at": "3000-12-12T00:00:00-05:00"
},
"address": "Cira Green, Philadelphia, PA",
"beds": 3.0,
"baths": 1.0,
"start_date": "2024-01-01T00:00:00-05:00",
"end_date": "2025-05-31T00:00:00-04:00"
"end_date": "3000-05-31T00:00:00-04:00"
}
]
Loading
Loading