From 1ce650d3c3850020c6ba54766cb70ad049c6e0bd Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 29 Mar 2011 14:19:51 -0500 Subject: Log user additions via new user form Signed-off-by: Dan McGee --- devel/views.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'devel') diff --git a/devel/views.py b/devel/views.py index b774e0e2..a6a51f22 100644 --- a/devel/views.py +++ b/devel/views.py @@ -170,6 +170,20 @@ def save(self): [user.email], fail_silently=False) +def log_addition(request, obj): + """Cribbed from ModelAdmin.log_addition.""" + from django.contrib.admin.models import LogEntry, ADDITION + from django.contrib.contenttypes.models import ContentType + from django.utils.encoding import force_unicode + LogEntry.objects.log_action( + user_id = request.user.pk, + content_type_id = ContentType.objects.get_for_model(obj).pk, + object_id = obj.pk, + object_repr = force_unicode(obj), + action_flag = ADDITION, + change_message = "Added via Create New User form." + ) + @permission_required('auth.add_user') @never_cache def new_user_form(request): @@ -177,6 +191,7 @@ def new_user_form(request): form = NewUserForm(request.POST) if form.is_valid(): form.save() + log_addition(request, form.instance.user) return HttpResponseRedirect('/admin/auth/user/%d/' % \ form.instance.user.id) else: -- cgit v1.2.3-54-g00ecf