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
|
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework.mixins import (
CreateModelMixin, DestroyModelMixin, ListModelMixin, RetrieveModelMixin
)
from rest_framework.viewsets import GenericViewSet
from pydis_site.apps.api.models.bot import AocAccountLink
from pydis_site.apps.api.serializers import AocAccountLinkSerializer
class AocAccountLinkViewSet(
GenericViewSet, CreateModelMixin, DestroyModelMixin, RetrieveModelMixin, ListModelMixin
):
"""
View providing management for Users who linked their AoC accounts to their Discord Account.
## Routes
### GET /bot/aoc-account-links
Returns all the AoC account links
#### Response format
>>> [
... {
... "user": 2,
... "aoc_username": "AoCUser1"
... },
... ...
... ]
### GET /bot/aoc-account-links/<user__id:int>
Retrieve a AoC account link by User ID
#### Response format
>>>
... {
... "user": 2,
... "aoc_username": "AoCUser1"
... }
#### Status codes
- 200: returned on success
- 404: returned if an AoC account link with the given `user__id` was not found.
### POST /bot/aoc-account-links
Adds a single AoC account link block
#### Request body
>>> {
... 'user': int,
... 'aoc_username': str
... }
#### Status codes
- 204: returned on success
- 400: if one of the given fields was invalid
### DELETE /bot/aoc-account-links/<user__id:int>
Deletes the AoC account link item with the given `user__id`.
#### Status codes
- 204: returned on success
- 404: returned if the AoC account link with the given `user__id` was not found
"""
serializer_class = AocAccountLinkSerializer
queryset = AocAccountLink.objects.all()
filter_backends = (DjangoFilterBackend,)
filterset_fields = ("user__id", "aoc_username")
|