fix: email notification assignees (#3762)

This commit is contained in:
Bavisetti Narayan 2024-02-23 19:03:09 +05:30 committed by GitHub
parent 34f89ba45b
commit 1f7565ce52
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 24 additions and 14 deletions

View File

@ -601,15 +601,15 @@ class IssueSerializer(DynamicBaseSerializer):
# ids # ids
cycle_id = serializers.PrimaryKeyRelatedField(read_only=True) cycle_id = serializers.PrimaryKeyRelatedField(read_only=True)
module_ids = serializers.ListField( module_ids = serializers.ListField(
child=serializers.UUIDField(), required=False, allow_null=True child=serializers.UUIDField(), required=False,
) )
# Many to many # Many to many
label_ids = serializers.ListField( label_ids = serializers.ListField(
child=serializers.UUIDField(), required=False, allow_null=True child=serializers.UUIDField(), required=False,
) )
assignee_ids = serializers.ListField( assignee_ids = serializers.ListField(
child=serializers.UUIDField(), required=False, allow_null=True child=serializers.UUIDField(), required=False,
) )
# Count items # Count items

View File

@ -296,11 +296,7 @@ class InboxIssueViewSet(BaseViewSet):
issue_data = request.data.pop("issue", False) issue_data = request.data.pop("issue", False)
if bool(issue_data): if bool(issue_data):
issue = Issue.objects.get( issue = self.get_queryset().filter(pk=inbox_issue.issue_id).first()
pk=inbox_issue.issue_id,
workspace__slug=slug,
project_id=project_id,
)
# Only allow guests and viewers to edit name and description # Only allow guests and viewers to edit name and description
if project_member.role <= 10: if project_member.role <= 10:
# viewers and guests since only viewers and guests # viewers and guests since only viewers and guests

View File

@ -572,12 +572,18 @@ class IssueViewSet(WebhookMixin, BaseViewSet):
return Response(serializer.data, status=status.HTTP_200_OK) return Response(serializer.data, status=status.HTTP_200_OK)
def partial_update(self, request, slug, project_id, pk=None): def partial_update(self, request, slug, project_id, pk=None):
issue = Issue.objects.get( issue = self.get_queryset().filter(pk=pk).first()
workspace__slug=slug, project_id=project_id, pk=pk
) if not issue:
return Response(
{"error": "Issue not found"},
status=status.HTTP_404_NOT_FOUND,
)
current_instance = json.dumps( current_instance = json.dumps(
IssueSerializer(issue).data, cls=DjangoJSONEncoder IssueSerializer(issue).data, cls=DjangoJSONEncoder
) )
requested_data = json.dumps(self.request.data, cls=DjangoJSONEncoder) requested_data = json.dumps(self.request.data, cls=DjangoJSONEncoder)
serializer = IssueCreateSerializer( serializer = IssueCreateSerializer(
issue, data=request.data, partial=True issue, data=request.data, partial=True
@ -2296,9 +2302,14 @@ class IssueDraftViewSet(BaseViewSet):
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
def partial_update(self, request, slug, project_id, pk): def partial_update(self, request, slug, project_id, pk):
issue = Issue.objects.get( issue = self.get_queryset().filter(pk=pk).first()
workspace__slug=slug, project_id=project_id, pk=pk
) if not issue:
return Response(
{"error": "Issue does not exist"},
status=status.HTTP_404_NOT_FOUND,
)
serializer = IssueSerializer(issue, data=request.data, partial=True) serializer = IssueSerializer(issue, data=request.data, partial=True)
if serializer.is_valid(): if serializer.is_valid():

View File

@ -10,6 +10,7 @@ from django.utils import timezone
from django.core.mail import EmailMultiAlternatives, get_connection from django.core.mail import EmailMultiAlternatives, get_connection
from django.template.loader import render_to_string from django.template.loader import render_to_string
from django.utils.html import strip_tags from django.utils.html import strip_tags
from django.conf import settings
# Module imports # Module imports
from plane.db.models import EmailNotificationLog, User, Issue from plane.db.models import EmailNotificationLog, User, Issue
@ -301,5 +302,7 @@ def send_email_notification(
print("Duplicate task recived. Skipping...") print("Duplicate task recived. Skipping...")
return return
except (Issue.DoesNotExist, User.DoesNotExist) as e: except (Issue.DoesNotExist, User.DoesNotExist) as e:
if settings.DEBUG:
print(e)
release_lock(lock_id=lock_id) release_lock(lock_id=lock_id)
return return