fix: allow all roles except 'user' on tech-passport endpoint

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
xoliqberdiyev
2026-05-05 17:47:39 +05:00
parent cb795fe3b8
commit 25e92623fd

View File

@@ -1,7 +1,7 @@
# rest framework # rest framework
from rest_framework.response import Response from rest_framework.response import Response
from rest_framework import status from rest_framework import status
from rest_framework.permissions import IsAuthenticated from rest_framework.permissions import BasePermission
from rest_framework.generics import GenericAPIView from rest_framework.generics import GenericAPIView
# swagger # swagger
@@ -10,11 +10,18 @@ from drf_spectacular.utils import extend_schema
# core apps # core apps
from core.services.tech_passport import TechPassportService from core.services.tech_passport import TechPassportService
from core.apps.evaluation.serializers import TechPassportSerializer from core.apps.evaluation.serializers import TechPassportSerializer
from core.apps.accounts.choices import RoleChoice
class IsNotUserRole(BasePermission):
def has_permission(self, request, view):
if not request.user or not request.user.is_authenticated:
return False
return request.user.role != RoleChoice.USER
class TechPassportAPIView(GenericAPIView): class TechPassportAPIView(GenericAPIView):
authentication_classes = [] permission_classes = [IsNotUserRole]
permission_classes = [IsAuthenticated]
@extend_schema( @extend_schema(
tags=["Tech Passport"], tags=["Tech Passport"],