From 5bea1c28e6abd6ce0cd556190302f091f0821c1a Mon Sep 17 00:00:00 2001 From: Laurent Date: Wed, 22 Jan 2025 12:00:30 +0100 Subject: [PATCH 1/2] adds method to return the club of the last event --- tournaments/models/custom_user.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tournaments/models/custom_user.py b/tournaments/models/custom_user.py index d0d4d41..e49d474 100644 --- a/tournaments/models/custom_user.py +++ b/tournaments/models/custom_user.py @@ -56,3 +56,9 @@ class CustomUser(AbstractUser): def full_name(self): return f"{self.first_name} {self.last_name}" + + def latest_event_club_name(self): + latest_event = self.event_set.order_by('-creation_date').first() + if latest_event and latest_event.club: + return latest_event.club.name + return None From 8e711c07efb22416468bd673a46dc0be18e053a0 Mon Sep 17 00:00:00 2001 From: Laurent Date: Wed, 22 Jan 2025 12:10:12 +0100 Subject: [PATCH 2/2] Adds club of last event of users --- tournaments/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tournaments/admin.py b/tournaments/admin.py index 922a0c5..2bfaf36 100644 --- a/tournaments/admin.py +++ b/tournaments/admin.py @@ -19,7 +19,7 @@ class CustomUserAdmin(UserAdmin): form = CustomUserChangeForm add_form = CustomUserCreationForm model = CustomUser - list_display = ['email', 'username', 'is_active', 'is_staff', 'first_name', 'last_name', 'date_joined', 'event_count'] + list_display = ['email', 'username', 'is_active', 'is_staff', 'first_name', 'last_name', 'date_joined', 'event_count', 'latest_event_club_name'] ordering = ['-date_joined'] fieldsets = [ (None, {'fields': ['id', 'username', 'email', 'password', 'first_name', 'last_name', 'is_active',