From 90568ae9012b3c5f5525fa673d9b010b3c928e66 Mon Sep 17 00:00:00 2001 From: William Gearty Date: Sat, 18 Jan 2025 11:43:56 -0500 Subject: [PATCH] Allow for comparisons with anonymous users (also Fixes #3800) --- esp/esp/users/models/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/esp/esp/users/models/__init__.py b/esp/esp/users/models/__init__.py index 5a023c6ec0..3b3b0d749a 100644 --- a/esp/esp/users/models/__init__.py +++ b/esp/esp/users/models/__init__.py @@ -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())