Skip to content

Commit

Permalink
update jsonmonke
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLovesDoggo committed Jan 6, 2024
1 parent db0778e commit af5450a
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions core/api/views/objects/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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):
Expand Down

0 comments on commit af5450a

Please sign in to comment.