# HG changeset patch # User Brian Neal # Date 1400877554 18000 # Node ID 6a06080e7ca8c92a2a54b0bbb7b78e9e3e0151f9 # Parent 9e803323a0d08aaea7aca991a1aedd269979e50d Prevent accidental deletion of UserProfiles in the admin. diff -r 9e803323a0d0 -r 6a06080e7ca8 bio/admin.py --- 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'