Skip to content
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 duplicate locale defintion in TranslatableCreateView template #580

Merged
merged 3 commits into from Jun 5, 2022
Merged

Fix duplicate locale defintion in TranslatableCreateView template #580

merged 3 commits into from Jun 5, 2022

Conversation

ghost
Copy link

@ghost ghost commented May 27, 2022

This PR fixes #579, as it removes the duplicate definition of the "locale" parameter.

The "?locale=" parameter is already attached to the URL in the base template ("modeladmin/create.html"):
{% block form_action %}{{ view.create_url }}{% endblock %}{% if locale %}?locale={{ locale.language_code }}{% endif %}

As a result, it is currently not necessary to override the "form_action" block.

Removing the code ensures that the CreateView works again, and does not fail because of a malformed URL, ending in a 404 error.

…oing what we want.

Quite the opposite: Adding the locale parameter to the URL at this point will result in a malformed URL, which causes a defect of the Create View.
@zerolab
Copy link
Collaborator

zerolab commented May 29, 2022

Hey @benmth, thanks for this. Could you please add test for the fix?
This will ensure future changes don't undo the work

@codecov-commenter
Copy link

codecov-commenter commented May 29, 2022

Codecov Report

Merging #580 (4f3af21) into main (23d0bb7) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #580   +/-   ##
=======================================
  Coverage   91.55%   91.56%           
=======================================
  Files          47       47           
  Lines        3898     3899    +1     
  Branches      592      592           
=======================================
+ Hits         3569     3570    +1     
+ Misses        186      185    -1     
- Partials      143      144    +1     
Impacted Files Coverage Δ
wagtail_localize/modeladmin/tests.py 100.00% <100.00%> (ø)
wagtail_localize/views/convert.py 71.62% <0.00%> (ø)
wagtail_localize/wagtail_hooks.py 80.11% <0.00%> (ø)
wagtail_localize/views/edit_translation.py 85.44% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 23d0bb7...4f3af21. Read the comment docs.

@zerolab
Copy link
Collaborator

zerolab commented May 31, 2022

I tried to replicate the issue locally and cannot, so this most certainly needs test

@ghost
Copy link
Author

ghost commented Jun 1, 2022

Hey @zerolab,

i am not very experienced with testing, especially when it comes to Django templates.

Due to little time at the moment, a test from me will therefore unfortunately take some time, because I have to get acquainted first, to be able to deliver something useful.

@ghost
Copy link
Author

ghost commented Jun 4, 2022

Hey @zerolab,

again, sorry to keep you waiting.

I found the time to look at it today and was able to expand the tests accordingly.

In doing so, I then also extended the original change to respect Wagtail installations below version 3.0.

If there is still something to do from my side, please just let me know.

Copy link
Collaborator

@zerolab zerolab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice on @benmth!

@zerolab zerolab merged commit f2e5add into wagtail:main Jun 5, 2022
@zerolab zerolab added this to the 1.2.1 milestone Jun 5, 2022
@zerolab
Copy link
Collaborator

zerolab commented Jun 5, 2022

version 1.2.1 is now out

@ghost ghost deleted the fix-579_404-in-create-view branch June 5, 2022 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TranslatableCreateView gets Error 404 after submit
2 participants