Skip to content

Commit

Permalink
Merge pull request #4489 from archesproject/4472_enable_privileges_fo…
Browse files Browse the repository at this point in the history
…r_mobile

fix child cards not being added to the mobile survey, re #4488
  • Loading branch information
apeters authored Jan 29, 2019
2 parents 1280d60 + fd0cd6a commit 79e4edd
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions arches/app/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ def get(self, request):
viewable_nodegroups = request.user.userprofile.viewable_nodegroups
editable_nodegroups = request.user.userprofile.editable_nodegroups
permitted_nodegroups = viewable_nodegroups.union(editable_nodegroups)

def get_child_cardids(card, cardset):
for child_card in models.CardModel.objects.filter(nodegroup__parentnodegroup_id=card.nodegroup_id):
cardset.add(str(child_card.cardid))
get_child_cardids(child_card, cardset)

group_ids = list(request.user.groups.values_list('id', flat=True))
projects = MobileSurvey.objects.filter(Q(users__in=[request.user]) | Q(groups__in=group_ids), active=True).distinct()
projects_for_couch = [project.serialize_for_mobile() for project in projects]
Expand All @@ -149,6 +155,7 @@ def get(self, request):
for card in models.CardModel.objects.filter(cardid__in=project['cards']):
if str(card.nodegroup_id) in permitted_nodegroups:
permitted_cards.add(str(card.cardid))
get_child_cardids(card, permitted_cards)
project['cards'] = list(permitted_cards)
for graph in project['graphs']:
cards = []
Expand Down

0 comments on commit 79e4edd

Please sign in to comment.