diff --git a/apiserver/apiserver/api/serializers.py b/apiserver/apiserver/api/serializers.py index 6f84648..9556688 100644 --- a/apiserver/apiserver/api/serializers.py +++ b/apiserver/apiserver/api/serializers.py @@ -206,6 +206,7 @@ class SearchSerializer(serializers.Serializer): class AdminSearchSerializer(serializers.Serializer): cards = serializers.SerializerMethodField() member = serializers.SerializerMethodField() + training = serializers.SerializerMethodField() transactions = serializers.SerializerMethodField() def get_member(self, obj): @@ -222,6 +223,15 @@ class AdminSearchSerializer(serializers.Serializer): serializer.is_valid() return serializer.data + def get_training(self, obj): + if obj.user: + queryset = obj.user.training + else: + queryset = models.Training.objects.filter(member_id=obj.id) + serializer = UserTrainingSerializer(data=queryset, many=True) + serializer.is_valid() + return serializer.data + def get_transactions(self, obj): if obj.user: queryset = obj.user.transactions