Skip to content

Commit

Permalink
feat: task list api endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Shavkatjon-O committed Sep 11, 2024
1 parent e5cf82b commit a14b774
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions apps/planners/api/TaskList/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .views import *
19 changes: 19 additions & 0 deletions apps/planners/api/TaskList/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from rest_framework import serializers
from apps.planners.models import Task


class TaskSerializer(serializers.ModelSerializer):
class Meta:
model = Task
fields = (
"id",
"title",
"description",
"status",
"due_date",
"completed_date",
"created_by",
)


__all__ = ("TaskSerializer",)
16 changes: 16 additions & 0 deletions apps/planners/api/TaskList/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from rest_framework.generics import ListAPIView
from rest_framework.permissions import IsAuthenticated

from apps.planners.api.TaskList.serializers import TaskSerializer
from apps.planners.models import Task


class TaskListAPIView(ListAPIView):
serializer_class = TaskSerializer
permission_classes = (IsAuthenticated,)

def get_queryset(self):
return Task.objects.filter(created_by=self.request.user)


__all__ = ("TaskListAPIView",)
1 change: 1 addition & 0 deletions apps/planners/api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .TaskList import *
7 changes: 7 additions & 0 deletions apps/planners/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.urls import path

from apps.planners.api.TaskList.views import TaskListAPIView

urlpatterns = [
path("", TaskListAPIView.as_view(), name="task-list"),
]

0 comments on commit a14b774

Please sign in to comment.