From: Bryan Date: Tue, 14 Jan 2014 04:11:30 +0000 (-0500) Subject: batch show/hide notes, closes #269 X-Git-Tag: release-20150131~240^2~13 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=c6445ac14b23da2af3ff6b16664da66ef6db164a;p=oweals%2Fkarmaworld.git batch show/hide notes, closes #269 --- diff --git a/karmaworld/apps/moderation/admin.py b/karmaworld/apps/moderation/admin.py index 58104cc..2f223af 100644 --- a/karmaworld/apps/moderation/admin.py +++ b/karmaworld/apps/moderation/admin.py @@ -9,12 +9,26 @@ from karmaworld.apps.notes.models import Note from karmaworld.apps.notes.admin import NoteAdmin from karmaworld.apps.moderation import moderator + # Create a simple action to reset flags to zero. # https://docs.djangoproject.com/en/1.4/ref/contrib/admin/actions/ def reset_flags(modeladmin, request, queryset): queryset.update(flags=0) reset_flags.short_description = "Reset flags to 0" + +# Create a simple action to set is_hidden +def hide_notes(modeladmin, request, queryset): + queryset.update(is_hidden=True) +hide_notes.short_description = "Hide selected notes" + + +# Create a simple action to unset is_hidden +def show_notes(modeladmin, request, queryset): + queryset.update(is_hidden=False) +show_notes.short_description = "Show selected notes" + + # Structure views of Course objects class CourseModerator(CourseAdmin): date_heirarchy = 'updated_at' @@ -25,15 +39,17 @@ class CourseModerator(CourseAdmin): # Enable resetting flags actions = (reset_flags,) + # Structure views of Note objects class NoteModerator(NoteAdmin): date_heirarchy = 'uploaded_at' # Identify fields to display on the Change page - list_display = ('name', 'flags', 'course', 'uploaded_at', 'ip') + list_display = ('name', 'flags', 'course', 'is_hidden', 'uploaded_at', 'ip') # Sort by highest number of flags first, and then by date for ties ordering = ('-flags', '-uploaded_at') # Enable resetting flags - actions = (reset_flags,) + actions = (reset_flags, hide_notes, show_notes) + moderator.site.register(Course, CourseModerator) moderator.site.register(Note, NoteModerator)