diff --git a/arches/app/views/plugin.py b/arches/app/views/plugin.py index 58be2fcd0d8..4a370624af9 100644 --- a/arches/app/views/plugin.py +++ b/arches/app/views/plugin.py @@ -28,17 +28,14 @@ class PluginView(MapBaseManagerView): action = None - def get(self, request, pluginid=None, slug=None): + def get(self, request, pluginid=None, slug=None, path=None): if slug is not None: plugin = models.Plugin.objects.get(slug=slug) else: plugin = models.Plugin.objects.get(pk=pluginid) if not request.user.has_perm("view_plugin", plugin): - if slug is not None: - return redirect("/auth?next=/plugins/{}".format(slug)) - if slug is not None: - return redirect("/auth?next=/plugins/{}".format(pluginid)) + return redirect("/auth/?next=" + request.path) if request.GET.get("json"): return JSONResponse(plugin) diff --git a/arches/urls.py b/arches/urls.py index 9cd86700a7c..c40ec940c16 100644 --- a/arches/urls.py +++ b/arches/urls.py @@ -648,10 +648,10 @@ api.Concepts.as_view(), name="concepts", ), - re_path( - r"^plugins/(?P%s)$" % uuid_regex, PluginView.as_view(), name="plugins" - ), - re_path(r"^plugins/(?P[-\w]+)$", PluginView.as_view(), name="plugins"), + path("plugins/", PluginView.as_view(), name="plugins"), + path("plugins//", PluginView.as_view(), name="plugins"), + path("plugins/", PluginView.as_view(), name="plugins"), + path("plugins//", PluginView.as_view(), name="plugins"), re_path( r"^workflow_history/(?P%s|())$" % uuid_regex, WorkflowHistoryView.as_view(), diff --git a/releases/8.0.0.md b/releases/8.0.0.md index 0d7fd9cbfb1..ea7ec836576 100644 --- a/releases/8.0.0.md +++ b/releases/8.0.0.md @@ -9,6 +9,7 @@ Arches 8.0.0 Release Notes - Add session-based REST APIs for login, logout [#11261](https://github.com/archesproject/arches/issues/11261) - Improve handling of longer model names [#11317](https://github.com/archesproject/arches/issues/11317) +- Support more expressive plugin URLs [#11320](https://github.com/archesproject/arches/issues/11320) ### Dependency changes ``` diff --git a/tests/views/plugin_tests.py b/tests/views/plugin_tests.py new file mode 100644 index 00000000000..9bd3092a7d9 --- /dev/null +++ b/tests/views/plugin_tests.py @@ -0,0 +1,12 @@ +from django.test import TestCase + +# these tests can be run from the command line via +# python manage.py test tests.views.plugin_tests --settings="tests.test_settings" + + +class PluginViewTests(TestCase): + def test_post_auth_redirect_preserves_full_path(self): + response = self.client.get("/plugins/bulk-data-manager/full-path") + self.assertRedirects( + response, "/auth/?next=/plugins/bulk-data-manager/full-path" + )