Skip to content

Commit

Permalink
feat(access): add back and return_url urls to team metadata
Browse files Browse the repository at this point in the history
ref: #410 #411
  • Loading branch information
jon-nfc committed Nov 30, 2024
1 parent 22615e4 commit c8b6a31
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions app/access/viewsets/team.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from drf_spectacular.utils import extend_schema, extend_schema_view, OpenApiParameter, OpenApiResponse

from access.models import Organization

from access.serializers.teams import (
Team,
TeamModelSerializer,
Expand Down Expand Up @@ -124,6 +126,24 @@ class ViewSet( ModelViewSet ):

view_description = 'Teams belonging to a single organization'


def get_back_url(self) -> str:

if(
getattr(self, '_back_url', None) is None
):

return_model = Organization.objects.get(
pk = self.kwargs['organization_id']
)

self._back_url = str(
return_model.get_url( self.request )
)

return self._back_url


def get_queryset(self):

queryset = super().get_queryset()
Expand All @@ -146,3 +166,21 @@ def get_serializer_class(self):

return globals()[str( self.model._meta.verbose_name) + 'ModelSerializer']


def get_return_url(self) -> str:

if getattr(self, '_get_return_url', None):

return self._get_return_url

if self.kwargs.get('pk', None) is None:

return_model = Organization.objects.get(
pk = self.kwargs['organization_id']
)

self._get_return_url = return_model.get_url( self.request )

return self._get_return_url

return None

0 comments on commit c8b6a31

Please sign in to comment.