-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathurls.py
More file actions
65 lines (59 loc) · 2.05 KB
/
urls.py
File metadata and controls
65 lines (59 loc) · 2.05 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
from django.urls import path
from rest_framework import routers
from market.views import (
CreateImages,
DeleteImage,
Favorites,
Listings,
Offers,
OffersMade,
OffersReceived,
Tags,
UserFavorites,
change_offer_status,
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"}),
),
# Update offer status (PATCH)
path("offers/<int:offer_id>/", change_offer_status, name="offer-status"),
# 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