Skip to content

Commit

Permalink
Allow for comparisons with anonymous users (also Fixes #3800)
Browse files Browse the repository at this point in the history
  • Loading branch information
willgearty committed Jan 18, 2025
1 parent dcb35e4 commit 90568ae
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions esp/esp/users/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,14 @@ def get_email_sendto_address(self):
return ESPUser.email_sendto_address(self.email, self.name())

def __cmp__(self, other):
# two anonymous users are equal
if isinstance(self, AnonymousESPUser) and isinstance(other, AnonymousESPUser):
return 0
# otherwise, rank the signed-in user higher
elif isinstance(other, AnonymousESPUser):
return 1
elif isinstance(self, AnonymousESPUser):
return -1
lastname = cmp(self.last_name.upper(), other.last_name.upper())
if lastname == 0:
return cmp(self.first_name.upper(), other.first_name.upper())
Expand Down

0 comments on commit 90568ae

Please sign in to comment.