changeset 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 9e803323a0d0
children 0ca691cccf8d
files bio/admin.py
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
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'