mirror of
https://github.com/makeplane/plane.git
synced 2026-07-12 13:29:56 +02:00
fix: issue attchment list query in graphql (#1518)
This commit is contained in:
@@ -11,7 +11,6 @@ from .base import BaseModel
|
||||
|
||||
|
||||
def get_upload_path(instance, filename):
|
||||
|
||||
if instance.workspace_id is not None:
|
||||
return f"{instance.workspace.id}/{uuid4().hex}-{filename}"
|
||||
return f"user-{uuid4().hex}-{filename}"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from .relation import IssueRelationQuery
|
||||
from .search import IssuesSearchQuery
|
||||
from .sub_issue import SubIssuesQuery
|
||||
from .sub_issue import SubIssuesQuery
|
||||
from .attachment import IssueAttachmentQuery
|
||||
@@ -10,7 +10,7 @@ from strawberry.permission import PermissionExtension
|
||||
|
||||
# Module Imports
|
||||
from plane.db.models import FileAsset
|
||||
from plane.graphql.types.attachment import IssueAttachmentType
|
||||
from plane.graphql.types.issues.attachment import IssueAttachmentType
|
||||
from plane.graphql.permissions.project import ProjectBasePermission
|
||||
|
||||
|
||||
@@ -19,20 +19,23 @@ class IssueAttachmentQuery:
|
||||
@strawberry.field(
|
||||
extensions=[PermissionExtension(permissions=[ProjectBasePermission()])]
|
||||
)
|
||||
async def issueAttachment(
|
||||
async def issue_attachment(
|
||||
self,
|
||||
info: Info,
|
||||
slug: str,
|
||||
project: strawberry.ID,
|
||||
issue: strawberry.ID,
|
||||
) -> list[IssueAttachmentType]:
|
||||
|
||||
print("---*___")
|
||||
print("Attachment query")
|
||||
print("---*___")
|
||||
issue_attachments = await sync_to_async(list)(
|
||||
FileAsset.objects.filter(
|
||||
entity_identifier=issue,
|
||||
entity_type=FileAsset.EntityTypeContext.ISSUE_ATTACHMENT,
|
||||
workspace__slug=slug,
|
||||
project_id=project,
|
||||
entity_type=FileAsset.EntityTypeContext.ISSUE_ATTACHMENT,
|
||||
issue=issue,
|
||||
)
|
||||
)
|
||||
|
||||
return issue_attachments
|
||||
@@ -38,13 +38,13 @@ from .queries.module import (
|
||||
ModuleIssueUserPropertyQuery,
|
||||
)
|
||||
from .queries.search import GlobalSearchQuery
|
||||
from .queries.attachment import IssueAttachmentQuery
|
||||
from .queries.link import IssueLinkQuery
|
||||
from .queries.estimate import EstimatePointQuery
|
||||
from .queries.issues import (
|
||||
IssueRelationQuery,
|
||||
IssuesSearchQuery,
|
||||
SubIssuesQuery,
|
||||
IssueAttachmentQuery,
|
||||
)
|
||||
from .queries.dashboard import userInformationQuery
|
||||
from .queries.external import UnsplashImagesQuery, ProjectCoversQuery
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
# python imports
|
||||
from typing import Optional
|
||||
from datetime import datetime
|
||||
|
||||
# Strawberry imports
|
||||
import strawberry
|
||||
import strawberry_django
|
||||
from strawberry.scalars import JSON
|
||||
|
||||
# Module Imports
|
||||
from plane.db.models import FileAsset
|
||||
|
||||
|
||||
@strawberry_django.type(FileAsset)
|
||||
class IssueAttachmentType:
|
||||
id: strawberry.ID
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
attributes: Optional[JSON]
|
||||
asset: str
|
||||
external_source: Optional[str]
|
||||
external_id: Optional[strawberry.ID]
|
||||
created_by: strawberry.ID
|
||||
updated_by: strawberry.ID
|
||||
project: strawberry.ID
|
||||
workspace: strawberry.ID
|
||||
entity_identifier: strawberry.ID
|
||||
entity_type: str
|
||||
|
||||
@strawberry.field
|
||||
def workspace(self) -> int:
|
||||
return self.workspace_id
|
||||
|
||||
@strawberry.field
|
||||
def project(self) -> int:
|
||||
return self.project_id
|
||||
|
||||
@strawberry.field
|
||||
def issue(self) -> int:
|
||||
return self.entity_identifier
|
||||
|
||||
@strawberry.field
|
||||
def created_by(self) -> int:
|
||||
return self.created_by_id
|
||||
|
||||
@strawberry.field
|
||||
def updated_by(self) -> int:
|
||||
return self.updated_by_id
|
||||
64
apiserver/plane/graphql/types/issues/attachment.py
Normal file
64
apiserver/plane/graphql/types/issues/attachment.py
Normal file
@@ -0,0 +1,64 @@
|
||||
# python imports
|
||||
from typing import Optional
|
||||
|
||||
# Strawberry imports
|
||||
import strawberry
|
||||
import strawberry_django
|
||||
from strawberry.scalars import JSON
|
||||
|
||||
# Module Imports
|
||||
from plane.db.models import FileAsset
|
||||
|
||||
|
||||
@strawberry_django.type(FileAsset)
|
||||
class IssueAttachmentType:
|
||||
id: strawberry.ID
|
||||
user: strawberry.ID
|
||||
workspace: strawberry.ID
|
||||
draft_issue: strawberry.ID
|
||||
project: strawberry.ID
|
||||
issue: strawberry.ID
|
||||
comment: strawberry.ID
|
||||
page: strawberry.ID
|
||||
|
||||
attributes: Optional[JSON]
|
||||
asset: str
|
||||
entity_type: str
|
||||
is_deleted: bool
|
||||
is_archived: bool
|
||||
|
||||
size: float
|
||||
is_uploaded: bool
|
||||
storage_metadata: Optional[JSON]
|
||||
asset_url: Optional[str]
|
||||
|
||||
external_id: strawberry.ID
|
||||
external_source: str
|
||||
|
||||
@strawberry.field
|
||||
def user(self):
|
||||
return self.user_id
|
||||
|
||||
@strawberry.field
|
||||
def workspace(self):
|
||||
return self.workspace_id
|
||||
|
||||
@strawberry.field
|
||||
def draft_issue(self):
|
||||
return self.draft_issue_id
|
||||
|
||||
@strawberry.field
|
||||
def project(self):
|
||||
return self.project_id
|
||||
|
||||
@strawberry.field
|
||||
def issue(self):
|
||||
return self.external_id
|
||||
|
||||
@strawberry.field
|
||||
def comment(self):
|
||||
return self.comment_id
|
||||
|
||||
@strawberry.field
|
||||
def page(self):
|
||||
return self.page_id
|
||||
Reference in New Issue
Block a user