mirror of
https://github.com/SectorLabs/django-localized-fields.git
synced 2025-04-24 19:32:53 +03:00
Copy the widget for each language
This commit is contained in:
parent
2393539b44
commit
13e2666a51
@ -1,4 +1,16 @@
|
|||||||
{% for widget in widget.subwidgets %}
|
{% with widget_id=widget.attrs.id %}
|
||||||
<label for="{{ widget.attrs.id }}">{{ widget.lang_name }}</label>
|
<div class="localized-fields-widget" role="tabs" data-synctabs="translation">
|
||||||
{% include widget.template_name %}
|
<ul class="localized-fields-widget tabs">
|
||||||
{% endfor %}
|
{% for widget in widget.subwidgets %}
|
||||||
|
<li class="localized-fields-widget tab">
|
||||||
|
<label for="{{ widget_id }}_{{ widget.lang_code }}">{{ widget.lang_name|capfirst }}</label>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% for widget in widget.subwidgets %}
|
||||||
|
<div role="tabpanel" id="{{ widget_id }}_{{ widget.lang_code }}">
|
||||||
|
{% include widget.template_name %}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endwith %}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import copy
|
||||||
|
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@ -16,7 +18,7 @@ class LocalizedFieldWidget(forms.MultiWidget):
|
|||||||
"""Initializes a new instance of :see:LocalizedFieldWidget."""
|
"""Initializes a new instance of :see:LocalizedFieldWidget."""
|
||||||
|
|
||||||
initial_widgets = [
|
initial_widgets = [
|
||||||
self.widget
|
copy.copy(self.widget)
|
||||||
for _ in settings.LANGUAGES
|
for _ in settings.LANGUAGES
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ class LocalizedFieldWidgetTestCase(TestCase):
|
|||||||
|
|
||||||
widget = LocalizedFieldWidget()
|
widget = LocalizedFieldWidget()
|
||||||
assert len(widget.widgets) == len(settings.LANGUAGES)
|
assert len(widget.widgets) == len(settings.LANGUAGES)
|
||||||
|
assert len(set(widget.widgets)) == len(widget.widgets)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def test_decompress():
|
def test_decompress():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user