@@ -0,0 +1,8 @@ | |||||
from rest_framework import serializers | |||||
from .models import Project | |||||
class ProjectSerializers(serializers.ModelSerializer): | |||||
class Meta: | |||||
model = Project | |||||
fields = ['id', 'name', 'project_image', 'client', 'total_compensation', 'start_date', 'end_date'] |
@@ -0,0 +1,6 @@ | |||||
from django.urls import path | |||||
from . import views | |||||
urlpatterns = [ | |||||
path('projects/', views.ProjectList.as_view()), | |||||
] |
@@ -1,3 +1,16 @@ | |||||
from django.shortcuts import render | |||||
from rest_framework.response import Response | |||||
from rest_framework.views import APIView | |||||
from rest_framework.authentication import TokenAuthentication, SessionAuthentication | |||||
from rest_framework.permissions import IsAuthenticated | |||||
from .models import Project | |||||
from .serializers import ProjectSerializers | |||||
# Create your views here. | |||||
class ProjectList(APIView): | |||||
authentication_classes = [TokenAuthentication, SessionAuthentication] | |||||
permission_classes = [IsAuthenticated] | |||||
def get(self, request): | |||||
projects = Project.objects.all() | |||||
serializer = ProjectSerializers(projects, many=True) | |||||
return Response(serializer.data) |
@@ -5,6 +5,7 @@ from drf_yasg.views import get_schema_view | |||||
from drf_yasg import openapi | from drf_yasg import openapi | ||||
from client import urls as clientUrls | from client import urls as clientUrls | ||||
from employee import urls as employeeUrls | from employee import urls as employeeUrls | ||||
from project import urls as projectUrls | |||||
schema_view = get_schema_view( | schema_view = get_schema_view( | ||||
@@ -29,7 +30,8 @@ urlpatterns = [ | |||||
path('redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'), | path('redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'), | ||||
path('api/', include([ | path('api/', include([ | ||||
path('', include(clientUrls)), | path('', include(clientUrls)), | ||||
path('', include(employeeUrls)) | |||||
path('', include(employeeUrls)), | |||||
path('', include(projectUrls)) | |||||
])) | ])) | ||||
])), | ])), | ||||
] | ] |