Skip to content

Commit

Permalink
Fix duplicate locale defintion in TranslatableCreateView template (#580)
Browse files Browse the repository at this point in the history
* For Wagtail versions below 3.0, the locale must be added at this point.
* Extended "test_create_view" to also ensure a forrect form action URL

Co-authored-by: benmth <b@omegabyte.lu>
  • Loading branch information
b and benmth authored Jun 5, 2022
1 parent 5168e76 commit f2e5add
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{% extends "modeladmin/create.html" %}

{% block header %}
{% include "wagtailadmin/shared/header_with_locale_selector.html" with title=view.get_page_title subtitle=view.get_page_subtitle icon=view.header_icon tabbed=1 merged=1 %}
{% include "wagtailadmin/shared/header_with_locale_selector.html" with title=view.get_page_title subtitle=view.get_page_subtitle icon=view.header_icon tabbed=1 merged=1 %}
{% endblock %}

{% block form_action %}{{ view.create_url }}?locale={{ locale.language_code }}{% endblock %}
{% block form_action %}{{ view.create_url }}{% if wagtail_version < "3.0" %}?locale={{ locale.language_code }}{% endif %}{% endblock %}
7 changes: 7 additions & 0 deletions wagtail_localize/modeladmin/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ def test_create_view(self):
create_url = reverse("wagtail_localize_test_testmodel_modeladmin_create")
response = self.client.get(create_url)

# Check for correct Form Action
self.assertContains(
response,
'<form action="/admin/wagtail_localize_test/testmodel/create/?locale=en"',
)

# Check, if other Language is available in Dropdown
self.assertContains(
response,
'<a href="/admin/wagtail_localize_test/testmodel/create/?locale=de"',
Expand Down

0 comments on commit f2e5add

Please sign in to comment.