-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check uid type in Field Locator and handle if str #132
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like this line would just override the new filters There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah yeah, that may just be a typo from when I copied my tested changes over to the patch :-) |
||
|
||
try: | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this issue only occur here: https://github.com/wagtail/wagtail-transfer/blob/main/wagtail_transfer/views.py#L314? In which case, I think it might be better for this method to assume a consistent type to the uid argument, and for the view/some other utility method to handle conversion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
although that is one place where I found the bug in practice, I'm not sure what the full implications would be for the rest of the codebase in using lookup field values for pages. But I agree if this is the only place that some sort of more testable utility method would be nice, but I'd need to either explore the codebase more or have help speccing that out to be confident in a solution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, it sounds like the key problem that this is solving is UID in query params (there may be other issues, but I think this fix only addresses that?). What happens if you change
request.GET.get
torequest.GET.getlist
? I'm wondering if that may solve the issue tooThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try playing with
request.GET.getlist
more, but at first test it didn't change the error