diff --git a/django/applications/catmaid/control/stack.py b/django/applications/catmaid/control/stack.py index 327d6c004e..519efad44d 100644 --- a/django/applications/catmaid/control/stack.py +++ b/django/applications/catmaid/control/stack.py @@ -8,7 +8,7 @@ from django.shortcuts import get_object_or_404 from ..models import UserRole, Project, Stack, ProjectStack, \ - BrokenSlice, StackMirror + BrokenSlice, StackMirror, StackStackGroup from .authentication import requires_user_role logger = logging.getLogger(__name__) @@ -152,3 +152,15 @@ def stacks(request, project_id=None): 'sort_keys': True, 'indent': 4 }) + +@requires_user_role([UserRole.Annotate, UserRole.Browse]) +def stack_groups(request, project_id=None, stack_id=None): + stackgroup_links = StackStackGroup.objects \ + .filter(stack=stack_id) \ + .select_related('group_relation') + + result = { + 'stack_group_ids': [l.stack_group_id for l in stackgroup_links] + } + + return JsonResponse(result) diff --git a/django/applications/catmaid/urls.py b/django/applications/catmaid/urls.py index d9fb8fb761..974488089c 100644 --- a/django/applications/catmaid/urls.py +++ b/django/applications/catmaid/urls.py @@ -100,6 +100,7 @@ urlpatterns += [ url(r'^(?P\d+)/stacks$', stack.stacks), url(r'^(?P\d+)/stack/(?P\d+)/info$', stack.stack_info), + url(r'^(?P\d+)/stack/(?P\d+)/groups$', stack.stack_groups), ] # General stack group access