Skip to content

Commit 8a4a664

Browse files
add disable allocation button (#135)
1 parent 7d0bcb8 commit 8a4a664

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

home/admin.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ class about_Admin(ImportExportMixin, admin.ModelAdmin):
293293
},
294294
),
295295
)
296-
actions = ["export_as_csv", "generate_table"]
296+
actions = ["export_as_csv", "generate_table", "disable_allocation"]
297297

298298
def generate_table(Student, request, queryset):
299299
"""
@@ -315,6 +315,14 @@ def export_as_csv(self, request, queryset):
315315

316316
export_as_csv.short_description = "Export Student details to CSV"
317317

318+
def disable_allocation(self, request, queryset: list[Student]):
319+
"""
320+
Disable allocation action available in the admin page
321+
"""
322+
for obj in queryset:
323+
obj.allocation_enabled = False
324+
obj.save()
325+
318326

319327
@admin.register(Scan)
320328
class about_Admin(admin.ModelAdmin):

0 commit comments

Comments
 (0)