mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-06 05:59:55 +02:00
Added API endpoint for listing public instance settings
This commit is contained in:
parent
0944ef2a07
commit
6152b3bb36
7 changed files with 69 additions and 1 deletions
0
api/funkwhale_api/instance/__init__.py
Normal file
0
api/funkwhale_api/instance/__init__.py
Normal file
7
api/funkwhale_api/instance/urls.py
Normal file
7
api/funkwhale_api/instance/urls.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
from django.conf.urls import url
|
||||
from . import views
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^settings/$', views.InstanceSettings.as_view(), name='settings'),
|
||||
]
|
25
api/funkwhale_api/instance/views.py
Normal file
25
api/funkwhale_api/instance/views.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
from rest_framework import views
|
||||
from rest_framework.response import Response
|
||||
|
||||
from dynamic_preferences.api import serializers
|
||||
from dynamic_preferences.registries import global_preferences_registry
|
||||
|
||||
|
||||
class InstanceSettings(views.APIView):
|
||||
permission_classes = []
|
||||
authentication_classes = []
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
manager = global_preferences_registry.manager()
|
||||
manager.all()
|
||||
all_preferences = manager.model.objects.all().order_by(
|
||||
'section', 'name'
|
||||
)
|
||||
api_preferences = [
|
||||
p
|
||||
for p in all_preferences
|
||||
if getattr(p.preference, 'show_in_api', False)
|
||||
]
|
||||
data = serializers.GlobalPreferenceSerializer(
|
||||
api_preferences, many=True).data
|
||||
return Response(data, status=200)
|
Loading…
Add table
Add a link
Reference in a new issue