0001-fix-displaying-custom-user-attributes-in-forms-7386.patch
src/authentic2/forms.py | ||
---|---|---|
93 | 93 |
form = BaseUserForm |
94 | 94 |
attributes = models.Attribute.objects.all() |
95 | 95 |
for attribute in attributes: |
96 |
if fields and attribute.name not in fields:
|
|
96 |
if attribute.name not in fields: |
|
97 | 97 |
continue |
98 | 98 |
d[attribute.name] = attribute.get_form_field() |
99 | 99 |
for field in app_settings.A2_REQUIRED_FIELDS: |
src/authentic2/tests.py | ||
---|---|---|
501 | 501 |
self.assertEqual(form['custom'].value(), 'random data') |
502 | 502 |
self.assertEqual(form['national_number'].value(), 'xx20153566342yy') |
503 | 503 | |
504 |
def test_noneditable_profile_attributes(self): |
|
505 |
""" |
|
506 |
tests if user non editable attributes do not appear in profile form |
|
507 |
""" |
|
508 | ||
509 |
models.Attribute.objects.create( |
|
510 |
label=u'custom', |
|
511 |
name='custom', |
|
512 |
required=False, |
|
513 |
user_editable=False, |
|
514 |
kind='string') |
|
515 |
models.Attribute.objects.create( |
|
516 |
label=u'ID', |
|
517 |
name='national_number', |
|
518 |
user_editable=False, |
|
519 |
user_visible=False, |
|
520 |
kind='string') |
|
521 | ||
522 |
self.assertTrue(self.client.login(username='testbot', password='secret')) |
|
523 |
response = self.client.get(reverse('profile_edit')) |
|
524 |
form = get_response_form(response) |
|
525 |
self.assertEqual(set(form.fields), set()) |
|
526 | ||
504 | 527 | |
505 | 528 |
class CacheTests(TestCase): |
506 | 529 |
urls = 'authentic2.cache_tests_urls' |
507 |
- |