Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WEB-2615] fix: module date validation during chart distribution generation #5791

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 14 additions & 12 deletions apiserver/plane/app/views/module/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
# Module imports
from plane.app.permissions import (
ProjectEntityPermission,
ProjectLitePermission,
allow_permission,
ROLE,
)
Expand Down Expand Up @@ -317,13 +318,12 @@ def get_queryset(self):
.order_by("-is_favorite", "-created_at")
)

allow_permission(
@allow_permission(
[
ROLE.ADMIN,
ROLE.MEMBER,
]
)

def create(self, request, slug, project_id):
project = Project.objects.get(workspace__slug=slug, pk=project_id)
serializer = ModuleWriteSerializer(
Expand Down Expand Up @@ -386,8 +386,7 @@ def create(self, request, slug, project_id):
return Response(module, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)

allow_permission([ROLE.ADMIN, ROLE.MEMBER, ROLE.GUEST])

@allow_permission([ROLE.ADMIN, ROLE.MEMBER, ROLE.GUEST])
def list(self, request, slug, project_id):
queryset = self.get_queryset().filter(archived_at__isnull=True)
if self.fields:
Expand Down Expand Up @@ -435,13 +434,7 @@ def list(self, request, slug, project_id):
)
return Response(modules, status=status.HTTP_200_OK)

allow_permission(
[
ROLE.ADMIN,
ROLE.MEMBER,
]
)

@allow_permission([ROLE.ADMIN, ROLE.MEMBER])
def retrieve(self, request, slug, project_id, pk):
queryset = (
self.get_queryset()
Expand Down Expand Up @@ -672,7 +665,13 @@ def retrieve(self, request, slug, project_id, pk):
"labels": label_distribution,
"completion_chart": {},
}
if modules and modules.start_date and modules.target_date:

if (
modules
and modules.start_date
and modules.target_date
and modules.total_issues > 0
):
data["distribution"]["completion_chart"] = burndown_plot(
queryset=modules,
slug=slug,
Expand Down Expand Up @@ -838,6 +837,9 @@ def get_queryset(self):

class ModuleFavoriteViewSet(BaseViewSet):
model = UserFavorite
permission_classes = [
ProjectLitePermission,
]

def get_queryset(self):
return self.filter_queryset(
Expand Down
18 changes: 6 additions & 12 deletions apiserver/plane/app/views/view/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,7 @@ def get_queryset(self):
.distinct()
)

allow_permission(allowed_roles=[ROLE.ADMIN, ROLE.MEMBER, ROLE.GUEST])

@allow_permission(allowed_roles=[ROLE.ADMIN, ROLE.MEMBER, ROLE.GUEST])
def list(self, request, slug, project_id):
NarayanBavisetti marked this conversation as resolved.
Show resolved Hide resolved
queryset = self.get_queryset()
project = Project.objects.get(id=project_id)
Expand All @@ -457,8 +456,7 @@ def list(self, request, slug, project_id):
).data
return Response(views, status=status.HTTP_200_OK)

allow_permission(allowed_roles=[ROLE.ADMIN, ROLE.MEMBER, ROLE.GUEST])

@allow_permission(allowed_roles=[ROLE.ADMIN, ROLE.MEMBER, ROLE.GUEST])
def retrieve(self, request, slug, project_id, pk):
NarayanBavisetti marked this conversation as resolved.
Show resolved Hide resolved
issue_view = (
self.get_queryset().filter(pk=pk, project_id=project_id).first()
Expand Down Expand Up @@ -498,8 +496,7 @@ def retrieve(self, request, slug, project_id, pk):
status=status.HTTP_200_OK,
)

allow_permission(allowed_roles=[], creator=True, model=IssueView)

@allow_permission(allowed_roles=[], creator=True, model=IssueView)
def partial_update(self, request, slug, project_id, pk):
with transaction.atomic():
NarayanBavisetti marked this conversation as resolved.
Show resolved Hide resolved
issue_view = IssueView.objects.select_for_update().get(
Expand Down Expand Up @@ -532,8 +529,7 @@ def partial_update(self, request, slug, project_id, pk):
serializer.errors, status=status.HTTP_400_BAD_REQUEST
)

allow_permission(allowed_roles=[ROLE.ADMIN], creator=True, model=IssueView)

@allow_permission(allowed_roles=[ROLE.ADMIN], creator=True, model=IssueView)
def destroy(self, request, slug, project_id, pk):
project_view = IssueView.objects.get(
NarayanBavisetti marked this conversation as resolved.
Show resolved Hide resolved
pk=pk,
Expand Down Expand Up @@ -578,8 +574,7 @@ def get_queryset(self):
.select_related("view")
)

allow_permission([ROLE.ADMIN, ROLE.MEMBER])

@allow_permission([ROLE.ADMIN, ROLE.MEMBER])
def create(self, request, slug, project_id):
NarayanBavisetti marked this conversation as resolved.
Show resolved Hide resolved
_ = UserFavorite.objects.create(
user=request.user,
Expand All @@ -589,8 +584,7 @@ def create(self, request, slug, project_id):
)
return Response(status=status.HTTP_204_NO_CONTENT)

allow_permission([ROLE.ADMIN, ROLE.MEMBER])

@allow_permission([ROLE.ADMIN, ROLE.MEMBER])
def destroy(self, request, slug, project_id, view_id):
view_favorite = UserFavorite.objects.get(
project=project_id,
Expand Down
2 changes: 1 addition & 1 deletion apiserver/plane/utils/analytics_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def burndown_plot(
if module_id:
# Get all dates between the two dates
date_range = [
(queryset.start_date + timedelta(days=x)).date()
(queryset.start_date + timedelta(days=x))
for x in range(
(queryset.target_date - queryset.start_date).days + 1
)
Expand Down
Loading