Mercurial > public > sg101
diff bio/admin.py @ 790:6a06080e7ca8
Prevent accidental deletion of UserProfiles in the admin.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Fri, 23 May 2014 15:39:14 -0500 |
parents | 84865fcd7c26 |
children | eeaf387803c6 |
line wrap: on
line diff
--- a/bio/admin.py Fri May 23 15:10:11 2014 -0500 +++ b/bio/admin.py Fri May 23 15:39:14 2014 -0500 @@ -37,6 +37,16 @@ 'unsubscribe_forums', ] + def has_delete_permission(self, request, object=None): + # We don't want to delete a user profile; it is tied to the user object + return False + + def get_actions(self, request): + # We don't want to delete a user profile; it is tied to the user object + actions = super(UserProfileAdmin, self).get_actions(request) + del actions['delete_selected'] + return actions + def get_status_display(self, obj): return obj.get_status_display() get_status_display.short_description = 'Status'