From 02caf579fe44a7a96f788dbe275daccfc0d1e424 Mon Sep 17 00:00:00 2001 From: Ishaan Mittal Date: Thu, 17 Jul 2025 11:33:43 +0530 Subject: [PATCH] add disable allocation button --- home/admin.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/home/admin.py b/home/admin.py index a82cabe..9aa97ae 100644 --- a/home/admin.py +++ b/home/admin.py @@ -293,7 +293,7 @@ class about_Admin(ImportExportMixin, admin.ModelAdmin): }, ), ) - actions = ["export_as_csv", "generate_table"] + actions = ["export_as_csv", "generate_table", "disable_allocation"] def generate_table(Student, request, queryset): """ @@ -315,6 +315,14 @@ def export_as_csv(self, request, queryset): export_as_csv.short_description = "Export Student details to CSV" + def disable_allocation(self, request, queryset: list[Student]): + """ + Disable allocation action available in the admin page + """ + for obj in queryset: + obj.allocation_enabled = False + obj.save() + @admin.register(Scan) class about_Admin(admin.ModelAdmin):