summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-03-29 21:19:51 +0200
committerDan McGee <dan@archlinux.org>2011-03-29 21:19:51 +0200
commit1ce650d3c3850020c6ba54766cb70ad049c6e0bd (patch)
treec9d291f338b1f63777d613ce43d492c03fecd7af
parent36f8649c36c0fa6af02247e0a796b79df8b1eb2b (diff)
downloadarchweb-1ce650d3c3850020c6ba54766cb70ad049c6e0bd.tar.gz
archweb-1ce650d3c3850020c6ba54766cb70ad049c6e0bd.tar.xz
Log user additions via new user form
Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--devel/views.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/devel/views.py b/devel/views.py
index b774e0e..a6a51f2 100644
--- a/devel/views.py
+++ b/devel/views.py
@@ -170,6 +170,20 @@ class NewUserForm(forms.ModelForm):
[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: