From fce72dbca2e05198c283728aa81b61132215be16 Mon Sep 17 00:00:00 2001 From: wvffle Date: Sun, 25 Sep 2022 16:27:11 +0000 Subject: [PATCH] Fix `get_radio_radio` --- api/funkwhale_api/schema.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/api/funkwhale_api/schema.py b/api/funkwhale_api/schema.py index b7ceb9c61..a0a820ef0 100644 --- a/api/funkwhale_api/schema.py +++ b/api/funkwhale_api/schema.py @@ -32,6 +32,7 @@ class CustomAutoSchema(AutoSchema): tokenized_path.append("root") model = tokenized_path.pop() + model_singular = model if self.method == "GET" and self._is_list_view(): action = "get" @@ -42,10 +43,17 @@ class CustomAutoSchema(AutoSchema): if re.search(r"", self.path_regex): tokenized_path.append("formatted") + # rename `create_radio_radio` to `create_radio`. Works with all models + if ( + len(tokenized_path) > 0 + and model_singular == tokenized_path[0] + ): + tokenized_path.pop(0) + # rename `get_radio_radio_track` to `get_radio_track` if ( len(tokenized_path) > 1 - and tokenized_path[1] == "radio" + and tokenized_path[0] == "radio" and tokenized_path[1] == "radio" ): tokenized_path.pop(0)