Web (Karma): add detail page to see the deltas of one key

this could be a graph, eventually, with more time to hack through
something like YUI.
http://developer.yahoo.com/yui/examples/charts/charts-styles_clean.html
is a solid example
This commit is contained in:
Brian S. Stephan 2011-02-20 17:08:17 -06:00
parent 497d9288e7
commit 2f5bdf5d1f
4 changed files with 42 additions and 2 deletions

View File

@ -4,4 +4,5 @@ urlpatterns = patterns('karma.views',
(r'^$', 'index'),
(r'^givers/$', 'givers'),
(r'^stats/$', 'stats'),
(r'^stats/(?P<key>.*)/$', 'key_detail', dict(), 'key_detail'),
)

View File

@ -1,5 +1,7 @@
from django.shortcuts import render_to_response
from karma.models import Value, User
from django.template import RequestContext
from karma.models import Value, User, LogEntry
def index(request):
karma_values = len(Value.objects.all())
@ -14,3 +16,9 @@ def stats(request):
def givers(request):
users = User.objects.all().order_by('who')
return render_to_response('karma/givers.html', {'users': users})
def key_detail(request, key):
deltas = LogEntry.objects.filter(key=key)
return render_to_response('karma/key_detail.html', {'key': key,'deltas': deltas}, context_instance=RequestContext(request))
# vi:tabstop=4:expandtab:autoindent

View File

@ -0,0 +1,31 @@
{% autoescape on %}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>dr.botzo &mdash; Karma &mdash; {{ key }}</title>
</head>
<body>
{% if messages %}
<div id="messages">
<ul class="messagelist">
{% for message in messages %}
<li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
{% endfor %}
</ul>
</div>
{% endif %}
<div id="container">
<ul>
{% for delta in deltas %}
<li>{{ delta }}</li>
{% endfor %}
</ul>
</div>
</body>
</html>
<!--
vi:tabstop=2:expandtab:autoindent
-->
{% endautoescape %}

View File

@ -2,7 +2,7 @@
<ol>
{% for value in values %}
<li>
{{ value.key }} ({{ value.value }})
<a href="{% url key_detail value.key %}">{{ value.key }}</a> ({{ value.value }})
</li>
{% endfor %}
</ol>