From 28cc0cd62b32eee8fa4a9e8113064ca72dcd1edf Mon Sep 17 00:00:00 2001 From: Eric Sherman <89405878+easherma-truth@users.noreply.github.com> Date: Tue, 20 Dec 2022 14:12:46 -0600 Subject: [PATCH] Check uid type in Field Locator and handle if str Currently nothing prevents a setup like ```WAGTAILTRANSFER_LOOKUP_FIELDS = {'wagtailcore.page': ['slug', 'locale_id']}``` from existing, but this will cause issues trying to look up and match the page due to how it's currently sent in the admin_url --- wagtail_transfer/locators.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/wagtail_transfer/locators.py b/wagtail_transfer/locators.py index 7be2e91..fc2879f 100644 --- a/wagtail_transfer/locators.py +++ b/wagtail_transfer/locators.py @@ -127,6 +127,12 @@ def uid_from_json(self, json_uid): def find(self, uid): # pair up field names with their respective items in the UID tuple, to form a filter dict # that we can use for an ORM lookup + if type(uid) == tuple: + filters = dict(zip(self.fields, uid)) + elif type(uid) == str: + # if lookup fields are configured for wagtailcore.page, then in the admin view those + # fields get passed along as a string + filters = dict(zip(self.fields, uid.split(","))) filters = dict(zip(self.fields, uid)) try: