0001-views-translate-boolean-attributes-in-profile-58939.patch
src/authentic2/attribute_kinds.py | ||
---|---|---|
327 | 327 |
'serialize': lambda x: str(int(bool(x))), |
328 | 328 |
'deserialize': lambda x: bool(int(x)), |
329 | 329 |
'rest_framework_field_class': serializers.NullBooleanField, |
330 |
'html_value': lambda attribute, value: _('True') if value else _('False'), |
|
330 | 331 |
}, |
331 | 332 |
{ |
332 | 333 |
'label': _('date'), |
tests/test_profile.py | ||
---|---|---|
262 | 262 |
assert [x['href'] for x in response.html.find('div', {'id': 'a2-profile'}).find_all('a')] == [ |
263 | 263 |
reverse('profile_edit'), |
264 | 264 |
] |
265 | ||
266 | ||
267 |
def test_account_view_boolean(app, simple_user, settings): |
|
268 |
settings.LANGUAGE_CODE = 'fr' |
|
269 | ||
270 |
Attribute.objects.create( |
|
271 |
name='accept', label='Accept', kind='boolean', user_visible=True, user_editable=True |
|
272 |
) |
|
273 |
simple_user.attributes.accept = True |
|
274 | ||
275 |
utils.login(app, simple_user) |
|
276 |
resp = app.get(reverse('account_management')) |
|
277 |
assert 'Vrai' in resp.text |
|
278 | ||
279 |
simple_user.attributes.accept = False |
|
280 |
resp = app.get(reverse('account_management')) |
|
281 |
assert 'Vrai' not in resp.text |
|
265 |
- |