Show member's training to admins

This commit is contained in:
Tanner Collin 2020-08-08 22:46:19 +00:00
parent 0d1ab359a4
commit bf6abb8737

View File

@ -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