Add ability to approve events by batch
authorMagnus Hagander <magnus@hagander.net>
Thu, 6 Dec 2012 18:40:47 +0000 (19:40 +0100)
committerMagnus Hagander <magnus@hagander.net>
Thu, 6 Dec 2012 18:40:47 +0000 (19:40 +0100)
pgweb/events/admin.py

index 424e3ed40a915040a9b17549b8b0cb4a2f7576cb..d876cce299bbee78c6388e6f5ad9a5d09db07a01 100644 (file)
@@ -3,9 +3,18 @@ from django.contrib import admin
 from util.admin import PgwebAdmin
 from models import *
 
+def approve_event(modeladmin, request, queryset):
+       # We need to do this in a loop even though it's less efficient,
+       # since using queryset.update() will not send the moderation messages.
+       for e in queryset:
+               e.approved = True
+               e.save()
+approve_event.short_description = 'Approve event'
+
 class EventAdmin(PgwebAdmin):
        list_display = ('title', 'org', 'startdate', 'training', 'approved',)
        list_filter = ('approved','training',)
        search_fields = ('summary', 'details', 'title', )
+       actions = [approve_event, ]
 
 admin.site.register(Event, EventAdmin)