def agent_stats(request, agent_id):
agent = get_object_or_404(EconomicAgent, id=agent_id)
scores = agent.resource_types.all()
agents = {}
contributions = EconomicEvent.objects.filter(is_contribution=True)
for c in contributions:
if c.from_agent not in agents:
agents[c.from_agent] = Decimal("0")
agents[c.from_agent] += c.quantity
member_hours = []
for key, value in agents.iteritems():
member_hours.append((key, value))
member_hours.sort(lambda x, y: cmp(y[1], x[1]))
return render_to_response("valueaccounting/agent_stats.html", {
"agent": agent,
"scores": scores,
"member_hours": member_hours,
}, context_instance=RequestContext(request))
评论列表
文章目录