Show member's training to admins
This commit is contained in:
parent
0d1ab359a4
commit
bf6abb8737
|
@ -206,6 +206,7 @@ class SearchSerializer(serializers.Serializer):
|
||||||
class AdminSearchSerializer(serializers.Serializer):
|
class AdminSearchSerializer(serializers.Serializer):
|
||||||
cards = serializers.SerializerMethodField()
|
cards = serializers.SerializerMethodField()
|
||||||
member = serializers.SerializerMethodField()
|
member = serializers.SerializerMethodField()
|
||||||
|
training = serializers.SerializerMethodField()
|
||||||
transactions = serializers.SerializerMethodField()
|
transactions = serializers.SerializerMethodField()
|
||||||
|
|
||||||
def get_member(self, obj):
|
def get_member(self, obj):
|
||||||
|
@ -222,6 +223,15 @@ class AdminSearchSerializer(serializers.Serializer):
|
||||||
serializer.is_valid()
|
serializer.is_valid()
|
||||||
return serializer.data
|
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):
|
def get_transactions(self, obj):
|
||||||
if obj.user:
|
if obj.user:
|
||||||
queryset = obj.user.transactions
|
queryset = obj.user.transactions
|
||||||
|
|
Loading…
Reference in New Issue
Block a user