From 2640fcc3653c4c188cc22e0d44495391e064d6ef Mon Sep 17 00:00:00 2001 From: Anne Haley Date: Fri, 20 Sep 2024 19:40:19 +0000 Subject: [PATCH] feat: add Access Control interface --- uvdat/core/rest/project.py | 10 + web/src/App.vue | 1 + web/src/components/AccessControl.vue | 375 +++++++++++++++++++++++++++ web/src/components/DatasetList.vue | 17 +- web/src/components/ProjectConfig.vue | 47 +++- 5 files changed, 437 insertions(+), 13 deletions(-) create mode 100644 web/src/components/AccessControl.vue diff --git a/uvdat/core/rest/project.py b/uvdat/core/rest/project.py index 9b963a06..01d29964 100644 --- a/uvdat/core/rest/project.py +++ b/uvdat/core/rest/project.py @@ -1,3 +1,4 @@ +from django.contrib.auth.models import User from django.http import HttpResponse from rest_framework.decorators import action from rest_framework.response import Response @@ -21,8 +22,17 @@ def perform_create(self, serializer): def partial_update(self, request, id): project = self.get_object() dataset_ids = request.data.pop('dataset_ids', None) + owner_id = request.data.pop('owner', None) + collaborator_ids = request.data.pop('collaborators', None) + follower_ids = request.data.pop('followers', None) if dataset_ids is not None: project.datasets.set(Dataset.objects.filter(id__in=dataset_ids)) + if owner_id is not None: + project.owner = User.objects.get(id=owner_id) + if collaborator_ids is not None: + project.collaborators.set(User.objects.filter(id__in=collaborator_ids)) + if follower_ids is not None: + project.followers.set(User.objects.filter(id__in=follower_ids)) serializer = ProjectSerializer(project, data=request.data, partial=True) if serializer.is_valid(): serializer.save() diff --git a/web/src/App.vue b/web/src/App.vue index 75a93fc2..1fbf6a93 100644 --- a/web/src/App.vue +++ b/web/src/App.vue @@ -44,6 +44,7 @@ export default defineComponent({ onMounted(onReady); watch(currentUser, onReady); + watch(projectConfigMode, loadProjects); return { login, diff --git a/web/src/components/AccessControl.vue b/web/src/components/AccessControl.vue new file mode 100644 index 00000000..cd63f3e3 --- /dev/null +++ b/web/src/components/AccessControl.vue @@ -0,0 +1,375 @@ + + + + + diff --git a/web/src/components/DatasetList.vue b/web/src/components/DatasetList.vue index 38a8f5b8..fdd24cfa 100644 --- a/web/src/components/DatasetList.vue +++ b/web/src/components/DatasetList.vue @@ -1,6 +1,6 @@