controllers.py 文件源码

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

项目:IntegraTI-API 作者: discentes-imd 项目源码 文件源码
def post(self):
        '''Create a new event'''
        ev = Event()

        tags = request.json['tags'][:] # copy the tags dict
        del request.json['tags']
        for tm in tags:
            t = Tag.query\
                .filter(Tag.name == tm['name'])\
                .filter(Tag.disabled == 0)\
                .first()

            if t is not None:
                ev.tags.append(t)
                continue

            tag = Tag()
            fill_object(tag, tm)
            ev.tags.append(tag)

        fill_object(ev, request.json)
        # submit objects to db
        db.session.add(ev)
        db.session.commit()

        return msg(ev.id_event, 'id')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号