summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--devel/urls.py2
-rw-r--r--devel/views.py16
-rw-r--r--templates/admin/index.html8
-rw-r--r--templates/devel/admin_log.html62
4 files changed, 87 insertions, 1 deletions
diff --git a/devel/urls.py b/devel/urls.py
index bcf9c071..41be2b31 100644
--- a/devel/urls.py
+++ b/devel/urls.py
@@ -5,6 +5,8 @@ urlpatterns = patterns('devel.views',
(r'^clock/$', 'clock'),
(r'^profile/$', 'change_profile'),
(r'^newuser/$', 'new_user_form'),
+ (r'^admin_log/(?P<username>.*)/$','admin_log'),
+ (r'^admin_log/$','admin_log'),
)
# vim: set ts=4 sw=4 et:
diff --git a/devel/views.py b/devel/views.py
index c926c5a4..46387f7a 100644
--- a/devel/views.py
+++ b/devel/views.py
@@ -1,9 +1,11 @@
from django import forms
from django.http import HttpResponseRedirect
-from django.contrib.auth.decorators import login_required, permission_required
+from django.contrib.auth.decorators import \
+ login_required, permission_required, user_passes_test
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
from django.core.mail import send_mail
+from django.shortcuts import get_object_or_404
from django.template import loader, Context
from django.views.decorators.cache import never_cache
from django.views.generic.simple import direct_to_template
@@ -169,4 +171,16 @@ def new_user_form(request):
}
return direct_to_template(request, 'general_form.html', context)
+@user_passes_test(lambda u: u.is_superuser)
+@never_cache
+def admin_log(request, username=None):
+ user = None
+ if username:
+ user = get_object_or_404(User, username=username)
+ context = {
+ 'title': "Admin Action Log",
+ 'log_user': user,
+ }
+ return direct_to_template(request, 'devel/admin_log.html', context)
+
# vim: set ts=4 sw=4 et:
diff --git a/templates/admin/index.html b/templates/admin/index.html
index 6f7f98ee..93cf258d 100644
--- a/templates/admin/index.html
+++ b/templates/admin/index.html
@@ -14,10 +14,18 @@
<div class="module">
<table>
<caption>Custom Admin Pages</caption>
+ {% if perms.auth.add_user %}
<tr>
<th scope="row"><a href="/devel/newuser/">Create New User</a></th>
<td></td><td></td>
</tr>
+ {% endif %}
+ {% if user.is_superuser %}
+ <tr>
+ <th scope="row"><a href="/devel/admin_log/">Admin Actions Log</a></th>
+ <td></td><td></td>
+ </tr>
+ {% endif %}
</table>
</div>
diff --git a/templates/devel/admin_log.html b/templates/devel/admin_log.html
new file mode 100644
index 00000000..2de15bad
--- /dev/null
+++ b/templates/devel/admin_log.html
@@ -0,0 +1,62 @@
+{% extends "admin/base_site.html" %}
+{% load i18n %}
+
+{% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% load adminmedia %}{% admin_media_prefix %}css/dashboard.css" />{% endblock %}
+
+{% block breadcrumbs %}<div class="breadcrumbs"><a href="/admin/">{% trans 'Home' %}</a>{% if title %} &rsaquo; {{ title }}{% endif %}</div>{% endblock %}
+
+{% block content %}
+<div id="content-main">
+ <div class="module">
+{% load log %}
+{% if log_user %}
+{% get_admin_log 100 as admin_log for_user log_user %}
+{% else %}
+{% get_admin_log 100 as admin_log %}
+{% endif %}
+{% if not admin_log %}
+<p>{% trans 'None available' %}</p>
+{% else %}
+<table id="change-history">
+ <thead>
+ <tr>
+ <th scope="col">{% trans 'Date/time' %}</th>
+ <th scope="col">{% trans 'User' %}</th>
+ <th>Type</th>
+ <th>Object</th>
+ <th scope="col">{% trans 'Action' %}</th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for entry in admin_log %}
+ <tr>
+ <th scope="row">{{ entry.action_time|date:"DATETIME_FORMAT" }}</th>
+ {% if log_user %}
+ <td>{{ entry.user.username }}{% if entry.user.get_full_name %} ({{ entry.user.get_full_name }}){% endif %}</td>
+ {% else %}
+ <td><a href="{{ entry.user.username }}/">{{ entry.user.username }}</a>{% if entry.user.get_full_name %} ({{ entry.user.get_full_name }}){% endif %}</td>
+ {% endif %}
+ <td>
+ {% if entry.content_type %}
+ <span>{% filter capfirst %}{% trans entry.content_type.name %}{% endfilter %}</span>
+ {% else %}
+ <span>{% trans 'Unknown content' %}</span>
+ {% endif %}
+ </td>
+ <td>
+ <span class="{% if entry.is_addition %}addlink{% endif %}{% if entry.is_change %}changelink{% endif %}{% if entry.is_deletion %}deletelink{% endif %}"></span>
+ {% if entry.is_deletion %}
+ {{ entry.object_repr }}
+ {% else %}
+ <a href="{{ entry.get_admin_url }}">{{ entry.object_repr }}</a>
+ {% endif %}
+ </td>
+ <td>{{ entry.change_message }}</td>
+ </tr>
+ {% endfor %}
+ </tbody>
+</table>
+{% endif %}
+ </div>
+</div>
+{% endblock %}