Fix /admin/ interface for registrations without user accounts
authorMagnus Hagander <magnus@hagander.net>
Fri, 29 Jun 2018 10:57:49 +0000 (12:57 +0200)
committerMagnus Hagander <magnus@hagander.net>
Fri, 29 Jun 2018 10:57:49 +0000 (12:57 +0200)
These can show up since we added the ability to register for somebody
else, and if such an account was made a volunteer of a conference, the
/admin/ interface would crash (the backend interface would still work,
which is how the data can get in there in the first place)

postgresqleu/confreg/lookups.py

index cf765b4c76e87100ee2ec8c7ce516512886ab837..f34b3b18adde182017085580b23ad2f96dab4dc8 100644 (file)
@@ -24,10 +24,10 @@ class RegistrationLookup(ModelLookup):
 
        def get_item_value(self, item):
                # Display for currently selected item
-               return u"%s (%s %s)" % (item.attendee.username, item.firstname, item.lastname)
+               return u"%s (%s %s)" % (item.attendee and item.attendee.username or '(no account)', item.firstname, item.lastname)
 
        def get_item_label(self, item):
                # Display for choice listings
-               return u"%s (%s %s)" % (item.attendee.username, item.firstname, item.lastname)
+               return u"%s (%s %s)" % (item.attendee and item.attendee.username or '(no account)', item.firstname, item.lastname)
 
 registry.register(RegistrationLookup)