def get_about_me(request): if request.user.is_authenticated(): # PATCH = update username if request.method == "PATCH": serializer = UserProfileSerializer( request.user, request.data, partial=True, ) if serializer.is_valid(): serializer.save() # generate user's data (username + stats) user_stats = Game.get_user_stats(request.user) return Response(user_stats, status=200) else: return Response( {'detail': 'Authentication credentials were not provided.'}, status=403)
def post(self, request, public_address): user = request.current_user user.profile_touched_manually = True serializer = UserProfileSerializer(user, data=request.data) serializer.is_valid(raise_exception=True) serializer.save() user.save_and_clear_skills(request.data.get('skills')) user.save_and_clear_languages(request.data.get('languages')) user.save() notification_client.profile_updated(user.public_address.lower()) seo_client.profile_preview_screenshot(user.id) return JsonResponse(UserProfileSerializer(user).data)
def post(self, request, public_address): user = request.current_user user.profile_touched_manually = True user.is_profile_image_dirty = request.data.get('profileDirectoryHash') != str(user.profileDirectoryHash) serializer = UserProfileSerializer(user, data=request.data) serializer.is_valid(raise_exception=True) serializer.save() user.save_and_clear_skills(request.data.get('skills')) user.save_and_clear_languages(request.data.get('languages')) user.save() notification_client.profile_updated(user.public_address.lower()) return JsonResponse(UserProfileSerializer(user).data)