def test_column_editable_list():
    app, db, admin = setup()

    Model1, Model2 = create_models(db)

    view = CustomModelView(Model1,
                           column_editable_list=[
                               'test1', 'datetime_field'])
    admin.add_view(view)

    fill_db(Model1, Model2)

    client = app.test_client()

    # Test in-line edit field rendering
    rv = client.get('/admin/model1/')
    data = rv.data.decode('utf-8')
    ok_('data-role="x-editable"' in data)

    # Form - Test basic in-line edit functionality
    obj1 = Model1.objects.get(test1 = 'test1_val_3')
    rv = client.post('/admin/model1/ajax/update/', data={
        'test1-' + str(obj1.id): 'change-success-1',
    })
    data = rv.data.decode('utf-8')
    ok_('Record was successfully saved.' == data)

    # confirm the value has changed
    rv = client.get('/admin/model1/')
    data = rv.data.decode('utf-8')
    ok_('change-success-1' in data)

    # Test validation error
    obj2 = Model1.objects.get(test1 = 'datetime_obj1')
    rv = client.post('/admin/model1/ajax/update/', data={
        'datetime_field-' + str(obj2.id): 'problematic-input',
    })
    eq_(rv.status_code, 500)
    
    # Test invalid primary key
    rv = client.post('/admin/model1/ajax/update/', data={
        'test1-1000': 'problematic-input',
    })
    data = rv.data.decode('utf-8')
    eq_(rv.status_code, 500)
    
    # Test editing column not in column_editable_list
    rv = client.post('/admin/model1/ajax/update/', data={
        'test2-1': 'problematic-input',
    })
    data = rv.data.decode('utf-8')
    eq_(rv.status_code, 500)
    
    # Test in-line editing for relations
    view = CustomModelView(Model2,
                           column_editable_list=[
                               'model1'])
    admin.add_view(view)
    
    obj3 = Model2.objects.get(string_field = 'string_field_val_1')
    rv = client.post('/admin/model2/ajax/update/', data={
        'model1-' + str(obj3.id): str(obj1.id),
    })
    data = rv.data.decode('utf-8')
    ok_('Record was successfully saved.' == data)

    # confirm the value has changed
    rv = client.get('/admin/model2/')
    data = rv.data.decode('utf-8')
    ok_('test1_val_1' in data)
dataset/ETHPy150Open mrjoes/flask-admin/flask_admin/tests/mongoengine/test_basic.py/test_column_editable_list/original