Skip to content

Commit

Permalink
switch to docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLovesDoggo committed Jan 6, 2024
1 parent 9298721 commit 1afc5a2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
8 changes: 6 additions & 2 deletions core/api/utils/polymorphism.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@ def get_provider(provider_name: str):

def get_providers_by_operation(
operation: Literal["single", "new", "list", "retrieve"]
) -> List[BaseProvider]:
) -> List[str]:
"""
Gets a list of providers by operation.
returns a list of provider path names that support the given operation.
Example:
>>> get_providers_by_operation("single")
["announcement", "blog-post", "exhibit", "event", "organization", "flatpage", "user", "tag", "term", "timetable", "comment", "like", "course"]
"""
return [
key
Expand Down
17 changes: 13 additions & 4 deletions core/api/views/objects/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

@extend_schema(
tags=["Objects"],
description="Endpoint for listing objects with various filters.",
parameters=[
OpenApiParameter(
name="type",
Expand All @@ -40,6 +39,9 @@ class ObjectList(
ObjectAPIView,
generics.ListAPIView,
):
"""
Endpoint for listing objects with various filters.
"""
mutate = False
detail = False
kind = "list"
Expand Down Expand Up @@ -167,7 +169,6 @@ def get(self, request, *args, **kwargs):

@extend_schema(
tags=["Objects"],
description="Endpoint for creating new objects.",
parameters=[
OpenApiParameter(
name="type",
Expand All @@ -179,6 +180,9 @@ def get(self, request, *args, **kwargs):
],
)
class ObjectNew(ObjectAPIView, LookupField, generics.CreateAPIView):
"""
Endpoint for creating new objects.
"""
mutate = True
detail = None
kind = "new"
Expand All @@ -194,7 +198,6 @@ def post(self, *args, **kwargs):

@extend_schema(
tags=["Objects"],
description="Endpoint for retrieving objects with various lookups.",
parameters=[
OpenApiParameter(
name="type",
Expand All @@ -206,12 +209,16 @@ def post(self, *args, **kwargs):
],
)
class ObjectRetrieve(

ObjectAPIView,
LookupField,
generics.RetrieveAPIView,
GenericAPIViewWithDebugInfo,
GenericAPIViewWithLastModified,
):
"""
Endpoint for retrieving objects with various lookups.
"""
mutate = False
detail = True
kind = "retrieve"
Expand All @@ -237,7 +244,6 @@ def get_queryset(self):

@extend_schema(
tags=["Objects"],
description="Endpoint for editing objects.",
parameters=[
OpenApiParameter(
name="type",
Expand All @@ -251,6 +257,9 @@ def get_queryset(self):
class ObjectSingle(
ObjectAPIView, LookupField, generics.DestroyAPIView, generics.UpdateAPIView
):
"""
Endpoint for editing objects with support for lookups.
"""
mutate = True
detail = None
kind = "single"
Expand Down

0 comments on commit 1afc5a2

Please sign in to comment.