Skip to content

Commit

Permalink
Add urls for views
Browse files Browse the repository at this point in the history
  • Loading branch information
SalmanAsh committed Jul 16, 2024
1 parent f5fb134 commit 9aa7142
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
4 changes: 4 additions & 0 deletions api/serializers/sign_agreement.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""
© Ocado Group
Created on 16/07/2024 at 09:05:55(+01:00).
"""
9 changes: 9 additions & 0 deletions api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@
from codeforlife.urls import get_urlpatterns
from rest_framework.routers import DefaultRouter

from .views import CheckAgreementViewSet

router = DefaultRouter()

router.register(
"check-agreement",
CheckAgreementViewSet,
basename="CheckAgreementViewSet",
)


urlpatterns = get_urlpatterns(router.urls)
2 changes: 2 additions & 0 deletions api/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
© Ocado Group
Created on 02/07/2024 at 11:59:45(+01:00).
"""

from .check_agreement import CheckAgreementViewSet
15 changes: 9 additions & 6 deletions api/views/check_agreement.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
from typing import Dict

import requests

# from codeforlife.request import Request
from codeforlife.permissions import AllowAny
from codeforlife.response import Response

# from codeforlife.user.models import User
from codeforlife.user.models import User
from codeforlife.views import ModelViewSet

# from django.http import HttpResponse
from rest_framework import status

from ..models import AgreementSignature, Contributor

# from rest_framework.views import APIView


class CheckAgreementViewSet(ModelViewSet):
class CheckAgreementViewSet(ModelViewSet[User, Contributor]):
"""
An endpoint to check if a contributor has signed latest agreement,
return OKAY if he has otherwise return the latest commit ID.
Expand Down Expand Up @@ -67,4 +67,7 @@ def get(self, request):
if latest_commit_id == latest_signature.agreement_id:
return Response(status=status.HTTP_200_OK)

return Response(status=status.HTTP_451_UNAVAILABLE_FOR_LEGAL_REASONS)
return Response(
data={"latest_commit_id: ": latest_commit_id},
status=status.HTTP_451_UNAVAILABLE_FOR_LEGAL_REASONS,
)

0 comments on commit 9aa7142

Please sign in to comment.