mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
chore: archive and draft issue description
This commit is contained in:
parent
d8c4461497
commit
fbfa536937
@ -20,6 +20,7 @@ from plane.app.views import (
|
|||||||
IssueViewSet,
|
IssueViewSet,
|
||||||
LabelViewSet,
|
LabelViewSet,
|
||||||
IssueDescriptionViewSet,
|
IssueDescriptionViewSet,
|
||||||
|
ArchivedIssueDescriptionViewSet,
|
||||||
)
|
)
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
@ -265,6 +266,16 @@ urlpatterns = [
|
|||||||
),
|
),
|
||||||
name="project-issue-archive-unarchive",
|
name="project-issue-archive-unarchive",
|
||||||
),
|
),
|
||||||
|
path(
|
||||||
|
"workspaces/<str:slug>/projects/<uuid:project_id>/archived-issues/<uuid:pk>/description/",
|
||||||
|
ArchivedIssueDescriptionViewSet.as_view(
|
||||||
|
{
|
||||||
|
"get": "retrieve",
|
||||||
|
"patch": "partial_update",
|
||||||
|
}
|
||||||
|
),
|
||||||
|
name="archived-issue-description",
|
||||||
|
),
|
||||||
## End Issue Archives
|
## End Issue Archives
|
||||||
## Issue Relation
|
## Issue Relation
|
||||||
path(
|
path(
|
||||||
@ -309,4 +320,14 @@ urlpatterns = [
|
|||||||
),
|
),
|
||||||
name="project-issue-draft",
|
name="project-issue-draft",
|
||||||
),
|
),
|
||||||
|
path(
|
||||||
|
"workspaces/<str:slug>/projects/<uuid:project_id>/issue-drafts/<uuid:pk>/description/",
|
||||||
|
IssueDraftViewSet.as_view(
|
||||||
|
{
|
||||||
|
"get": "retrieve",
|
||||||
|
"patch": "partial_update",
|
||||||
|
}
|
||||||
|
),
|
||||||
|
name="draft-issue-description",
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
@ -114,9 +114,7 @@ from .issue.activity import (
|
|||||||
IssueActivityEndpoint,
|
IssueActivityEndpoint,
|
||||||
)
|
)
|
||||||
|
|
||||||
from .issue.archive import (
|
from .issue.archive import IssueArchiveViewSet, ArchivedIssueDescriptionViewSet
|
||||||
IssueArchiveViewSet,
|
|
||||||
)
|
|
||||||
|
|
||||||
from .issue.attachment import (
|
from .issue.attachment import (
|
||||||
IssueAttachmentEndpoint,
|
IssueAttachmentEndpoint,
|
||||||
@ -127,7 +125,7 @@ from .issue.comment import (
|
|||||||
CommentReactionViewSet,
|
CommentReactionViewSet,
|
||||||
)
|
)
|
||||||
|
|
||||||
from .issue.draft import IssueDraftViewSet
|
from .issue.draft import IssueDraftViewSet, DraftIssueDescriptionViewSet
|
||||||
|
|
||||||
from .issue.label import (
|
from .issue.label import (
|
||||||
LabelViewSet,
|
LabelViewSet,
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
# Python imports
|
# Python imports
|
||||||
import json
|
import json
|
||||||
|
import base64
|
||||||
|
|
||||||
# Django imports
|
# Django imports
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
@ -18,6 +19,7 @@ from django.db.models import (
|
|||||||
UUIDField,
|
UUIDField,
|
||||||
)
|
)
|
||||||
from django.core.serializers.json import DjangoJSONEncoder
|
from django.core.serializers.json import DjangoJSONEncoder
|
||||||
|
from django.http import StreamingHttpResponse
|
||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
from django.views.decorators.gzip import gzip_page
|
from django.views.decorators.gzip import gzip_page
|
||||||
from django.contrib.postgres.aggregates import ArrayAgg
|
from django.contrib.postgres.aggregates import ArrayAgg
|
||||||
@ -351,3 +353,48 @@ class IssueArchiveViewSet(BaseViewSet):
|
|||||||
issue.save()
|
issue.save()
|
||||||
|
|
||||||
return Response(status=status.HTTP_204_NO_CONTENT)
|
return Response(status=status.HTTP_204_NO_CONTENT)
|
||||||
|
|
||||||
|
|
||||||
|
class ArchivedIssueDescriptionViewSet(BaseViewSet):
|
||||||
|
permission_classes = [
|
||||||
|
ProjectEntityPermission,
|
||||||
|
]
|
||||||
|
|
||||||
|
def retrieve(self, request, slug, project_id, pk):
|
||||||
|
issue = Issue.objects.get(
|
||||||
|
pk=pk, workspace__slug=slug, project_id=project_id
|
||||||
|
)
|
||||||
|
binary_data = issue.description_binary
|
||||||
|
|
||||||
|
def stream_data():
|
||||||
|
if binary_data:
|
||||||
|
yield binary_data
|
||||||
|
else:
|
||||||
|
yield b""
|
||||||
|
|
||||||
|
response = StreamingHttpResponse(
|
||||||
|
stream_data(), content_type="application/octet-stream"
|
||||||
|
)
|
||||||
|
response["Content-Disposition"] = (
|
||||||
|
'attachment; filename="issue_description.bin"'
|
||||||
|
)
|
||||||
|
return response
|
||||||
|
|
||||||
|
def partial_update(self, request, slug, project_id, pk):
|
||||||
|
issue = Issue.objects.get(
|
||||||
|
pk=pk, workspace__slug=slug, project_id=project_id
|
||||||
|
)
|
||||||
|
|
||||||
|
base64_data = request.data.get("description_binary")
|
||||||
|
|
||||||
|
if base64_data:
|
||||||
|
# Decode the base64 data to bytes
|
||||||
|
new_binary_data = base64.b64decode(base64_data)
|
||||||
|
|
||||||
|
# Store the updated binary data
|
||||||
|
issue.description_binary = new_binary_data
|
||||||
|
issue.description_html = request.data.get("description_html")
|
||||||
|
issue.save()
|
||||||
|
return Response({"message": "Updated successfully"})
|
||||||
|
else:
|
||||||
|
return Response({"error": "No binary data provided"})
|
||||||
|
@ -682,7 +682,7 @@ class IssueDescriptionViewSet(BaseViewSet):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def retrieve(self, request, slug, project_id, pk):
|
def retrieve(self, request, slug, project_id, pk):
|
||||||
issue = Issue.objects.get(
|
issue = Issue.issue_objects.get(
|
||||||
pk=pk, workspace__slug=slug, project_id=project_id
|
pk=pk, workspace__slug=slug, project_id=project_id
|
||||||
)
|
)
|
||||||
binary_data = issue.description_binary
|
binary_data = issue.description_binary
|
||||||
@ -702,7 +702,7 @@ class IssueDescriptionViewSet(BaseViewSet):
|
|||||||
return response
|
return response
|
||||||
|
|
||||||
def partial_update(self, request, slug, project_id, pk):
|
def partial_update(self, request, slug, project_id, pk):
|
||||||
issue = Issue.objects.get(
|
issue = Issue.issue_objects.get(
|
||||||
pk=pk, workspace__slug=slug, project_id=project_id
|
pk=pk, workspace__slug=slug, project_id=project_id
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
# Python imports
|
# Python imports
|
||||||
import json
|
import json
|
||||||
|
import base64
|
||||||
|
|
||||||
# Django imports
|
# Django imports
|
||||||
from django.contrib.postgres.aggregates import ArrayAgg
|
from django.contrib.postgres.aggregates import ArrayAgg
|
||||||
|
from django.http import StreamingHttpResponse
|
||||||
from django.contrib.postgres.fields import ArrayField
|
from django.contrib.postgres.fields import ArrayField
|
||||||
from django.core.serializers.json import DjangoJSONEncoder
|
from django.core.serializers.json import DjangoJSONEncoder
|
||||||
from django.db.models import (
|
from django.db.models import (
|
||||||
@ -366,3 +368,48 @@ class IssueDraftViewSet(BaseViewSet):
|
|||||||
origin=request.META.get("HTTP_ORIGIN"),
|
origin=request.META.get("HTTP_ORIGIN"),
|
||||||
)
|
)
|
||||||
return Response(status=status.HTTP_204_NO_CONTENT)
|
return Response(status=status.HTTP_204_NO_CONTENT)
|
||||||
|
|
||||||
|
|
||||||
|
class DraftIssueDescriptionViewSet(BaseViewSet):
|
||||||
|
permission_classes = [
|
||||||
|
ProjectEntityPermission,
|
||||||
|
]
|
||||||
|
|
||||||
|
def retrieve(self, request, slug, project_id, pk):
|
||||||
|
issue = Issue.objects.get(
|
||||||
|
pk=pk, workspace__slug=slug, project_id=project_id
|
||||||
|
)
|
||||||
|
binary_data = issue.description_binary
|
||||||
|
|
||||||
|
def stream_data():
|
||||||
|
if binary_data:
|
||||||
|
yield binary_data
|
||||||
|
else:
|
||||||
|
yield b""
|
||||||
|
|
||||||
|
response = StreamingHttpResponse(
|
||||||
|
stream_data(), content_type="application/octet-stream"
|
||||||
|
)
|
||||||
|
response["Content-Disposition"] = (
|
||||||
|
'attachment; filename="issue_description.bin"'
|
||||||
|
)
|
||||||
|
return response
|
||||||
|
|
||||||
|
def partial_update(self, request, slug, project_id, pk):
|
||||||
|
issue = Issue.objects.get(
|
||||||
|
pk=pk, workspace__slug=slug, project_id=project_id
|
||||||
|
)
|
||||||
|
|
||||||
|
base64_data = request.data.get("description_binary")
|
||||||
|
|
||||||
|
if base64_data:
|
||||||
|
# Decode the base64 data to bytes
|
||||||
|
new_binary_data = base64.b64decode(base64_data)
|
||||||
|
|
||||||
|
# Store the updated binary data
|
||||||
|
issue.description_binary = new_binary_data
|
||||||
|
issue.description_html = request.data.get("description_html")
|
||||||
|
issue.save()
|
||||||
|
return Response({"message": "Updated successfully"})
|
||||||
|
else:
|
||||||
|
return Response({"error": "No binary data provided"})
|
||||||
|
Loading…
Reference in New Issue
Block a user