0001-fix-displaying-custom-user-attributes-in-forms-7386.patch
src/authentic2/forms.py | ||
---|---|---|
99 | 99 |
bases = (BaseUserForm,) |
100 | 100 |
attributes = models.Attribute.objects.all() |
101 | 101 |
for attribute in attributes: |
102 |
if fields and attribute.name not in fields:
|
|
102 |
if attribute.name not in fields: |
|
103 | 103 |
continue |
104 | 104 |
d[attribute.name] = attribute.get_form_field() |
105 | 105 |
for field in app_settings.A2_REQUIRED_FIELDS: |
src/authentic2/tests.py | ||
---|---|---|
284 | 284 |
'password2': 'toto'}) |
285 | 285 |
self.assertEqual(response.status_code, 200) |
286 | 286 |
self.assertFormError(response, 'form', 'password1', ['password must contain at least 6 characters']) |
287 |
|
|
287 | ||
288 | 288 |
response = self.client.post(link, { 'password1': 'T0toto', |
289 | 289 |
'password2': 'T0toto'}) |
290 | 290 |
new_user = User.objects.get() |
... | ... | |
453 | 453 |
self.assertNotContains(response, 'John') |
454 | 454 | |
455 | 455 | |
456 |
class UserProfileTests(TestCase): |
|
457 |
def setUp(self): |
|
458 |
from django.contrib.auth import get_user_model |
|
459 |
User = get_user_model() |
|
460 |
user = User.objects.create(username='testbot') |
|
461 |
user.set_password('secret') |
|
462 |
user.save() |
|
463 |
self.client = Client() |
|
464 | ||
465 |
def test_noneditable_profile_attributes(self): |
|
466 |
models.Attribute.objects.create( |
|
467 |
label=u'custom', |
|
468 |
name='custom', |
|
469 |
required=False, |
|
470 |
user_editable=False, |
|
471 |
kind='string') |
|
472 |
models.Attribute.objects.create( |
|
473 |
label=u'ID', |
|
474 |
name='national_number', |
|
475 |
user_editable=False, |
|
476 |
user_visible=False, |
|
477 |
kind='string') |
|
478 | ||
479 |
self.assertTrue(self.client.login(username='testbot', password='secret')) |
|
480 | ||
481 |
response = self.client.get(reverse('profile_edit')) |
|
482 |
form = get_response_form(response) |
|
483 |
self.assertFalse(set(form.fields), set(['national_number', 'custom'])) |
|
484 | ||
485 | ||
456 | 486 |
class CacheTests(TestCase): |
457 | 487 |
urls = 'authentic2.cache_tests_urls' |
458 | 488 | |
459 |
- |