views: translate boolean attributes in profile (#58939)
This commit is contained in:
parent
d80c5ef988
commit
026c90d93d
|
@ -327,6 +327,7 @@ DEFAULT_ATTRIBUTE_KINDS = [
|
|||
'serialize': lambda x: str(int(bool(x))),
|
||||
'deserialize': lambda x: bool(int(x)),
|
||||
'rest_framework_field_class': serializers.NullBooleanField,
|
||||
'html_value': lambda attribute, value: _('True') if value else _('False'),
|
||||
},
|
||||
{
|
||||
'label': _('date'),
|
||||
|
|
|
@ -262,3 +262,20 @@ def test_account_view(app, simple_user, settings):
|
|||
assert [x['href'] for x in response.html.find('div', {'id': 'a2-profile'}).find_all('a')] == [
|
||||
reverse('profile_edit'),
|
||||
]
|
||||
|
||||
|
||||
def test_account_view_boolean(app, simple_user, settings):
|
||||
settings.LANGUAGE_CODE = 'fr'
|
||||
|
||||
Attribute.objects.create(
|
||||
name='accept', label='Accept', kind='boolean', user_visible=True, user_editable=True
|
||||
)
|
||||
simple_user.attributes.accept = True
|
||||
|
||||
utils.login(app, simple_user)
|
||||
resp = app.get(reverse('account_management'))
|
||||
assert 'Vrai' in resp.text
|
||||
|
||||
simple_user.attributes.accept = False
|
||||
resp = app.get(reverse('account_management'))
|
||||
assert 'Vrai' not in resp.text
|
||||
|
|
Loading…
Reference in New Issue