Skip to content

Commit

Permalink
Stacks: add endpoint to get groups
Browse files Browse the repository at this point in the history
  • Loading branch information
aschampion committed Nov 9, 2018
1 parent a4f9a4c commit c00d98a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion django/applications/catmaid/control/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down Expand Up @@ -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)
1 change: 1 addition & 0 deletions django/applications/catmaid/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
urlpatterns += [
url(r'^(?P<project_id>\d+)/stacks$', stack.stacks),
url(r'^(?P<project_id>\d+)/stack/(?P<stack_id>\d+)/info$', stack.stack_info),
url(r'^(?P<project_id>\d+)/stack/(?P<stack_id>\d+)/groups$', stack.stack_groups),
]

# General stack group access
Expand Down

0 comments on commit c00d98a

Please sign in to comment.