Skip to content

Commit

Permalink
Move case-change above user check
Browse files Browse the repository at this point in the history
  • Loading branch information
jace committed Oct 9, 2023
1 parent 084df80 commit a2f2024
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions funnel/forms/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}")

Expand Down

0 comments on commit a2f2024

Please sign in to comment.