Skip to content

Commit

Permalink
Adds resources to user profile request. re #4357
Browse files Browse the repository at this point in the history
  • Loading branch information
chiatt committed Dec 22, 2018
1 parent 392de76 commit 915bb60
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion arches/app/templates/views/user-profile-manager.htm
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ <h3 class="project-panel-title" data-bind="text: vm.mobilesurvey.name() === '' ?

<div class="">
<div class="project-details">
<a id="view-project-details-btn" class="text-primary text-semibold" data-bind="click: function(val){val.mobilesurvey.toggleShowDetails(); val.getMobileSurveyResources(val)}">{% trans 'View Details' %}</a>
<a id="view-project-details-btn" class="text-primary text-semibold" data-bind="click: function(val){val.mobilesurvey.toggleShowDetails();}">{% trans 'View Details' %}</a>
</div>
</div>
</div>
Expand Down
9 changes: 9 additions & 0 deletions arches/app/views/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def post(self, request):
return render(request, 'views/user-profile-manager.htm', context)

def get_mobile_survey_resources(self, mobile_survey_models):
graphs = models.GraphModel.objects.filter(isresource=True).exclude(graphid=settings.SYSTEM_SETTINGS_RESOURCE_MODEL_ID)
resources = []
mobile_surveys = []
all_ordered_card_ids = []
Expand All @@ -160,4 +161,12 @@ def get_mobile_survey_resources(self, mobile_survey_models):
all_ordered_card_ids += mobile_survey_dict['cards']
mobile_surveys.append(mobile_survey_dict)

active_graphs = set([unicode(card.graph_id) for card in models.CardModel.objects.filter(cardid__in=all_ordered_card_ids)])

for i, graph in enumerate(graphs):
cards = []
if i == 0 or unicode(graph.graphid) in active_graphs:
cards = [Card.objects.get(pk=card.cardid) for card in models.CardModel.objects.filter(graph=graph)]
resources.append({'name': graph.name, 'id': graph.graphid, 'subtitle': graph.subtitle, 'iconclass': graph.iconclass, 'cards': cards})

return mobile_surveys, resources

0 comments on commit 915bb60

Please sign in to comment.