Skip to content

Commit

Permalink
The Team API is needed as a publicly readable entity because the posi…
Browse files Browse the repository at this point in the history
…tions and the team descriptions are open to the public. If a new team is created or edited, it will most likely be through the admin console, meaning that we probably shouldn't have writeable APIs for this. Ludwig I'm writing this in a commit to show you that we need a ticketing system. In most ticketing systems you can set up an automation where referencing the ticket number will associate your commit to that ticket.
  • Loading branch information
ankurr0y committed Jan 17, 2024
1 parent a82dbf1 commit 6212353
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/involvement/serializers/team_serializer.py
Original file line number Diff line number Diff line change
@@ -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__'

3 changes: 3 additions & 0 deletions src/involvement/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
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 @@ -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
4 changes: 2 additions & 2 deletions src/involvement/views/position_api.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
11 changes: 11 additions & 0 deletions src/involvement/views/team_read_api.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 6212353

Please sign in to comment.