Merge pull request #667 from emanuelschuetze/NoEmptyFirstAndLastName
No empty first and last name
This commit is contained in:
commit
3ccb8755e3
@ -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):
|
||||||
"""
|
"""
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
{% if form.non_field_errors %}
|
||||||
|
<div class="alert alert-error">
|
||||||
|
<button type="button" class="close" data-dismiss="alert">×</button>
|
||||||
|
{% for msg in form.non_field_errors %}
|
||||||
|
{{ msg }}
|
||||||
|
{% if not forloop.last %}<br />{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% for field in form %}
|
{% for field in form %}
|
||||||
<div class="control-group {% if field.errors %}error{% endif%}">
|
<div class="control-group {% if field.errors %}error{% endif%}">
|
||||||
<label for="id_{{ field.name }}">{{ field.label }}{% if field.field.required %}<span class="required">*</span>{% endif %}:</label>
|
<label for="id_{{ field.name }}">{{ field.label }}{% if field.field.required %}<span class="required">*</span>{% endif %}:</label>
|
||||||
|
Loading…
Reference in New Issue
Block a user