Rename operation ids

This commit is contained in:
wvffle 2022-09-25 13:57:22 +00:00 committed by Georg Krause
commit 68face201b
20 changed files with 14173 additions and 23 deletions

View file

@ -4,9 +4,12 @@ import urllib.parse
from django import http
from django.utils import timezone
from django.db.models import Q
from rest_framework import mixins, permissions, response, views, viewsets
from rest_framework.decorators import action
from drf_spectacular.utils import extend_schema
from oauth2_provider import exceptions as oauth2_exceptions
from oauth2_provider import views as oauth_views
from oauth2_provider.settings import oauth2_settings
@ -83,6 +86,7 @@ class ApplicationViewSet(
qs = qs.filter(user=self.request.user)
return qs
@extend_schema(operation_id='refresh_oauth_token')
@action(
detail=True,
methods=["post"],

View file

@ -12,6 +12,8 @@ from rest_framework import viewsets
from rest_framework.decorators import action
from rest_framework.response import Response
from drf_spectacular.utils import extend_schema
from funkwhale_api.common import authentication
from funkwhale_api.common import preferences
from funkwhale_api.common import throttling
@ -19,6 +21,7 @@ from funkwhale_api.common import throttling
from . import models, serializers, tasks
@extend_schema(operation_id='register', methods=['post'])
class RegisterView(registration_views.RegisterView):
serializer_class = serializers.RegisterSerializer
permission_classes = []
@ -43,18 +46,22 @@ class RegisterView(registration_views.RegisterView):
return user
@extend_schema(operation_id='verify_email')
class VerifyEmailView(registration_views.VerifyEmailView):
action = "verify-email"
@extend_schema(operation_id='change_password')
class PasswordChangeView(rest_auth_views.PasswordChangeView):
action = "password-change"
@extend_schema(operation_id='reset_password')
class PasswordResetView(rest_auth_views.PasswordResetView):
action = "password-reset"
@extend_schema(operation_id='confirm_password_reset')
class PasswordResetConfirmView(rest_auth_views.PasswordResetConfirmView):
action = "password-reset-confirm"
@ -66,6 +73,8 @@ class UserViewSet(mixins.UpdateModelMixin, viewsets.GenericViewSet):
lookup_value_regex = r"[a-zA-Z0-9-_.]+"
required_scope = "profile"
@extend_schema(operation_id='get_authenticated_user', methods=['get'])
@extend_schema(operation_id='delete_authenticated_user', methods=['delete'])
@action(methods=["get", "delete"], detail=False)
def me(self, request, *args, **kwargs):
"""Return information about the current user or delete it"""
@ -80,6 +89,7 @@ class UserViewSet(mixins.UpdateModelMixin, viewsets.GenericViewSet):
serializer = serializers.MeSerializer(request.user)
return Response(serializer.data)
@extend_schema(operation_id='update_settings')
@action(methods=["post"], detail=False, url_name="settings", url_path="settings")
def set_settings(self, request, *args, **kwargs):
"""Return information about the current user or delete it"""
@ -111,6 +121,7 @@ class UserViewSet(mixins.UpdateModelMixin, viewsets.GenericViewSet):
data = {"subsonic_api_token": self.request.user.subsonic_api_token}
return Response(data)
@extend_schema(operation_id='change_email')
@action(
methods=["post"],
required_scope="security",
@ -138,6 +149,8 @@ class UserViewSet(mixins.UpdateModelMixin, viewsets.GenericViewSet):
return super().partial_update(request, *args, **kwargs)
@extend_schema(operation_id='login')
@action(methods=['post'], detail=False)
def login(request):
throttling.check_request(request, "login")
if request.method != "POST":
@ -157,6 +170,8 @@ def login(request):
return response
@extend_schema(operation_id='logout')
@action(methods=['post'], detail=False)
def logout(request):
if request.method != "POST":
return http.HttpResponse(status=405)