diff --git a/django_etebase/app_settings.py b/django_etebase/app_settings.py index 33dc65f..3c580b2 100644 --- a/django_etebase/app_settings.py +++ b/django_etebase/app_settings.py @@ -61,6 +61,13 @@ class AppSettings: return self.import_from_str(func) return None + @cached_property + def DASHBOARD_URL_FUNC(self): # pylint: disable=invalid-name + func = self._setting("DASHBOARD_URL_FUNC", None) + if func is not None: + return self.import_from_str(func) + return None + @cached_property def CHUNK_PATH_FUNC(self): # pylint: disable=invalid-name func = self._setting("CHUNK_PATH_FUNC", None) diff --git a/django_etebase/views.py b/django_etebase/views.py index 6003d4b..d421e43 100644 --- a/django_etebase/views.py +++ b/django_etebase/views.py @@ -783,6 +783,18 @@ class AuthenticationViewSet(viewsets.ViewSet): return Response({}, status=status.HTTP_200_OK) + @action_decorator(detail=False, methods=['POST'], permission_classes=BaseViewSet.permission_classes) + def dashboard_url(self, request, *args, **kwargs): + get_dashboard_url = app_settings.DASHBOARD_URL_FUNC + if get_dashboard_url is None: + raise EtebaseValidationError('not_supported', 'This server doesn\'t have a user dashboard.', + status_code=status.HTTP_400_BAD_REQUEST) + + ret = { + 'url': get_dashboard_url(request, *args, **kwargs), + } + return Response(ret) + class TestAuthenticationViewSet(viewsets.ViewSet): allowed_methods = ['POST']