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
Fix/10285 correct serialization of download url property for document model with direct wagtaildocs serve method config #10291
Fix/10285 correct serialization of download url property for document model with direct wagtaildocs serve method config #10291
Conversation
Manage this branch in SquashTest this branch here: https://swojak-afix10285-correct-seria-sbgzv.squash.io |
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.
Thanks for picking this up @Swojak-A! Just a couple of suggestions...
- Rather than adding a special case for
WAGTAILDOCS_SERVE_METHOD == 'direct'
within DocumentDownloadUrlField, I think it would be better to fix the get_full_url helper function to not add the base URL if it's already been passed a full URL. (This can simply check for it starting withhttp://
orhttps://
, like Django does here.) That way, we can be confident that this bug won't arise again in some other scenario in future (e.g. we introduce a new WAGTAILDOCS_SERVE_METHOD option that also returns absolute URLs). - The test code might be over-complicating things a bit - since we have control over the test setup and know exactly what URL we expect to get back, we can just do a
self.assertEqual(download_url, "http://remotestorage.com/media/...")
rather than the "is this a valid URL with only one http" checks.
@gasman No problem. I will modify the Pull Request accordingly. |
@Swojak-A when you get a moment, please also update the first line of the description. The content Thanks for working through the feedback. |
e112a04
to
1401e08
Compare
@gasman I've updated the Pull Request. Let me know pls, if there's still something to change. |
Thanks @Swojak-A! Have now merged in 0447b25, with some small tweaks:
I've added you to the contributors list as Swojak-A - please let me know if you'd like this changing to a different name. |
Fix #10285
Fixing the serialization of
download_url
property in Document model in case ofWAGTAILDOCS_SERVE_METHOD = "direct"
config turned on. Issue: click herePlease check the following:
make lint
from the Wagtail root.Please describe additional details for testing this change.
Footnotes
Development Testing ↩
Browser and device support ↩
Accessibility Target ↩