Mercurial > public > sg101
changeset 663:84865fcd7c26
For #45, create admin action to unsubscribe users from topics.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 15 May 2013 20:56:10 -0500 |
parents | b347a31d12dd |
children | 929d0e637a37 |
files | bio/admin.py |
diffstat | 1 files changed, 19 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/bio/admin.py Wed May 15 20:13:05 2013 -0500 +++ b/bio/admin.py Wed May 15 20:56:10 2013 -0500 @@ -19,22 +19,23 @@ class UserProfileAdmin(admin.ModelAdmin): - search_fields = ('user__username', 'user__first_name', 'user__last_name', - 'user__email') - exclude = ('profile_html', 'signature_html') - list_display = ('__unicode__', 'user_is_active', 'get_status_display', 'status_date') - readonly_fields = ('status', 'status_date', 'update_date') - list_filter = ('status', ) + search_fields = ['user__username', 'user__first_name', 'user__last_name', + 'user__email'] + exclude = ['profile_html', 'signature_html'] + list_display = ['__unicode__', 'user_is_active', 'get_status_display', 'status_date'] + readonly_fields = ['status', 'status_date', 'update_date'] + list_filter = ['status', ] date_hierarchy = 'status_date' - inlines = (BadgeOwnerInline, ) - actions = ( + inlines = [BadgeOwnerInline, ] + actions = [ 'mark_active', 'mark_resigned', 'mark_removed', 'mark_suspended', 'mark_spammer', 'mark_stranger', - ) + 'unsubscribe_forums', + ] def get_status_display(self, obj): return obj.get_status_display() @@ -109,6 +110,15 @@ self.mark_user_status(request, qs, bio.models.STA_STRANGER) mark_stranger.short_description = "Mark selected users as strangers" + def unsubscribe_forums(self, request, qs): + """Delete users forum topic subscriptions.""" + for profile in qs: + profile.user.subscriptions.clear() + + self.message_user(request, "%s subscription(s) deleted." % qs.count()) + + unsubscribe_forums.short_description = "Delete users' forum subscriptions" + class UserProfileFlagAdmin(admin.ModelAdmin): list_display = ['__unicode__', 'flag_date', 'get_profile_url']