[Fix] Contest Rank User's Title

This commit is contained in:
Harry-zklcdc 2020-08-02 15:20:32 +08:00
parent c137e0b2d4
commit 07bf2e2fe7

View File

@ -192,6 +192,6 @@ class ContestRankAPI(APIView):
page_qs["results"] = serializer(page_qs["results"], many=True, is_contest_admin=is_contest_admin).data
for i in range(0, len(page_qs["results"])):
user = User.objects.get(username=page_qs["results"][i]["user"]["username"], is_disabled=False)
grade = UserProfileSerializer(user.userprofile, show_real_name=True).data["grade"]
page_qs["results"][i]["user"].update({"grade": grade})
userprofile = UserProfileSerializer(user.userprofile, show_real_name=True).data
page_qs["results"][i].update({"grade": userprofile["grade"], "title": userprofile["user"]["title"], "title_color": userprofile["user"]["title_color"]})
return self.success(page_qs)