Skip to content

Commit

Permalink
Read APIs for Applications
Browse files Browse the repository at this point in the history
  • Loading branch information
ankurr0y committed Jan 19, 2024
1 parent e83e501 commit f370981
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/involvement/serializers/application_serializer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from involvement.models.application import Application
from rest_framework import serializers

#Role serializer
class ApplicationSerializer(serializers.ModelSerializer):
class Meta:
model = Application
fields = '__all__'
depth = 1

2 changes: 1 addition & 1 deletion src/involvement/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
router.register(r'^position2', views.position_api.Position2ViewSet, basename="Position2View")
router.register(r'^teams', views.team_read_api.TeamViewSet, basename="TeamsView")
router.register(r'^roles', views.role_read_api.RoleViewSet, basename="RolesView")

router.register(r'^application', views.application_api.ApplicationViewSet, basename="ApplicationView")

urlpatterns = [
re_path(
Expand Down
1 change: 1 addition & 0 deletions src/involvement/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
from .role_inspect_view import RoleInspectView
from .team_read_api import TeamViewSet
from .role_read_api import RoleViewSet
from .application_api import ApplicationViewSet
14 changes: 14 additions & 0 deletions src/involvement/views/application_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from rest_framework import viewsets
from involvement.serializers.application_serializer import ApplicationSerializer
from rest_framework.permissions import IsAuthenticated
from involvement.models.application import Application

#Role view
class ApplicationViewSet(viewsets.ReadOnlyModelViewSet):
serializer_class = ApplicationSerializer
permission_classes = [IsAuthenticated]

def get_queryset(self):
user = self.request.user
queryset = Application.objects.filter(applicant=user)
return queryset

0 comments on commit f370981

Please sign in to comment.