Ensure that the user has either a first name or a last name
This commit is contained in:
parent
41abe871dd
commit
bf58f2a6cc
@ -35,6 +35,16 @@ class UserCreateForm(CssClassMixin, forms.ModelForm):
|
|||||||
'groups', 'structure_level', 'committee', 'about_me', 'comment',
|
'groups', 'structure_level', 'committee', 'about_me', 'comment',
|
||||||
'is_active', 'default_password')
|
'is_active', 'default_password')
|
||||||
|
|
||||||
|
def clean(self, *args, **kwargs):
|
||||||
|
"""
|
||||||
|
Ensures that a user has either a first name or a last name.
|
||||||
|
"""
|
||||||
|
cleaned_data = super(UserCreateForm, self).clean(*args, **kwargs)
|
||||||
|
if not cleaned_data['first_name'] and not cleaned_data['last_name']:
|
||||||
|
error_msg = _('First name and last name can not both be empty.')
|
||||||
|
raise forms.ValidationError(error_msg)
|
||||||
|
return cleaned_data
|
||||||
|
|
||||||
|
|
||||||
class UserUpdateForm(UserCreateForm):
|
class UserUpdateForm(UserCreateForm):
|
||||||
"""
|
"""
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<form action="" method="post">{% csrf_token %}
|
<form action="" method="post">{% csrf_token %}
|
||||||
|
{{ form.non_field_errors }}
|
||||||
{% include "form.html" %}
|
{% include "form.html" %}
|
||||||
{% if edit_user %}
|
{% if edit_user %}
|
||||||
<p style="margin: -15px 0 25px 0;">
|
<p style="margin: -15px 0 25px 0;">
|
||||||
|
Loading…
Reference in New Issue
Block a user