Merged in [15681] from rjsparks@nostrum.com:

Only do state-parent cross-validation on the group edit form when both fields are used on the form. (Many invocations of the form suppress all but one field.) Fixes #2597.
 - Legacy-Id: 15687
Note: SVN reference [15681] has been migrated to Git commit 16ae849d68
This commit is contained in:
Henrik Levkowetz 2018-11-03 05:42:01 +00:00
commit 42db540789

View file

@ -4,6 +4,8 @@ from __future__ import unicode_literals, print_function
# Stdlib imports
import re
import debug # pyflakes:ignore
# Django imports
from django import forms
from django.utils.html import mark_safe
@ -200,7 +202,7 @@ class GroupForm(forms.Form):
cleaned_data = super(GroupForm, self).clean()
state = cleaned_data.get('state', None)
parent = cleaned_data.get('parent', None)
if state and (state.slug in ['bof', ] and not parent):
if state and (state.slug in ['bof', ] and 'parent' in self.fields and not parent):
raise forms.ValidationError("You requested the creation of a BoF, but specified no parent area. A parent is required when creating a bof.")
return cleaned_data