mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
chore: changed issue relation history logs (#2192)
* chore: changed issue relation history logs * chore: change field name
This commit is contained in:
parent
32d945be0d
commit
b274a21ca5
@ -293,12 +293,12 @@ class IssueLabelSerializer(BaseSerializer):
|
|||||||
|
|
||||||
|
|
||||||
class IssueRelationSerializer(BaseSerializer):
|
class IssueRelationSerializer(BaseSerializer):
|
||||||
related_issue_detail = IssueProjectLiteSerializer(read_only=True, source="related_issue")
|
issue_detail = IssueProjectLiteSerializer(read_only=True, source="related_issue")
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = IssueRelation
|
model = IssueRelation
|
||||||
fields = [
|
fields = [
|
||||||
"related_issue_detail",
|
"issue_detail",
|
||||||
"relation_type",
|
"relation_type",
|
||||||
"related_issue",
|
"related_issue",
|
||||||
"issue",
|
"issue",
|
||||||
|
@ -53,6 +53,7 @@ from plane.api.serializers import (
|
|||||||
CommentReactionSerializer,
|
CommentReactionSerializer,
|
||||||
IssueVoteSerializer,
|
IssueVoteSerializer,
|
||||||
IssueRelationSerializer,
|
IssueRelationSerializer,
|
||||||
|
RelatedIssueSerializer,
|
||||||
IssuePublicSerializer,
|
IssuePublicSerializer,
|
||||||
)
|
)
|
||||||
from plane.api.permissions import (
|
from plane.api.permissions import (
|
||||||
@ -2085,9 +2086,10 @@ class IssueRelationViewSet(BaseViewSet):
|
|||||||
def create(self, request, slug, project_id, issue_id):
|
def create(self, request, slug, project_id, issue_id):
|
||||||
try:
|
try:
|
||||||
related_list = request.data.get("related_list", [])
|
related_list = request.data.get("related_list", [])
|
||||||
|
relation = request.data.get("relation", None)
|
||||||
project = Project.objects.get(pk=project_id)
|
project = Project.objects.get(pk=project_id)
|
||||||
|
|
||||||
issueRelation = IssueRelation.objects.bulk_create(
|
issue_relation = IssueRelation.objects.bulk_create(
|
||||||
[
|
[
|
||||||
IssueRelation(
|
IssueRelation(
|
||||||
issue_id=related_issue["issue"],
|
issue_id=related_issue["issue"],
|
||||||
@ -2113,8 +2115,14 @@ class IssueRelationViewSet(BaseViewSet):
|
|||||||
current_instance=None,
|
current_instance=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if relation == "blocking":
|
||||||
return Response(
|
return Response(
|
||||||
IssueRelationSerializer(issueRelation, many=True).data,
|
RelatedIssueSerializer(issue_relation, many=True).data,
|
||||||
|
status=status.HTTP_201_CREATED,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return Response(
|
||||||
|
IssueRelationSerializer(issue_relation, many=True).data,
|
||||||
status=status.HTTP_201_CREATED,
|
status=status.HTTP_201_CREATED,
|
||||||
)
|
)
|
||||||
except IntegrityError as e:
|
except IntegrityError as e:
|
||||||
|
@ -1048,6 +1048,25 @@ def create_issue_relation_activity(
|
|||||||
)
|
)
|
||||||
if current_instance is None and requested_data.get("related_list") is not None:
|
if current_instance is None and requested_data.get("related_list") is not None:
|
||||||
for issue_relation in requested_data.get("related_list"):
|
for issue_relation in requested_data.get("related_list"):
|
||||||
|
if issue_relation.get("relation_type") == "blocked_by":
|
||||||
|
relation_type = "blocking"
|
||||||
|
else:
|
||||||
|
relation_type = issue_relation.get("relation_type")
|
||||||
|
issue = Issue.objects.get(pk=issue_relation.get("issue"))
|
||||||
|
issue_activities.append(
|
||||||
|
IssueActivity(
|
||||||
|
issue_id=issue_relation.get("related_issue"),
|
||||||
|
actor=actor,
|
||||||
|
verb="created",
|
||||||
|
old_value="",
|
||||||
|
new_value=f"{project.identifier}-{issue.sequence_id}",
|
||||||
|
field=relation_type,
|
||||||
|
project=project,
|
||||||
|
workspace=project.workspace,
|
||||||
|
comment=f'added {relation_type} relation',
|
||||||
|
old_identifier=issue_relation.get("issue"),
|
||||||
|
)
|
||||||
|
)
|
||||||
issue = Issue.objects.get(pk=issue_relation.get("related_issue"))
|
issue = Issue.objects.get(pk=issue_relation.get("related_issue"))
|
||||||
issue_activities.append(
|
issue_activities.append(
|
||||||
IssueActivity(
|
IssueActivity(
|
||||||
@ -1060,7 +1079,7 @@ def create_issue_relation_activity(
|
|||||||
project=project,
|
project=project,
|
||||||
workspace=project.workspace,
|
workspace=project.workspace,
|
||||||
comment=f'added {issue_relation.get("relation_type")} relation',
|
comment=f'added {issue_relation.get("relation_type")} relation',
|
||||||
old_identifier=issue_relation.get("issue"),
|
old_identifier=issue_relation.get("related_issue"),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -1073,19 +1092,38 @@ def delete_issue_relation_activity(
|
|||||||
json.loads(current_instance) if current_instance is not None else None
|
json.loads(current_instance) if current_instance is not None else None
|
||||||
)
|
)
|
||||||
if current_instance is not None and requested_data.get("related_list") is None:
|
if current_instance is not None and requested_data.get("related_list") is None:
|
||||||
|
if current_instance.get("relation_type") == "blocked_by":
|
||||||
|
relation_type = "blocking"
|
||||||
|
else:
|
||||||
|
relation_type = current_instance.get("relation_type")
|
||||||
issue = Issue.objects.get(pk=current_instance.get("issue"))
|
issue = Issue.objects.get(pk=current_instance.get("issue"))
|
||||||
|
issue_activities.append(
|
||||||
|
IssueActivity(
|
||||||
|
issue_id=current_instance.get("related_issue"),
|
||||||
|
actor=actor,
|
||||||
|
verb="deleted",
|
||||||
|
old_value="",
|
||||||
|
new_value=f"{project.identifier}-{issue.sequence_id}",
|
||||||
|
field=relation_type,
|
||||||
|
project=project,
|
||||||
|
workspace=project.workspace,
|
||||||
|
comment=f'deleted {relation_type} relation',
|
||||||
|
old_identifier=current_instance.get("issue"),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
issue = Issue.objects.get(pk=current_instance.get("related_issue"))
|
||||||
issue_activities.append(
|
issue_activities.append(
|
||||||
IssueActivity(
|
IssueActivity(
|
||||||
issue_id=current_instance.get("issue"),
|
issue_id=current_instance.get("issue"),
|
||||||
actor=actor,
|
actor=actor,
|
||||||
verb="deleted",
|
verb="deleted",
|
||||||
old_value=f"{project.identifier}-{issue.sequence_id}",
|
old_value="",
|
||||||
new_value="",
|
new_value=f"{project.identifier}-{issue.sequence_id}",
|
||||||
field=f'{current_instance.get("relation_type")}',
|
field=f'{current_instance.get("relation_type")}',
|
||||||
project=project,
|
project=project,
|
||||||
workspace=project.workspace,
|
workspace=project.workspace,
|
||||||
comment=f'deleted the {current_instance.get("relation_type")} relation',
|
comment=f'deleted {current_instance.get("relation_type")} relation',
|
||||||
old_identifier=current_instance.get("issue"),
|
old_identifier=current_instance.get("related_issue"),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
23
apiserver/plane/db/migrations/0045_auto_20230915_0655.py
Normal file
23
apiserver/plane/db/migrations/0045_auto_20230915_0655.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# Generated by Django 4.2.3 on 2023-09-15 06:55
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
def update_issue_activity(apps, schema_editor):
|
||||||
|
IssueActivityModel = apps.get_model("db", "IssueActivity")
|
||||||
|
updated_issue_activity = []
|
||||||
|
for obj in IssueActivityModel.objects.all():
|
||||||
|
if obj.field == "blocks":
|
||||||
|
obj.field = "blocked_by"
|
||||||
|
updated_issue_activity.append(obj)
|
||||||
|
IssueActivityModel.objects.bulk_update(updated_issue_activity, ["field"], batch_size=100)
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('db', '0044_auto_20230913_0709'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(update_issue_activity),
|
||||||
|
]
|
Loading…
Reference in New Issue
Block a user