Skip to content

Commit

Permalink
feat: add Access Control interface
Browse files Browse the repository at this point in the history
  • Loading branch information
annehaley committed Sep 20, 2024
1 parent 02c1b2e commit e2fec2f
Show file tree
Hide file tree
Showing 5 changed files with 438 additions and 13 deletions.
11 changes: 11 additions & 0 deletions uvdat/core/rest/project.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from django.http import HttpResponse
from django.contrib.auth.models import User

from rest_framework.decorators import action
from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet
Expand All @@ -21,8 +23,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()
Expand Down
1 change: 1 addition & 0 deletions web/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default defineComponent({
onMounted(onReady);
watch(currentUser, onReady);
watch(projectConfigMode, loadProjects);
return {
login,
Expand Down
Loading

0 comments on commit e2fec2f

Please sign in to comment.