-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathurls.py
More file actions
84 lines (78 loc) · 2.61 KB
/
urls.py
File metadata and controls
84 lines (78 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
from django.urls import path
from rest_framework import routers
from market.views import (
CreateImages,
DeleteImage,
Favorites,
Listings,
MyOfferForListing,
OfferDetailsUpdate,
Offers,
OffersMade,
OffersReceived,
OfferStatusUpdate,
Tags,
UserFavorites,
get_current_user,
get_phone_status,
send_verification_code,
verify_phone_code,
)
app_name = "market"
router = routers.DefaultRouter()
router.register(r"listings", Listings, basename="listings")
additional_urls = [
# Current user
path("user/me/", get_current_user, name="current-user"),
# List of all amenities
path("tags/", Tags.as_view(), name="tags"),
# All favorites for user
path("favorites/", UserFavorites.as_view(), name="user-favorites"),
# All offers made by user
path("offers/made/", OffersMade.as_view(), name="offers-made"),
# All offers for an listing owned by user
path("offers/received/", OffersReceived.as_view(), name="offers-received"),
# Favorites
# post: add a listing to the user's favorites
# delete: remove a listing from the user's favorites
path(
"listings/<listing_id>/favorites/",
Favorites.as_view({"post": "create", "delete": "destroy"}),
),
# Offers
# get: list all offers for an listing
# post: create an offer for an listing
# delete: delete an offer for an listing
path(
"listings/<int:listing_id>/offers/",
Offers.as_view({"get": "list", "post": "create", "delete": "destroy"}),
),
# Current user's offer for an individual listing
# (Returns 404 when the user has no offer for that listing.)
path(
"listings/<int:listing_id>/offers/mine/",
MyOfferForListing.as_view(),
name="offers-mine",
),
# Update offer status only (PATCH; listing seller or superuser)
path(
"offers/<int:offer_id>/status/",
OfferStatusUpdate.as_view(),
name="offer-status",
),
# Update offer offered_price + message (PATCH; offer owner or superuser)
path(
"offers/<int:offer_id>/details/",
OfferDetailsUpdate.as_view(),
name="offer-details",
),
# Image Creation
path("listings/<listing_id>/images/", CreateImages.as_view()),
# Image Deletion
path("listings/images/<image_id>/", DeleteImage.as_view()),
# Phone verification
path("phone/status/", get_phone_status, name="phone-status"),
path("phone/send-code/", send_verification_code, name="send-verification-code"),
path("phone/verify-code/", verify_phone_code, name="verify-phone-code"),
]
urlpatterns = router.urls + additional_urls