From 67506b2a4bbf1bfbec5d00bde8874e8a29c4bea1 Mon Sep 17 00:00:00 2001 From: Rachel Lougee Date: Tue, 22 Aug 2023 11:56:15 -0400 Subject: [PATCH] update full name on user profile (#1825) * allow full name editable on user profile * update sync_contact_with_hubspot to specify update fields --- hubspot_sync/api.py | 2 +- users/serializers.py | 1 - users/views.py | 2 ++ 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/hubspot_sync/api.py b/hubspot_sync/api.py index 7e474fb11a..fcf460c82b 100644 --- a/hubspot_sync/api.py +++ b/hubspot_sync/api.py @@ -662,7 +662,7 @@ def sync_contact_with_hubspot(user: User): body=body, ) user.hubspot_sync_datetime = now_in_utc() - user.save() + user.save(update_fields=["hubspot_sync_datetime"]) return result diff --git a/users/serializers.py b/users/serializers.py index 57548809b2..13da8260d1 100644 --- a/users/serializers.py +++ b/users/serializers.py @@ -338,7 +338,6 @@ def update(self, instance, validated_data): user = super().update(instance, validated_data) - sync_hubspot_user(user) return user class Meta: diff --git a/users/views.py b/users/views.py index 6d8b38128a..b04088fc3d 100644 --- a/users/views.py +++ b/users/views.py @@ -10,6 +10,7 @@ from rest_framework.permissions import IsAdminUser, IsAuthenticated from rest_framework.response import Response +from hubspot_sync.task_helpers import sync_hubspot_user from main.permissions import UserIsOwnerPermission from main.views import RefinePagination from openedx import tasks @@ -54,6 +55,7 @@ def update(self, request, *args, **kwargs): if user_name != request.data.get("name"): tasks.change_edx_user_name_async.delay(request.user.id) tasks.update_edx_user_profile(request.user.id) + sync_hubspot_user(request.user) return update_result