added logic to prevent deleting pages with FK to templates