Permalink
Browse files

[bug 678742] Monkeypatch User.get_absolute_url

  • Loading branch information...
1 parent 14ee1d9 commit fbb68f83aca3dc1043be8a42c3619b2aab9f8ce9 James Socol committed Oct 28, 2011
Showing with 16 additions and 1 deletion.
  1. +1 −1 apps/users/admin.py
  2. +15 −0 apps/users/monkeypatch.py
View
@@ -52,4 +52,4 @@ def save_model(self, request, obj, form, change):
obj.save()
admin.site.register(Profile, ProfileAdmin)
-monkeypatch.patch_user_admin()
+monkeypatch.patch_all()
View
@@ -1,4 +1,7 @@
from django.contrib.auth.admin import UserAdmin
+from django.contrib.auth.models import User
+
+from sumo.urlresolvers import reverse
def _activate_users(admin, request, qs):
@@ -22,3 +25,15 @@ def patch_user_admin():
UserAdmin._monkeyed = True
UserAdmin.has_delete_permission = lambda *a, **kw: False
UserAdmin.actions = [_activate_users, _deactivate_users]
+
+
+def patch_user_model():
+ """Add a more accurate User.get_absolute_url."""
+ def get_absolute_url(self):
+ return reverse('users.profile', args=[self.pk])
+ User.get_absolute_url = get_absolute_url
+
+
+def patch_all():
+ patch_user_admin()
+ patch_user_model()

0 comments on commit fbb68f8

Please sign in to comment.