fixed add junior multiple device notification issue, changed send multiple user notification method, modified add fcm token method

This commit is contained in:
abutalib-kiwi
2023-08-28 15:36:24 +05:30
parent f424c99478
commit 5e17edcf3f
5 changed files with 28 additions and 31 deletions

View File

@ -9,7 +9,7 @@ from django.contrib.auth import get_user_model
from account.utils import get_user_full_name
# local imports
from base.constants import USER_TYPE
from base.constants import USER_TYPE, JUNIOR
from junior.models import JuniorPoints, Junior
@ -37,7 +37,7 @@ class JuniorLeaderboardSerializer(serializers.ModelSerializer):
:param obj: junior object
:return: full name
"""
return f"{obj.auth.first_name} {obj.auth.last_name}" if obj.auth.last_name else obj.auth.first_name
return get_user_full_name(obj.auth)
@staticmethod
def get_first_name(obj):
@ -60,6 +60,8 @@ class LeaderboardSerializer(serializers.ModelSerializer):
"""
leaderboard serializer
"""
user_id = serializers.SerializerMethodField()
user_type = serializers.SerializerMethodField()
junior = JuniorLeaderboardSerializer()
rank = serializers.IntegerField()
@ -68,7 +70,15 @@ class LeaderboardSerializer(serializers.ModelSerializer):
meta class
"""
model = JuniorPoints
fields = ('total_points', 'rank', 'junior')
fields = ('user_id', 'user_type', 'total_points', 'rank', 'junior')
@staticmethod
def get_user_id(obj):
return obj.junior.auth.id
@staticmethod
def get_user_type(obj):
return JUNIOR
class UserCSVReportSerializer(serializers.ModelSerializer):