1
1
from rest_framework .mixins import (
2
- CreateModelMixin , DestroyModelMixin , ListModelMixin , RetrieveModelMixin
2
+ CreateModelMixin , DestroyModelMixin , ListModelMixin
3
3
)
4
+ from rest_framework .request import Request
5
+ from rest_framework .response import Response
4
6
from rest_framework .viewsets import GenericViewSet
5
7
6
8
from pydis_site .apps .api .models .bot import BumpedThread
7
9
from pydis_site .apps .api .serializers import BumpedThreadSerializer
8
10
9
11
10
12
class BumpedThreadViewSet (
11
- GenericViewSet , CreateModelMixin , DestroyModelMixin , RetrieveModelMixin , ListModelMixin
13
+ GenericViewSet , CreateModelMixin , DestroyModelMixin , ListModelMixin
12
14
):
13
15
"""
14
16
View providing CRUD (Minus the U) operations on threads to be bumped.
@@ -25,15 +27,10 @@ class BumpedThreadViewSet(
25
27
- 401: returned if unauthenticated
26
28
27
29
### GET /bot/bumped-threads/<thread_id:int>
28
- Returns a specific BumpedThread item from the database.
29
-
30
- #### Response format
31
- >>> {
32
- ... 'thread_id': "941705627405811793",
33
- ... }
30
+ Returns whether a specific BumpedThread exists in the database.
34
31
35
32
#### Status codes
36
- - 200 : returned on success
33
+ - 204 : returned on success
37
34
- 404: returned if a BumpedThread with the given thread_id was not found.
38
35
39
36
### POST /bot/bumped-threads
@@ -58,3 +55,12 @@ class BumpedThreadViewSet(
58
55
59
56
serializer_class = BumpedThreadSerializer
60
57
queryset = BumpedThread .objects .all ()
58
+
59
+ def retrieve (self , request : Request , * args , ** kwargs ) -> Response :
60
+ """
61
+ DRF method for checking if the given BumpedThread exists.
62
+
63
+ Called by the Django Rest Framework in response to the corresponding HTTP request.
64
+ """
65
+ self .get_object ()
66
+ return Response (status = 204 )
0 commit comments