Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
c534fcd
fix: workspace draft issues
NarayanBavisetti Sep 24, 2024
8ef1d14
Merge branch 'fix/workspace-draft-issues' of https://github.com/makep…
sharma01ketan Sep 24, 2024
1ac55ce
Merge branch 'preview' of github.com:makeplane/plane into fix/workspa…
NarayanBavisetti Sep 24, 2024
36b9c65
add service and store for workspace-drafts
sharma01ketan Sep 25, 2024
a45df67
Merge branch 'fix/workspace-draft-issues' of https://github.com/makep…
sharma01ketan Sep 25, 2024
715261e
add service type in draft store
sharma01ketan Sep 25, 2024
6ee6599
fix type for getDraftIssues because backend response is not paginated
sharma01ketan Sep 25, 2024
24684ed
chore: move to draft to issue
NarayanBavisetti Sep 26, 2024
986165a
Merge branch 'fix/workspace-draft-issues' of github.com:makeplane/pla…
NarayanBavisetti Sep 26, 2024
0bdb2d1
remove comment
sharma01ketan Sep 26, 2024
f3f481a
updated logic
sharma01ketan Sep 27, 2024
301be75
Merge branch 'fix/workspace-draft-issues' of https://github.com/makep…
sharma01ketan Sep 27, 2024
7b49ebb
add to dashboard
sharma01ketan Sep 27, 2024
bf331a2
update store
sharma01ketan Sep 27, 2024
5fa9edb
chore: added version field in cycle model
NarayanBavisetti Sep 30, 2024
54036fd
change in requirements
sharma01ketan Sep 30, 2024
65fcf5e
filter_store issue_store and respective constants
sharma01ketan Oct 1, 2024
3d8a9ab
Merge branch 'fix/workspace-draft-issues' of https://github.com/makep…
sharma01ketan Oct 1, 2024
5e41f0d
chore: paginated the draft issues
NarayanBavisetti Oct 1, 2024
edbb618
global-view-list rendered without filters
sharma01ketan Oct 1, 2024
8a8f5e0
add header to previous commit
sharma01ketan Oct 1, 2024
f612614
Merge branch 'fix/workspace-draft-issues' of https://github.com/makep…
sharma01ketan Oct 2, 2024
e693e55
minor updates
sharma01ketan Oct 2, 2024
b1cb6a4
fix label and cycle
sharma01ketan Oct 3, 2024
9dc936d
list render with partial quick actions
sharma01ketan Oct 4, 2024
f917fae
"fix cycle and label"
sharma01ketan Oct 4, 2024
5e5c3c1
Merge branch 'preview' of github.com:makeplane/plane into fix/workspa…
anmolsinghbhatia Oct 4, 2024
615f465
chore: workspace draft issue create modal fix and code refactor
anmolsinghbhatia Oct 4, 2024
076704d
Merge branch 'fix/workspace-draft-issues' of github.com:makeplane/pla…
anmolsinghbhatia Oct 4, 2024
c262859
fix: workspace draft issue create endpoint
anmolsinghbhatia Oct 4, 2024
0b15818
change modal storeType for draft
sharma01ketan Oct 4, 2024
9fac48e
fix: workspace draft issue move to issue action
anmolsinghbhatia Oct 4, 2024
876cbf4
Merge branch 'fix/workspace-draft-issues' of https://github.com/makep…
sharma01ketan Oct 4, 2024
d82c128
fix: workspace draft issue peek overview issue fetch
anmolsinghbhatia Oct 4, 2024
b5d2c76
Merge branch 'fix/workspace-draft-issues' of https://github.com/makep…
sharma01ketan Oct 4, 2024
08139a6
Quick Actions Completed
sharma01ketan Oct 4, 2024
54a5478
changes in modal
sharma01ketan Oct 4, 2024
c5516c9
code cleanup remove useless hooks
sharma01ketan Oct 4, 2024
b7b3bd8
fix row component api calls
sharma01ketan Oct 7, 2024
39eabc2
chore: only admin can changed the project settings (#5766)
NarayanBavisetti Oct 7, 2024
2f56027
chore: update cycle draft issue
NarayanBavisetti Oct 7, 2024
eb85c13
sidepeek fixes
sharma01ketan Oct 8, 2024
bfd5678
Merge branch 'fix/workspace-draft-issues' of https://github.com/makep…
sharma01ketan Oct 8, 2024
128e0dd
fix discard button modal draft creation
sharma01ketan Oct 8, 2024
67bc687
chore: code refactor
anmolsinghbhatia Oct 8, 2024
328b696
[WEB-2605] fix: update URL regex pattern to allow complex links. (#5767)
prateekshourya29 Oct 8, 2024
14d817e
Merge branch 'preview' of github.com:makeplane/plane into fix/workspa…
anmolsinghbhatia Oct 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions apiserver/plane/api/views/cycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def get(self, request, slug, project_id, pk=None):
# Incomplete Cycles
if cycle_view == "incomplete":
queryset = queryset.filter(
Q(end_date__gte=timezone.now().date())
Q(end_date__gte=timezone.now())
| Q(end_date__isnull=True),
)
return self.paginate(
Expand Down Expand Up @@ -311,7 +311,7 @@ def patch(self, request, slug, project_id, pk):

if (
cycle.end_date is not None
and cycle.end_date < timezone.now().date()
and cycle.end_date < timezone.now()
):
if "sort_order" in request_data:
# Can only change sort order
Expand Down Expand Up @@ -537,7 +537,7 @@ def post(self, request, slug, project_id, cycle_id):
cycle = Cycle.objects.get(
pk=cycle_id, project_id=project_id, workspace__slug=slug
)
if cycle.end_date >= timezone.now().date():
if cycle.end_date >= timezone.now():
return Response(
{"error": "Only completed cycles can be archived"},
status=status.HTTP_400_BAD_REQUEST,
Expand Down Expand Up @@ -1146,7 +1146,7 @@ def post(self, request, slug, project_id, cycle_id):

if (
new_cycle.end_date is not None
and new_cycle.end_date < timezone.now().date()
and new_cycle.end_date < timezone.now()
):
return Response(
{
Expand Down
6 changes: 6 additions & 0 deletions apiserver/plane/app/serializers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,9 @@
from .dashboard import DashboardSerializer, WidgetSerializer

from .favorite import UserFavoriteSerializer

from .draft import (
DraftIssueCreateSerializer,
DraftIssueSerializer,
DraftIssueDetailSerializer,
)
290 changes: 290 additions & 0 deletions apiserver/plane/app/serializers/draft.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,290 @@
# Django imports
from django.utils import timezone

# Third Party imports
from rest_framework import serializers

# Module imports
from .base import BaseSerializer
from plane.db.models import (
User,
Issue,
Label,
State,
DraftIssue,
DraftIssueAssignee,
DraftIssueLabel,
DraftIssueCycle,
DraftIssueModule,
)


class DraftIssueCreateSerializer(BaseSerializer):
# ids
state_id = serializers.PrimaryKeyRelatedField(
source="state",
queryset=State.objects.all(),
required=False,
allow_null=True,
)
parent_id = serializers.PrimaryKeyRelatedField(
source="parent",
queryset=Issue.objects.all(),
required=False,
allow_null=True,
)
label_ids = serializers.ListField(
child=serializers.PrimaryKeyRelatedField(queryset=Label.objects.all()),
write_only=True,
required=False,
)
assignee_ids = serializers.ListField(
child=serializers.PrimaryKeyRelatedField(queryset=User.objects.all()),
write_only=True,
required=False,
)

class Meta:
model = DraftIssue
fields = "__all__"
read_only_fields = [
"workspace",
"created_by",
"updated_by",
"created_at",
"updated_at",
]

def to_representation(self, instance):
data = super().to_representation(instance)
assignee_ids = self.initial_data.get("assignee_ids")
data["assignee_ids"] = assignee_ids if assignee_ids else []
label_ids = self.initial_data.get("label_ids")
data["label_ids"] = label_ids if label_ids else []
return data

def validate(self, data):
if (
data.get("start_date", None) is not None
and data.get("target_date", None) is not None
and data.get("start_date", None) > data.get("target_date", None)
):
raise serializers.ValidationError(
"Start date cannot exceed target date"
)
return data

def create(self, validated_data):
assignees = validated_data.pop("assignee_ids", None)
labels = validated_data.pop("label_ids", None)
modules = validated_data.pop("module_ids", None)
cycle_id = self.initial_data.get("cycle_id", None)
modules = self.initial_data.get("module_ids", None)

workspace_id = self.context["workspace_id"]
project_id = self.context["project_id"]

# Create Issue
issue = DraftIssue.objects.create(
**validated_data,
workspace_id=workspace_id,
project_id=project_id,
)

# Issue Audit Users
created_by_id = issue.created_by_id
updated_by_id = issue.updated_by_id

if assignees is not None and len(assignees):
DraftIssueAssignee.objects.bulk_create(
[
DraftIssueAssignee(
assignee=user,
draft_issue=issue,
workspace_id=workspace_id,
project_id=project_id,
created_by_id=created_by_id,
updated_by_id=updated_by_id,
)
for user in assignees
],
batch_size=10,
)

if labels is not None and len(labels):
DraftIssueLabel.objects.bulk_create(
[
DraftIssueLabel(
label=label,
draft_issue=issue,
project_id=project_id,
workspace_id=workspace_id,
created_by_id=created_by_id,
updated_by_id=updated_by_id,
)
for label in labels
],
batch_size=10,
)

if cycle_id is not None:
DraftIssueCycle.objects.create(
cycle_id=cycle_id,
draft_issue=issue,
project_id=project_id,
workspace_id=workspace_id,
created_by_id=created_by_id,
updated_by_id=updated_by_id,
)

if modules is not None and len(modules):
DraftIssueModule.objects.bulk_create(
[
DraftIssueModule(
module_id=module_id,
draft_issue=issue,
project_id=project_id,
workspace_id=workspace_id,
created_by_id=created_by_id,
updated_by_id=updated_by_id,
)
for module_id in modules
],
batch_size=10,
)

return issue

def update(self, instance, validated_data):
assignees = validated_data.pop("assignee_ids", None)
labels = validated_data.pop("label_ids", None)
cycle_id = self.context.get("cycle_id", None)
modules = self.initial_data.get("module_ids", None)

# Related models
workspace_id = instance.workspace_id
project_id = instance.project_id

created_by_id = instance.created_by_id
updated_by_id = instance.updated_by_id

if assignees is not None:
DraftIssueAssignee.objects.filter(draft_issue=instance).delete()
DraftIssueAssignee.objects.bulk_create(
[
DraftIssueAssignee(
assignee=user,
draft_issue=instance,
workspace_id=workspace_id,
project_id=project_id,
created_by_id=created_by_id,
updated_by_id=updated_by_id,
)
for user in assignees
],
batch_size=10,
)

if labels is not None:
DraftIssueLabel.objects.filter(draft_issue=instance).delete()
DraftIssueLabel.objects.bulk_create(
[
DraftIssueLabel(
label=label,
draft_issue=instance,
workspace_id=workspace_id,
project_id=project_id,
created_by_id=created_by_id,
updated_by_id=updated_by_id,
)
for label in labels
],
batch_size=10,
)

if cycle_id != "not_provided":
DraftIssueCycle.objects.filter(draft_issue=instance).delete()
if cycle_id is not None:
DraftIssueCycle.objects.create(
cycle_id=cycle_id,
draft_issue=instance,
workspace_id=workspace_id,
project_id=project_id,
created_by_id=created_by_id,
updated_by_id=updated_by_id,
)

if modules is not None:
DraftIssueModule.objects.filter(draft_issue=instance).delete()
DraftIssueModule.objects.bulk_create(
[
DraftIssueModule(
module_id=module_id,
draft_issue=instance,
workspace_id=workspace_id,
project_id=project_id,
created_by_id=created_by_id,
updated_by_id=updated_by_id,
)
for module_id in modules
],
batch_size=10,
)

# Time updation occurs even when other related models are updated
instance.updated_at = timezone.now()
return super().update(instance, validated_data)


class DraftIssueSerializer(BaseSerializer):
# ids
cycle_id = serializers.PrimaryKeyRelatedField(read_only=True)
module_ids = serializers.ListField(
child=serializers.UUIDField(),
required=False,
)

# Many to many
label_ids = serializers.ListField(
child=serializers.UUIDField(),
required=False,
)
assignee_ids = serializers.ListField(
child=serializers.UUIDField(),
required=False,
)

class Meta:
model = DraftIssue
fields = [
"id",
"name",
"state_id",
"sort_order",
"completed_at",
"estimate_point",
"priority",
"start_date",
"target_date",
"project_id",
"parent_id",
"cycle_id",
"module_ids",
"label_ids",
"assignee_ids",
"created_at",
"updated_at",
"created_by",
"updated_by",
]
read_only_fields = fields


class DraftIssueDetailSerializer(DraftIssueSerializer):
description_html = serializers.CharField()

class Meta(DraftIssueSerializer.Meta):
fields = DraftIssueSerializer.Meta.fields + [
"description_html",
]
read_only_fields = fields
23 changes: 0 additions & 23 deletions apiserver/plane/app/urls/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
IssueActivityEndpoint,
IssueArchiveViewSet,
IssueCommentViewSet,
IssueDraftViewSet,
IssueListEndpoint,
IssueReactionViewSet,
IssueRelationViewSet,
Expand Down Expand Up @@ -290,28 +289,6 @@
name="issue-relation",
),
## End Issue Relation
## Issue Drafts
path(
"workspaces/<str:slug>/projects/<uuid:project_id>/issue-drafts/",
IssueDraftViewSet.as_view(
{
"get": "list",
"post": "create",
}
),
name="project-issue-draft",
),
path(
"workspaces/<str:slug>/projects/<uuid:project_id>/issue-drafts/<uuid:pk>/",
IssueDraftViewSet.as_view(
{
"get": "retrieve",
"patch": "partial_update",
"delete": "destroy",
}
),
name="project-issue-draft",
),
path(
"workspaces/<str:slug>/projects/<uuid:project_id>/deleted-issues/",
DeletedIssuesListViewSet.as_view(),
Expand Down
Loading