Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4ec2c61e0d | |||
| 641ef9fd14 | |||
| 68a4d02847 |
@@ -1,5 +1,6 @@
|
||||
# Python imports
|
||||
import json
|
||||
import base64
|
||||
|
||||
# Django imports
|
||||
from django.contrib.postgres.aggregates import ArrayAgg
|
||||
@@ -480,9 +481,7 @@ class IssueViewSet(BaseViewSet):
|
||||
project = Project.objects.get(pk=project_id, workspace__slug=slug)
|
||||
|
||||
issue = (
|
||||
Issue.objects.filter(
|
||||
project_id=self.kwargs.get("project_id")
|
||||
)
|
||||
Issue.objects.filter(project_id=self.kwargs.get("project_id"))
|
||||
.filter(workspace__slug=self.kwargs.get("slug"))
|
||||
.select_related("workspace", "project", "state", "parent")
|
||||
.prefetch_related("assignees", "labels", "issue_module__module")
|
||||
@@ -517,7 +516,7 @@ class IssueViewSet(BaseViewSet):
|
||||
.order_by()
|
||||
.annotate(count=Func(F("id"), function="Count"))
|
||||
.values("count")
|
||||
)
|
||||
)
|
||||
.filter(pk=pk)
|
||||
.annotate(
|
||||
label_ids=Coalesce(
|
||||
@@ -852,9 +851,21 @@ class IssuePaginatedViewSet(BaseViewSet):
|
||||
)
|
||||
).distinct()
|
||||
|
||||
def process_paginated_result(self, fields, results, timezone):
|
||||
def process_paginated_result(
|
||||
self, fields, results, timezone, description_binary_required=False
|
||||
):
|
||||
paginated_data = results.values(*fields)
|
||||
|
||||
# handling the description binary field
|
||||
if description_binary_required:
|
||||
for item in paginated_data:
|
||||
if item["description_binary"]:
|
||||
item["description_binary"] = base64.b64encode(
|
||||
item["description_binary"]
|
||||
).decode("utf-8")
|
||||
else:
|
||||
item["description_binary"] = None
|
||||
|
||||
# converting the datetime fields in paginated data
|
||||
datetime_fields = ["created_at", "updated_at"]
|
||||
paginated_data = user_timezone_converter(
|
||||
@@ -867,6 +878,9 @@ class IssuePaginatedViewSet(BaseViewSet):
|
||||
def list(self, request, slug, project_id):
|
||||
cursor = request.GET.get("cursor", None)
|
||||
is_description_required = request.GET.get("description", "false")
|
||||
is_description_binary_required = request.GET.get(
|
||||
"description_binary", "false"
|
||||
)
|
||||
updated_at = request.GET.get("updated_at__gt", None)
|
||||
|
||||
# required fields
|
||||
@@ -902,6 +916,9 @@ class IssuePaginatedViewSet(BaseViewSet):
|
||||
if str(is_description_required).lower() == "true":
|
||||
required_fields.append("description_html")
|
||||
|
||||
if str(is_description_binary_required).lower() == "true":
|
||||
required_fields.append("description_binary")
|
||||
|
||||
# querying issues
|
||||
base_queryset = Issue.issue_objects.filter(
|
||||
workspace__slug=slug, project_id=project_id
|
||||
@@ -966,12 +983,19 @@ class IssuePaginatedViewSet(BaseViewSet):
|
||||
),
|
||||
)
|
||||
|
||||
is_description_binary_required = False
|
||||
if required_fields.__contains__("description_binary"):
|
||||
is_description_binary_required = True
|
||||
|
||||
paginated_data = paginate(
|
||||
base_queryset=base_queryset,
|
||||
queryset=queryset,
|
||||
cursor=cursor,
|
||||
on_result=lambda results: self.process_paginated_result(
|
||||
required_fields, results, request.user.user_timezone
|
||||
required_fields,
|
||||
results,
|
||||
request.user.user_timezone,
|
||||
is_description_binary_required,
|
||||
),
|
||||
)
|
||||
|
||||
@@ -1077,7 +1101,6 @@ class IssueDetailEndpoint(BaseAPIView):
|
||||
|
||||
|
||||
class IssueBulkUpdateDateEndpoint(BaseAPIView):
|
||||
|
||||
def validate_dates(
|
||||
self, current_start, current_target, new_start, new_target
|
||||
):
|
||||
@@ -1093,7 +1116,6 @@ class IssueBulkUpdateDateEndpoint(BaseAPIView):
|
||||
|
||||
@allow_permission([ROLE.ADMIN, ROLE.MEMBER])
|
||||
def post(self, request, slug, project_id):
|
||||
|
||||
updates = request.data.get("updates", [])
|
||||
|
||||
issue_ids = [update["id"] for update in updates]
|
||||
|
||||
Reference in New Issue
Block a user