示例#1
0
 def patch(self):
     try:
         patch_request_id = patching.create_request(
             patching.from_text(request.data), g.identity.id)
         database.commit()
         return None, 202, {
             'Location': api.url_for(PatchRequest, id=patch_request_id)
         }
     except patching.InvalidPatchError as e:
         return {'status': 400, 'message': str(e)}, 400
示例#2
0
    def post(self, id):
        data = request.data or ''
        if isinstance(data, bytes):
            data = data.decode()

        try:
            data = json.loads(data)
            message = data['message']
        except:
            return {'message': 'No message present in request data.'}, 400

        try:
            patching.add_comment(id,
                                 g.identity.id,
                                 message)
            database.commit()
            return None, 200, {
                'Location': api.url_for(PatchRequest, id=id)
            }
        except patching.MergeError as e:
            return {'message': e.message}, 404