training.py 文件源码

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

项目:vj4 作者: vijos 项目源码 文件源码
def post(self, *, tid: objectid.ObjectId, title: str, content: str, dag: str, desc: str):
    tdoc = await training.get(self.domain_id, tid)
    if not self.own(tdoc, builtin.PERM_EDIT_TRAINING_SELF):
      self.check_perm(builtin.PERM_EDIT_TRAINING)
    dag = _parse_dag_json(dag)
    pids = self.get_pids({'dag': dag})
    if not pids:
      # empty plan
      raise error.ValidationError('dag')
    pdocs = await problem.get_multi(domain_id=self.domain_id, doc_id={'$in': pids},
                                    fields={'doc_id': 1, 'hidden': 1}) \
                         .sort('doc_id', 1) \
                         .to_list()
    exist_pids = [pdoc['doc_id'] for pdoc in pdocs]
    if len(pids) != len(exist_pids):
      for pid in pids:
        if pid not in exist_pids:
          raise error.ProblemNotFoundError(self.domain_id, pid)
    for pdoc in pdocs:
      if pdoc.get('hidden', False):
        self.check_perm(builtin.PERM_VIEW_PROBLEM_HIDDEN)
    await training.edit(self.domain_id, tdoc['doc_id'], title=title, content=content,
                        dag=dag, desc=desc)
    self.json_or_redirect(self.reverse_url('training_detail', tid=tid))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号