actions.py 文件源码

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

项目:quokka_ng 作者: rochacbruno 项目源码 文件源码
def action_clone_item(self, ids):
        if len(ids) > 1:
            flash(
                "You can select only one item for this action",
                'error'
            )
            return

        model = current_app.db.get_with_content(_id=ids[0])
        clone = deepcopy(model)
        del clone['_id']
        clone['slug'] = f'{clone["slug"]}-{random.getrandbits(32)}'
        clone['_isclone'] = True
        self._on_model_change(None, clone, True)
        self.coll.insert(clone)
        self.after_model_change(None, clone, True)
        return redirect(url_for('.edit_view', id=clone['_id']))


# TODO: Serialize and activate thia action
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号