Skip to content

Commit 35ed950

Browse files
committed
Merging new serverFetch function into the branch
1 parent 79cafc1 commit 35ed950

3 files changed

Lines changed: 4 additions & 8 deletions

File tree

backend/market/models.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class Meta:
5555
def __str__(self):
5656
return f"Offer for {self.listing} made by {self.user}"
5757

58+
5859
class Category(models.Model):
5960
name = models.CharField(max_length=100, unique=True)
6061

@@ -178,7 +179,8 @@ def _calculate_approximate_location(self, latitude, longitude):
178179
def approximate_location(self):
179180
if self.latitude is not None and self.longitude is not None:
180181
approximate_location = self._calculate_approximate_location(
181-
self.latitude, self.longitude)
182+
self.latitude, self.longitude
183+
)
182184
return approximate_location
183185
return None, None
184186

backend/market/serializers.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
from django.contrib.auth import get_user_model
32
from django.core.exceptions import ValidationError as ModelValidationError
43
from profanity_check import predict
@@ -161,6 +160,7 @@ def get_longitude(self, obj):
161160
return float(approx_lon)
162161
return None
163162

163+
164164
# Unified serializer for all listing types (Items and Sublets); used for CRUD operations
165165
class ListingSerializer(ListingTypeMixin, ModelSerializer):
166166
LISTING_TYPE_CONFIG = {
@@ -326,7 +326,6 @@ def _create_sublet(self, validated_data, additional_data):
326326
latitude = additional_data.get("latitude")
327327
longitude = additional_data.get("longitude")
328328

329-
330329
if latitude is not None:
331330
latitude = float(latitude)
332331
if longitude is not None:

frontend/lib/actions.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,7 @@ export async function changeOfferStatus(offerId: number, status: Offer["status"]
240240
// offers: current user's offer for a listing
241241
// ------------------------------------------------------------
242242
export async function getMyOfferForListing(listingId: number): Promise<Offer | null> {
243-
try {
244243
return await serverFetch<Offer>(`/market/listings/${listingId}/offers/mine/`);
245-
} catch (error) {
246-
if (error instanceof APIError && error.status === 404) return null;
247-
throw error;
248-
}
249244
}
250245

251246
export async function updateMyOfferDetails(

0 commit comments

Comments
 (0)