Merge pull request #892 from ostcar/issue-891
Fixed keyerror on user setting page
This commit is contained in:
commit
d926f4da07
@ -165,6 +165,7 @@ class UsersettingsForm(CssClassMixin, forms.ModelForm):
|
||||
language = forms.ChoiceField(choices=settings.LANGUAGES)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
kwargs['initial'] = kwargs.get('initial', {})
|
||||
kwargs['initial']['user_name'] = kwargs['instance'].username
|
||||
return super(UsersettingsForm, self).__init__(*args, **kwargs)
|
||||
|
||||
|
@ -122,3 +122,23 @@ class LockoutProtection(TestCase):
|
||||
form='form',
|
||||
field=None,
|
||||
errors='You can not remove the permission to manage participants from the last group your are in.')
|
||||
|
||||
|
||||
class TestUserSettings(TestCase):
|
||||
def setUp(self):
|
||||
self.admin = User.objects.get(pk=1)
|
||||
self.admin_client = Client()
|
||||
self.admin_client.login(username='admin', password='admin')
|
||||
|
||||
def test_get(self):
|
||||
response = self.admin_client.get('/usersettings/')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_pst(self):
|
||||
response = self.admin_client.post('/usersettings/', {
|
||||
'user_name': 'new_name',
|
||||
'language': 'de'})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
admin = User.objects.get(pk=1)
|
||||
self.assertEqual(admin.username, 'new_name')
|
||||
|
Loading…
Reference in New Issue
Block a user