Beispiel #1
0
def destroy(id):

    thread = Thread.get_by_id(id)

    if thread.delete_instance(recursive=True):
        return jsonify({
            'message': "thread deleted"
        }), 200
    else:
        er_msg = []
        for error in thread.errors:
            er_msg.append(error)
        return jsonify({'message': er_msg}), 418
Beispiel #2
0
def update(id):

    thread = Thread.get_by_id(id)

    new_thread = request.get_json()

    thread.template = new_thread['template']
    thread.content = new_thread['content']

    if thread.save():
        return jsonify({
            'message': 'successfully updated thread',
            'status': 'success',
            'updated_thread': {
                'id': thread.id,
                'template': thread.template,
                'content': thread.content,
            },
        }), 200
    else:
        er_msg = []
        for error in thread.errors:
            er_msg.append(error)
        return jsonify({'message': er_msg}), 418