diff --git a/src/involvement/serializers/team_serializer.py b/src/involvement/serializers/team_serializer.py new file mode 100644 index 00000000..f92541a7 --- /dev/null +++ b/src/involvement/serializers/team_serializer.py @@ -0,0 +1,9 @@ +from involvement.models.team import Team +from rest_framework import serializers + +#Serializer for team +class TeamSerializer(serializers.ModelSerializer): + class Meta: + model = Team + fields = '__all__' + diff --git a/src/involvement/urls.py b/src/involvement/urls.py index b1929946..d9f01aae 100644 --- a/src/involvement/urls.py +++ b/src/involvement/urls.py @@ -2,9 +2,12 @@ from rest_framework import routers from involvement import views +#API URLs router = routers.SimpleRouter() router.register(r'^position', views.position_api.PositionViewSet, basename="PositionView") router.register(r'^position2', views.position_api.Position2ViewSet, basename="Position2View") +router.register(r'^teams', views.team_read_api.TeamViewSet, basename="Position2View") + urlpatterns = [ re_path( diff --git a/src/involvement/views/__init__.py b/src/involvement/views/__init__.py index cad3281c..3f33c5f2 100644 --- a/src/involvement/views/__init__.py +++ b/src/involvement/views/__init__.py @@ -16,3 +16,4 @@ from .application_edit_view import ApplicationEditView from .application_inspect_view import ApplicationInspectView from .role_inspect_view import RoleInspectView +from .team_read_api import TeamViewSet diff --git a/src/involvement/views/position_api.py b/src/involvement/views/position_api.py index 9d854f65..926e0870 100644 --- a/src/involvement/views/position_api.py +++ b/src/involvement/views/position_api.py @@ -1,6 +1,6 @@ -from rest_framework import viewsets, mixins +from rest_framework import viewsets from involvement.serializers.position_serializer import PositionSerializer, PositionDepthSerializer -from rest_framework.permissions import IsAuthenticatedOrReadOnly, +from rest_framework.permissions import IsAuthenticatedOrReadOnly from involvement.models.position import Position class PositionViewSet(viewsets.ReadOnlyModelViewSet): diff --git a/src/involvement/views/team_read_api.py b/src/involvement/views/team_read_api.py new file mode 100644 index 00000000..a4fb5f66 --- /dev/null +++ b/src/involvement/views/team_read_api.py @@ -0,0 +1,11 @@ +from rest_framework import viewsets +from involvement.serializers.team_serializer import TeamSerializer +from rest_framework.permissions import AllowAny +from involvement.models.team import Team + +#Read Teams API +class TeamViewSet(viewsets.ReadOnlyModelViewSet): + serializer_class = TeamSerializer + permission_classes = [AllowAny] + queryset = Team.objects.all() +