class PermissionMixin:
    def has_perm(self, permission_name, obj_type=None, obj_id=None):
     
        if getattr(self, 'is_super_admin', False):
            return True

    
        for op in getattr(self, 'object_permissions', []):
            if op.permission_name == permission_name:
                if obj_type == op.object_type and obj_id == op.object_id:
                    return True

        for role in getattr(self, 'roles', []):
            for p in role.permissions:
                if p.permission_name == permission_name:
                    return True

        for group in getattr(self, 'groups', []):
            for role in group.roles:
                for p in role.permissions:
                    if p.permission_name == permission_name:
                        return True

        return False