Skip to content

Commit e9158f8

Browse files
[WEB-2615] fix: module date validation during chart distribution generation (#5791)
* fix: module date validation while generating the chart distribution * chore: indentation fix --------- Co-authored-by: NarayanBavisetti <narayan3119@gmail.com>
1 parent 1e1733f commit e9158f8

File tree

3 files changed

+21
-25
lines changed

3 files changed

+21
-25
lines changed

apiserver/plane/app/views/module/base.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
# Module imports
3131
from plane.app.permissions import (
3232
ProjectEntityPermission,
33+
ProjectLitePermission,
3334
allow_permission,
3435
ROLE,
3536
)
@@ -317,13 +318,12 @@ def get_queryset(self):
317318
.order_by("-is_favorite", "-created_at")
318319
)
319320

320-
allow_permission(
321+
@allow_permission(
321322
[
322323
ROLE.ADMIN,
323324
ROLE.MEMBER,
324325
]
325326
)
326-
327327
def create(self, request, slug, project_id):
328328
project = Project.objects.get(workspace__slug=slug, pk=project_id)
329329
serializer = ModuleWriteSerializer(
@@ -386,8 +386,7 @@ def create(self, request, slug, project_id):
386386
return Response(module, status=status.HTTP_201_CREATED)
387387
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
388388

389-
allow_permission([ROLE.ADMIN, ROLE.MEMBER, ROLE.GUEST])
390-
389+
@allow_permission([ROLE.ADMIN, ROLE.MEMBER, ROLE.GUEST])
391390
def list(self, request, slug, project_id):
392391
queryset = self.get_queryset().filter(archived_at__isnull=True)
393392
if self.fields:
@@ -435,13 +434,7 @@ def list(self, request, slug, project_id):
435434
)
436435
return Response(modules, status=status.HTTP_200_OK)
437436

438-
allow_permission(
439-
[
440-
ROLE.ADMIN,
441-
ROLE.MEMBER,
442-
]
443-
)
444-
437+
@allow_permission([ROLE.ADMIN, ROLE.MEMBER])
445438
def retrieve(self, request, slug, project_id, pk):
446439
queryset = (
447440
self.get_queryset()
@@ -672,7 +665,13 @@ def retrieve(self, request, slug, project_id, pk):
672665
"labels": label_distribution,
673666
"completion_chart": {},
674667
}
675-
if modules and modules.start_date and modules.target_date:
668+
669+
if (
670+
modules
671+
and modules.start_date
672+
and modules.target_date
673+
and modules.total_issues > 0
674+
):
676675
data["distribution"]["completion_chart"] = burndown_plot(
677676
queryset=modules,
678677
slug=slug,
@@ -838,6 +837,9 @@ def get_queryset(self):
838837

839838
class ModuleFavoriteViewSet(BaseViewSet):
840839
model = UserFavorite
840+
permission_classes = [
841+
ProjectLitePermission,
842+
]
841843

842844
def get_queryset(self):
843845
return self.filter_queryset(

apiserver/plane/app/views/view/base.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,7 @@ def get_queryset(self):
431431
.distinct()
432432
)
433433

434-
allow_permission(allowed_roles=[ROLE.ADMIN, ROLE.MEMBER, ROLE.GUEST])
435-
434+
@allow_permission(allowed_roles=[ROLE.ADMIN, ROLE.MEMBER, ROLE.GUEST])
436435
def list(self, request, slug, project_id):
437436
queryset = self.get_queryset()
438437
project = Project.objects.get(id=project_id)
@@ -457,8 +456,7 @@ def list(self, request, slug, project_id):
457456
).data
458457
return Response(views, status=status.HTTP_200_OK)
459458

460-
allow_permission(allowed_roles=[ROLE.ADMIN, ROLE.MEMBER, ROLE.GUEST])
461-
459+
@allow_permission(allowed_roles=[ROLE.ADMIN, ROLE.MEMBER, ROLE.GUEST])
462460
def retrieve(self, request, slug, project_id, pk):
463461
issue_view = (
464462
self.get_queryset().filter(pk=pk, project_id=project_id).first()
@@ -498,8 +496,7 @@ def retrieve(self, request, slug, project_id, pk):
498496
status=status.HTTP_200_OK,
499497
)
500498

501-
allow_permission(allowed_roles=[], creator=True, model=IssueView)
502-
499+
@allow_permission(allowed_roles=[], creator=True, model=IssueView)
503500
def partial_update(self, request, slug, project_id, pk):
504501
with transaction.atomic():
505502
issue_view = IssueView.objects.select_for_update().get(
@@ -532,8 +529,7 @@ def partial_update(self, request, slug, project_id, pk):
532529
serializer.errors, status=status.HTTP_400_BAD_REQUEST
533530
)
534531

535-
allow_permission(allowed_roles=[ROLE.ADMIN], creator=True, model=IssueView)
536-
532+
@allow_permission(allowed_roles=[ROLE.ADMIN], creator=True, model=IssueView)
537533
def destroy(self, request, slug, project_id, pk):
538534
project_view = IssueView.objects.get(
539535
pk=pk,
@@ -578,8 +574,7 @@ def get_queryset(self):
578574
.select_related("view")
579575
)
580576

581-
allow_permission([ROLE.ADMIN, ROLE.MEMBER])
582-
577+
@allow_permission([ROLE.ADMIN, ROLE.MEMBER])
583578
def create(self, request, slug, project_id):
584579
_ = UserFavorite.objects.create(
585580
user=request.user,
@@ -589,8 +584,7 @@ def create(self, request, slug, project_id):
589584
)
590585
return Response(status=status.HTTP_204_NO_CONTENT)
591586

592-
allow_permission([ROLE.ADMIN, ROLE.MEMBER])
593-
587+
@allow_permission([ROLE.ADMIN, ROLE.MEMBER])
594588
def destroy(self, request, slug, project_id, view_id):
595589
view_favorite = UserFavorite.objects.get(
596590
project=project_id,

apiserver/plane/utils/analytics_plot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def burndown_plot(
203203
if module_id:
204204
# Get all dates between the two dates
205205
date_range = [
206-
(queryset.start_date + timedelta(days=x)).date()
206+
(queryset.start_date + timedelta(days=x))
207207
for x in range(
208208
(queryset.target_date - queryset.start_date).days + 1
209209
)

0 commit comments

Comments
 (0)