dev: add cycle date validation (#442)

This commit is contained in:
pablohashescobar 2023-03-15 23:20:49 +05:30 committed by GitHub
parent d6aadb115d
commit 0082a98d53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -263,15 +263,20 @@ class CycleIssueViewSet(BaseViewSet):
class CycleDateCheckEndpoint(BaseAPIView): class CycleDateCheckEndpoint(BaseAPIView):
permission_classes = [ permission_classes = [
ProjectEntityPermission, ProjectEntityPermission,
] ]
def post(self, request, slug, project_id): def post(self, request, slug, project_id):
try: try:
start_date = request.data.get("start_date") start_date = request.data.get("start_date", False)
end_date = request.data.get("end_date") end_date = request.data.get("end_date", False)
if not start_date or not end_date:
return Response(
{"error": "Start date and end date both are required"},
status=status.HTTP_400_BAD_REQUEST,
)
cycles = Cycle.objects.filter( cycles = Cycle.objects.filter(
Q(start_date__lte=start_date, end_date__gte=start_date) Q(start_date__lte=start_date, end_date__gte=start_date)
@ -299,7 +304,6 @@ class CycleDateCheckEndpoint(BaseAPIView):
class CurrentUpcomingCyclesEndpoint(BaseAPIView): class CurrentUpcomingCyclesEndpoint(BaseAPIView):
permission_classes = [ permission_classes = [
ProjectEntityPermission, ProjectEntityPermission,
] ]
@ -342,12 +346,10 @@ class CurrentUpcomingCyclesEndpoint(BaseAPIView):
class CompletedCyclesEndpoint(BaseAPIView): class CompletedCyclesEndpoint(BaseAPIView):
permission_classes = [ permission_classes = [
ProjectEntityPermission, ProjectEntityPermission,
] ]
def get(self, request, slug, project_id): def get(self, request, slug, project_id):
try: try:
subquery = CycleFavorite.objects.filter( subquery = CycleFavorite.objects.filter(
@ -380,7 +382,6 @@ class CompletedCyclesEndpoint(BaseAPIView):
class DraftCyclesEndpoint(BaseAPIView): class DraftCyclesEndpoint(BaseAPIView):
permission_classes = [ permission_classes = [
ProjectEntityPermission, ProjectEntityPermission,
] ]
@ -407,7 +408,6 @@ class DraftCyclesEndpoint(BaseAPIView):
class CycleFavoriteViewSet(BaseViewSet): class CycleFavoriteViewSet(BaseViewSet):
permission_classes = [ permission_classes = [
ProjectEntityPermission, ProjectEntityPermission,
] ]