fix: added url and resolved bugs

This commit is contained in:
NarayanBavisetti 2023-11-06 12:10:26 +05:30
parent 05a6f972b2
commit 67777c1787
2 changed files with 198 additions and 202 deletions

View File

@ -21,6 +21,7 @@ from plane.api.views import (
IssueArchiveViewSet,
IssueRelationViewSet,
IssueDraftViewSet,
BulkIssueOperationsEndpoint,
)
@ -74,6 +75,11 @@ urlpatterns = [
BulkCreateIssueLabelsEndpoint.as_view(),
name="project-bulk-labels",
),
path(
"workspaces/<str:slug>/projects/<uuid:project_id>/bulk-operation-issues/",
BulkIssueOperationsEndpoint.as_view(),
name="bulk-issue-operation",
),
path(
"workspaces/<str:slug>/projects/<uuid:project_id>/bulk-delete-issues/",
BulkDeleteIssuesEndpoint.as_view(),
@ -312,4 +318,5 @@ urlpatterns = [
),
name="project-issue-draft",
),
## End Issue Drafts
]

View File

@ -2252,7 +2252,6 @@ class BulkIssueOperationsEndpoint(BaseAPIView):
]
def post(self, request, slug, project_id):
try:
issue_ids = request.data.get("issue_ids", [])
# Get all the issues
issues = (
@ -2302,9 +2301,9 @@ class BulkIssueOperationsEndpoint(BaseAPIView):
{
"type": "issue.activity.updated",
"requested_data": json.dumps(
{"state": properties.get("state_id")}
{"state": properties.get("state")}
),
"current_instance": json.dumps({"state": (issue.state_id)}),
"current_instance": json.dumps({"state": str(issue.state_id)}),
"issue_id": str(issue.id),
"actor_id": str(request.user.id),
"project_id": str(project_id),
@ -2321,7 +2320,7 @@ class BulkIssueOperationsEndpoint(BaseAPIView):
{"start_date": properties.get("start_date")}
),
"current_instance": json.dumps(
{"start_date": (issue.start_date)}
{"start_date": str(issue.start_date)}
),
"issue_id": str(issue.id),
"actor_id": str(request.user.id),
@ -2336,10 +2335,10 @@ class BulkIssueOperationsEndpoint(BaseAPIView):
{
"type": "issue.activity.updated",
"requested_data": json.dumps(
{"target_date": properties.get("requested_data")}
{"target_date": properties.get("target_date")}
),
"current_instance": json.dumps(
{"target_date": (issue.target_date)}
{"target_date": str(issue.target_date)}
),
"issue_id": str(issue.id),
"actor_id": str(request.user.id),
@ -2370,8 +2369,8 @@ class BulkIssueOperationsEndpoint(BaseAPIView):
bulk_update_issues.append(issue)
# Labels
if properties.get("labels_list", []):
for label_id in properties.get("labels_list", []):
if properties.get("labels", []):
for label_id in properties.get("labels", []):
bulk_update_issue_labels.append(
IssueLabel(
issue=issue,
@ -2385,7 +2384,7 @@ class BulkIssueOperationsEndpoint(BaseAPIView):
{
"type": "issue.activity.updated",
"requested_data": json.dumps(
{"labels_list": properties.get("labels_list", [])}
{"labels": properties.get("labels", [])}
),
"current_instance": json.dumps(
{"labels": [str(label.id) for label in issue.labels.all()]}
@ -2398,9 +2397,9 @@ class BulkIssueOperationsEndpoint(BaseAPIView):
)
# Assignees
if properties.get("assignees_list", []):
if properties.get("assignees", []):
for assignee_id in properties.get(
"assignees_list", issue.assignees
"assignees", issue.assignees
):
bulk_update_issue_assignees.append(
IssueAssignee(
@ -2415,7 +2414,7 @@ class BulkIssueOperationsEndpoint(BaseAPIView):
{
"type": "issue.activity.updated",
"requested_data": json.dumps(
{"assignees_list": properties.get("assignees_list", [])}
{"assignees": properties.get("assignees", [])}
),
"current_instance": json.dumps(
{
@ -2452,19 +2451,9 @@ class BulkIssueOperationsEndpoint(BaseAPIView):
ignore_conflicts=True,
batch_size=100,
)
# update the issue activity
[issue_activity.delay(**activity) for activity in bulk_issue_activities]
return Response(status=status.HTTP_204_NO_CONTENT)
except Project.DoesNotExist:
return Response(
{"error": "Project does not exists"}, status=status.HTTP_400_BAD_REQUEST
)
except Exception as e:
capture_exception(e)
return Response(
{"error": "Something went wrong please try again later"},
status=status.HTTP_400_BAD_REQUEST,
)