views.py 文件源码

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

项目:itaplay 作者: lhalam 项目源码 文件源码
def post(self, request):
        """
        Handling POST method.
        :param request: Request to View.
        :return: Http response with status code 201
        """
        data = json.loads(request.body)
        template = XmlTemplate.get_by_id(data['template_id']).template_content
        tree = ElementTree.fromstring(template)
        for area in data['areas']:
            template_area = tree.find(".//area[@id=\"%s\"]" % (area['id']))
            for clip in area['clips']:
                clip_tag = ElementTree.SubElement(template_area, 'clip')
                clip_tag.set('id', str(clip['pk']))
                clip_tag.set('src', clip['fields']['url'])
                clip_tag.set('mimetype', clip['fields']['mimetype'])
                clip_tag.text = clip['fields']['name']
        result_template = ElementTree.tostring(tree, encoding="us-ascii", method="xml")
        project_hash = hashlib.md5(result_template)
        AdviserProject.update(data['project_id'],project_hash=project_hash, project_template = result_template)
        return HttpResponse(status=201)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号