views.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:nrp 作者: django-rea 项目源码 文件源码
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))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号