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):