From 858a494765ef5274fdefec26811234aa75c55241 Mon Sep 17 00:00:00 2001 From: Kumi Date: Sat, 16 Nov 2024 21:48:06 +0100 Subject: [PATCH] refactor: Refactors registration status updates Replaces bulk update with individual model saves to possibly trigger save-related handlers or signals. Improves code consistency in registration approval process. --- src/synapse_registration/registration/admin.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/synapse_registration/registration/admin.py b/src/synapse_registration/registration/admin.py index cb17ff5..7ea1b3c 100644 --- a/src/synapse_registration/registration/admin.py +++ b/src/synapse_registration/registration/admin.py @@ -11,11 +11,17 @@ class UserRegistrationAdmin(admin.ModelAdmin): actions = ["approve_registrations", "deny_registrations"] def approve_registrations(self, request, queryset): - queryset.update(status=UserRegistration.STATUS_APPROVED) + for registration in queryset: + registration.status = UserRegistration.STATUS_APPROVED + registration.save() + self.message_user(request, f"{queryset.count()} registrations approved.") def deny_registrations(self, request, queryset): - queryset.update(status=UserRegistration.STATUS_DENIED) + for registration in queryset: + registration.status = UserRegistration.STATUS_DENIED + registration.save() + self.message_user(request, f"{queryset.count()} registrations denied.") approve_registrations.short_description = "Approve selected registrations"