예제 #1
0
 def all_practices(self, request, *args, **kwargs):
     """
     Get all practices list
     """
     data = api_serializers.TrekPracticeSerializer(trekking_models.Practice.objects.all(),
                                                   many=True,
                                                   context={'request': request}).data
     return response.Response(data)
예제 #2
0
 def used_practices(self, request, *args, **kwargs):
     """
     Get practices used by Trek instances
     """
     data = api_serializers.TrekPracticeSerializer(trekking_models.Practice.objects.filter(
         pk__in=trekking_models.Trek.objects.existing().values_list('practice_id', flat=True)),
         many=True,
         context={'request': request}).data
     return response.Response(data)