diff --git a/apiserver/plane/app/views/module/base.py b/apiserver/plane/app/views/module/base.py index 5a987dad8..4dc4c4921 100644 --- a/apiserver/plane/app/views/module/base.py +++ b/apiserver/plane/app/views/module/base.py @@ -431,15 +431,15 @@ class ModuleViewSet(BaseViewSet): def partial_update(self, request, slug, project_id, pk): module = self.get_queryset().filter(pk=pk) - current_instance = json.dumps( - ModuleSerializer(module).data, cls=DjangoJSONEncoder - ) if module.first().archived_at: return Response( {"error": "Archived module cannot be updated"}, status=status.HTTP_400_BAD_REQUEST, ) + current_instance = json.dumps( + ModuleSerializer(module.first()).data, cls=DjangoJSONEncoder + ) serializer = ModuleWriteSerializer( module.first(), data=request.data, partial=True ) diff --git a/apiserver/plane/bgtasks/webhook_task.py b/apiserver/plane/bgtasks/webhook_task.py index d1e1cb34c..6696a569c 100644 --- a/apiserver/plane/bgtasks/webhook_task.py +++ b/apiserver/plane/bgtasks/webhook_task.py @@ -15,6 +15,7 @@ from django.core.mail import EmailMultiAlternatives, get_connection from django.core.serializers.json import DjangoJSONEncoder from django.template.loader import render_to_string from django.utils.html import strip_tags +from django.core.exceptions import ObjectDoesNotExist # Module imports from plane.api.serializers import ( @@ -422,6 +423,9 @@ def webhook_activity( ) return except Exception as e: + # Return if a does not exist error occurs + if isinstance(e, ObjectDoesNotExist): + return if settings.DEBUG: print(e) log_exception(e) @@ -462,21 +466,23 @@ def model_activity( # Loop through all keys in requested data and check the current value and requested value for key in requested_data: - current_value = current_instance.get(key, None) - requested_value = requested_data.get(key, None) - if current_value != requested_value: - webhook_activity.delay( - event=model_name, - verb="updated", - field=key, - old_value=current_value, - new_value=requested_value, - actor_id=actor_id, - slug=slug, - current_site=origin, - event_id=model_id, - old_identifier=None, - new_identifier=None, - ) + # Check if key is present in current instance or not + if key in current_instance: + current_value = current_instance.get(key, None) + requested_value = requested_data.get(key, None) + if current_value != requested_value: + webhook_activity.delay( + event=model_name, + verb="updated", + field=key, + old_value=current_value, + new_value=requested_value, + actor_id=actor_id, + slug=slug, + current_site=origin, + event_id=model_id, + old_identifier=None, + new_identifier=None, + ) return