diff --git a/funnel/forms/organization.py b/funnel/forms/organization.py index 840530bb8..077b96454 100644 --- a/funnel/forms/organization.py +++ b/funnel/forms/organization.py @@ -61,6 +61,13 @@ def validate_name(self, field: forms.Field) -> None: ) if reason == 'reserved': raise forms.validators.ValidationError(_("This name is reserved")) + if ( + self.edit_obj + and self.edit_obj.name + and field.data.lower() == self.edit_obj.name.lower() + ): + # Name has only changed case from previous name. This is a validation pass + return if reason == 'user': if ( self.edit_user.username @@ -82,13 +89,6 @@ def validate_name(self, field: forms.Field) -> None: raise forms.validators.ValidationError( _("This name has been taken by another organization") ) - if ( - self.edit_obj - and self.edit_obj.name - and field.data.lower() == self.edit_obj.name.lower() - ): - # Name has only changed case from previous name. This is a validation pass - return # We're not supposed to get an unknown reason. Flag error to developers. raise ValueError(f"Unknown account name validation failure reason: {reason}")