def project_stats(request, context_agent_slug):
project = None
member_hours = []
#import pdb; pdb.set_trace()
if context_agent_slug:
project = get_object_or_404(EconomicAgent, slug=context_agent_slug)
if project:
subs = project.with_all_sub_agents()
ces = CachedEventSummary.objects.filter(
event_type__relationship="work",
context_agent__in=subs)
if ces.count():
agents = {}
for ce in ces:
agents.setdefault(ce.agent, Decimal("0"))
agents[ce.agent] += ce.quantity
for key, value in agents.items():
member_hours.append((key, value))
member_hours.sort(lambda x, y: cmp(y[1], x[1]))
return render_to_response("valueaccounting/project_stats.html", {
"member_hours": member_hours,
"page_title": "All-time project stats",
}, context_instance=RequestContext(request))
评论列表
文章目录