def METHOD_NAME(self, permission):
    """
    Helper function to check if the user has the appropriate permission
    """
    if not self.roles.filter(
            Q(role_permissions__permission__code=permission)):
        return False
    return True