Fix cloud_users view
This commit is contained in:
parent
6d7c478bfc
commit
893da302e1
3 changed files with 14 additions and 15 deletions
|
|
@ -12,7 +12,7 @@ class CloudUserSerializer(serializers.ModelSerializer):
|
|||
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ["sync_data"]
|
||||
fields = ["cloud_data"]
|
||||
|
||||
def get_cloud_data(self, obj):
|
||||
link = None
|
||||
|
|
|
|||
|
|
@ -1,19 +1,14 @@
|
|||
from django.urls import path
|
||||
from django.urls import include, path
|
||||
|
||||
from common.api_helpers.optional_slash_router import optional_slash_path
|
||||
from common.api_helpers.optional_slash_router import OptionalSlashRouter, optional_slash_path
|
||||
|
||||
from .views import CloudConnectionView, CloudUsersView, CloudUserView
|
||||
|
||||
router = OptionalSlashRouter()
|
||||
router.register("cloud_users", CloudUserView, basename="cloud-users")
|
||||
|
||||
urlpatterns = [
|
||||
path("", include(router.urls)),
|
||||
optional_slash_path("cloud_users", CloudUsersView.as_view(), name="cloud-users-list"),
|
||||
path(
|
||||
"cloud_users/<str:pk>",
|
||||
CloudUserView.as_view(
|
||||
{
|
||||
"get": "retrieve",
|
||||
}
|
||||
),
|
||||
name="cloud-user-detail",
|
||||
),
|
||||
optional_slash_path("cloud_connection", CloudConnectionView.as_view(), name="cloud-connection-status"),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from rest_framework.response import Response
|
|||
from rest_framework.views import APIView
|
||||
|
||||
import apps.oss_installation.constants as cloud_constants
|
||||
from apps.api.permissions import ActionPermission, IsAdmin, IsOwnerOrAdmin
|
||||
from apps.api.permissions import ActionPermission, AnyRole, IsAdmin, IsOwnerOrAdmin
|
||||
from apps.auth_token.auth import PluginAuthentication
|
||||
from apps.oss_installation.models import CloudConnector, CloudUserIdentity
|
||||
from apps.oss_installation.serializers import CloudUserSerializer
|
||||
|
|
@ -81,8 +81,12 @@ class CloudUserView(
|
|||
authentication_classes = (PluginAuthentication,)
|
||||
permission_classes = (IsAuthenticated, ActionPermission)
|
||||
|
||||
action_permissions = {
|
||||
AnyRole: ("retrieve",),
|
||||
IsAdmin: ("sync",),
|
||||
}
|
||||
action_object_permissions = {
|
||||
IsOwnerOrAdmin: ("retrieve",),
|
||||
IsOwnerOrAdmin: ("retrieve", "sync"),
|
||||
}
|
||||
serializer_class = CloudUserSerializer
|
||||
|
||||
|
|
@ -91,7 +95,7 @@ class CloudUserView(
|
|||
return queryset
|
||||
|
||||
@action(detail=True, methods=["post"])
|
||||
def sync_with_cloud(self, request, pk):
|
||||
def sync(self, request, pk):
|
||||
user = self.get_object()
|
||||
connector = CloudConnector.objects.first()
|
||||
if connector is not None:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue