forms.py 文件源码

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

项目:nrp 作者: django-rea 项目源码 文件源码
def __init__(self, agent, pattern=None, *args, **kwargs): #agent is posting agent
        super(WorkTodoForm, self).__init__(*args, **kwargs)
        contexts = agent.related_contexts()
        self.fields["context_agent"].choices = list(set([(ct.id, ct) for ct in contexts]))
        peeps = [agent,]
        from_agent_choices = [('', 'Unassigned'), (agent.id, agent),]
        #import pdb; pdb.set_trace()
        for context in contexts:
            if agent.is_manager_of(context):
                peeps.extend(context.task_assignment_candidates())
        if len(peeps) > 1:
            peeps = list(OrderedDict.fromkeys(peeps))
        from_agent_choices = [('', 'Unassigned')] + [(peep.id, peep) for peep in peeps]

        self.fields["from_agent"].choices = from_agent_choices
        #import pdb; pdb.set_trace()
        if pattern:
            self.pattern = pattern
            #self.fields["resource_type"].choices = [(rt.id, rt) for rt in pattern.todo_resource_types()]
            self.fields["resource_type"].queryset = pattern.todo_resource_types()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号