diff --git a/openslides/participant/forms.py b/openslides/participant/forms.py index bff479fdd..72710bf3d 100644 --- a/openslides/participant/forms.py +++ b/openslides/participant/forms.py @@ -35,6 +35,16 @@ class UserCreateForm(CssClassMixin, forms.ModelForm): 'groups', 'structure_level', 'committee', 'about_me', 'comment', '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): """ diff --git a/openslides/participant/templates/participant/edit.html b/openslides/participant/templates/participant/edit.html index d0dfc143a..6d890dae1 100644 --- a/openslides/participant/templates/participant/edit.html +++ b/openslides/participant/templates/participant/edit.html @@ -24,6 +24,7 @@
{% csrf_token %} + {{ form.non_field_errors }} {% include "form.html" %} {% if edit_user %}