Mercurial > public > sg101
comparison bio/admin.py @ 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 | ee87ea74d46b |
children | 6a06080e7ca8 |
comparison
equal
deleted
inserted
replaced
662:b347a31d12dd | 663:84865fcd7c26 |
---|---|
17 model = bio.models.BadgeOwnership | 17 model = bio.models.BadgeOwnership |
18 extra = 1 | 18 extra = 1 |
19 | 19 |
20 | 20 |
21 class UserProfileAdmin(admin.ModelAdmin): | 21 class UserProfileAdmin(admin.ModelAdmin): |
22 search_fields = ('user__username', 'user__first_name', 'user__last_name', | 22 search_fields = ['user__username', 'user__first_name', 'user__last_name', |
23 'user__email') | 23 'user__email'] |
24 exclude = ('profile_html', 'signature_html') | 24 exclude = ['profile_html', 'signature_html'] |
25 list_display = ('__unicode__', 'user_is_active', 'get_status_display', 'status_date') | 25 list_display = ['__unicode__', 'user_is_active', 'get_status_display', 'status_date'] |
26 readonly_fields = ('status', 'status_date', 'update_date') | 26 readonly_fields = ['status', 'status_date', 'update_date'] |
27 list_filter = ('status', ) | 27 list_filter = ['status', ] |
28 date_hierarchy = 'status_date' | 28 date_hierarchy = 'status_date' |
29 inlines = (BadgeOwnerInline, ) | 29 inlines = [BadgeOwnerInline, ] |
30 actions = ( | 30 actions = [ |
31 'mark_active', | 31 'mark_active', |
32 'mark_resigned', | 32 'mark_resigned', |
33 'mark_removed', | 33 'mark_removed', |
34 'mark_suspended', | 34 'mark_suspended', |
35 'mark_spammer', | 35 'mark_spammer', |
36 'mark_stranger', | 36 'mark_stranger', |
37 ) | 37 'unsubscribe_forums', |
38 ] | |
38 | 39 |
39 def get_status_display(self, obj): | 40 def get_status_display(self, obj): |
40 return obj.get_status_display() | 41 return obj.get_status_display() |
41 get_status_display.short_description = 'Status' | 42 get_status_display.short_description = 'Status' |
42 | 43 |
107 Marks users as strangers. Updates their profile status to STA_STRANGER. | 108 Marks users as strangers. Updates their profile status to STA_STRANGER. |
108 """ | 109 """ |
109 self.mark_user_status(request, qs, bio.models.STA_STRANGER) | 110 self.mark_user_status(request, qs, bio.models.STA_STRANGER) |
110 mark_stranger.short_description = "Mark selected users as strangers" | 111 mark_stranger.short_description = "Mark selected users as strangers" |
111 | 112 |
113 def unsubscribe_forums(self, request, qs): | |
114 """Delete users forum topic subscriptions.""" | |
115 for profile in qs: | |
116 profile.user.subscriptions.clear() | |
117 | |
118 self.message_user(request, "%s subscription(s) deleted." % qs.count()) | |
119 | |
120 unsubscribe_forums.short_description = "Delete users' forum subscriptions" | |
121 | |
112 | 122 |
113 class UserProfileFlagAdmin(admin.ModelAdmin): | 123 class UserProfileFlagAdmin(admin.ModelAdmin): |
114 list_display = ['__unicode__', 'flag_date', 'get_profile_url'] | 124 list_display = ['__unicode__', 'flag_date', 'get_profile_url'] |
115 actions = ['accept_flags'] | 125 actions = ['accept_flags'] |
116 raw_id_fields = ['user', 'profile'] | 126 raw_id_fields = ['user', 'profile'] |