Skip to content

Commit

Permalink
chore: add permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
asadali145 committed Nov 29, 2024
1 parent 8762f75 commit 5af90fb
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions courses/views/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from mitol.digitalcredentials.mixins import DigitalCredentialsRequestViewSetMixin
from rest_framework import status, viewsets
from rest_framework.authentication import SessionAuthentication
from rest_framework.permissions import IsAuthenticated
from rest_framework.permissions import IsAdminUser, IsAuthenticated
from rest_framework.response import Response
from rest_framework.views import APIView

Expand Down Expand Up @@ -210,13 +210,12 @@ class EmeritusCourseListView(APIView):
ReadOnly View to list Emeritus courses.
"""

permission_classes = [IsAdminUser]

def get(self, request, *args, **kwargs): # noqa: ARG002
"""
Get Emeritus courses list from the Emeritus API and return it.
"""
if not request.user.is_authenticated or not request.user.is_superuser:
return Response(status=status.HTTP_401_UNAUTHORIZED)

try:
data = fetch_emeritus_courses()
return Response(data, status=status.HTTP_200_OK)
Expand Down

0 comments on commit 5af90fb

Please sign in to comment.