from apps.system.permission import RbacPermission, has_permission
from .models import *

class IsSubInspectTaskLeader(RbacPermission):
    def has_object_permission(self, request, view, obj):
        if InspectTeam.objects.filter(subtask=obj.subtask, type='组长').first().member == request.user:
            # 如果是组长
            return True
        return False

class IsInspectRecordChecker(RbacPermission):
    def has_object_permission(self, request, view, obj):
        if obj.checker == request.user or obj.checker == None:
            return True
        return False