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