From af5450a0f135d61751425c7ffaac36a52dda5f09 Mon Sep 17 00:00:00 2001 From: Jason Date: Sat, 6 Jan 2024 01:45:08 -0500 Subject: [PATCH] update jsonmonke --- core/api/views/objects/main.py | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/core/api/views/objects/main.py b/core/api/views/objects/main.py index 9b4f9d04..8b938a38 100644 --- a/core/api/views/objects/main.py +++ b/core/api/views/objects/main.py @@ -30,23 +30,6 @@ def get_provider(provider_name: str): return providers[provider_name] -get_provider = gen_get_provider( # k = Provider class name e.g. comment in CommentProvider, v = request name - { - "announcement": "announcement", - "blogpost": "blog-post", - "exhibit": "exhibit", - "event": "event", - "organization": "organization", - "flatpage": "flatpage", - "user": "user", - "tag": "tag", - "term": "term", - "timetable": "timetable", - "comment": "comment", - "like": "like", - "course": "course", - } -) providers = { # k = request type (param passed in url), v = provider class "announcement": AnnouncementProvider, "blog-post": BlogPostProvider, @@ -64,6 +47,17 @@ def get_provider(provider_name: str): } +def get_providers_by_operation( + operation: Literal["single", "retrieve", "new", "list"] +) -> List[BaseProvider]: + """ + Gets a list of providers by operation. + """ + return [ + prov + for prov in BaseProvider.__subclasses__() + if getattr(prov, operation, False) + ] class ObjectAPIView(generics.GenericAPIView):