Skip to content

Commit

Permalink
api: add endpoint to list all maintainer details
Browse files Browse the repository at this point in the history
  • Loading branch information
ericswpark committed Dec 30, 2022
1 parent 68a1661 commit 80780d2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
6 changes: 6 additions & 0 deletions api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
V1DownloadBuildCounter,
V1GeneralBuildLatest,
V1GeneralDeviceAll,
V1GeneralMaintainerAll,
V1MaintainersChunkedUpload,
V1UpdaterLOS,
v1_download_count_all,
Expand Down Expand Up @@ -74,6 +75,11 @@
V1GeneralDeviceAll.as_view(),
name="v1_general_device_all",
),
path(
"v1/general/maintainer/all/",
V1GeneralMaintainerAll.as_view(),
name="v1_general_maintainer_all",
),
path(
"v1/general/build/latest/<slug:codename>/<slug:variant>/",
V1GeneralBuildLatest.as_view(),
Expand Down
2 changes: 1 addition & 1 deletion api/views/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .general import V1GeneralBuildLatest, V1GeneralDeviceAll
from .general import V1GeneralBuildLatest, V1GeneralDeviceAll, V1GeneralMaintainerAll
from .shippy import (
V1MaintainersChunkedUpload,
v1_maintainers_build_enabled_status_modify,
Expand Down
26 changes: 26 additions & 0 deletions api/views/general.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import ast
import html

from django.contrib.auth import get_user_model

from api.utils import variant_check
from constance import config
from django.http import Http404
Expand All @@ -12,6 +14,8 @@
from core.models import Build, Device


User = get_user_model()

class V1GeneralDeviceAll(APIView):
"""
General endpoint to list all devices in shipper
Expand All @@ -38,6 +42,28 @@ def get(self, request):
return Response(return_json, status=HTTP_200_OK)


class V1GeneralMaintainerAll(APIView):
"""
General endpoint to list all maintainer information registered with shipper
"""

permission_classes = [AllowAny]

# noinspection PyMethodMayBeStatic
def get(self, request):
return_json = {}
for user in User.objects.all():
return_json[user.username] = {
"name": user.get_full_name(),
"bio": user.bio,
"profile_picture": user.profile_picture,
"contact_url": user.contact_url,
"devices": [device.codename for device in user.devices.all()],
}

return Response(return_json, status=HTTP_200_OK)


class V1GeneralBuildLatest(APIView):
"""
General endpoint for build information
Expand Down

0 comments on commit 80780d2

Please sign in to comment.