def test_editable_list_special_pks():
 (app, db, admin) = setup()
 class Model1(db.Model, ):
  def __init__(self, id=None, val1=None):
   self.id = id
   self.val1 = val1
  id = db.Column(db.String(20), primary_key=True)
  val1 = db.Column(db.String(20))
 db.create_all()
 view = CustomModelView(Model1, db.session, column_editable_list=['val1'])
 admin.add_view(view)
 db.session.add(Model1('1-1', 'test1'))
 db.session.add(Model1('1-5', 'test2'))
 db.session.commit()
 client = app.test_client()
 rv = client.post('/admin/model1/ajax/update/', data={'list_form_pk': '1-1', 'val1': 'change-success-1'})
 data = rv.data.decode('utf-8')
 ok_(('Record was successfully saved.' == data))
 rv = client.get('/admin/model1/')
 data = rv.data.decode('utf-8')
 ok_(('change-success-1' in data))

def test_editable_list_special_pks ( ) : ( app , db , admin ) = setup ( ) class Model1 ( db . Model , ) : def __init__ ( self , id = None , val1 = None ) : self . id = id self . val1 = val1 id = db . Column ( db . String ( 20 ) , primary_key = True ) val1 = db . Column ( db . String ( 20 ) ) db . create_all ( ) view = CustomModelView ( Model1 , db . session , column_editable_list = [ 'val1' ] ) admin . add_view ( view ) db . session . add ( Model1 ( '1-1' , 'test1' ) ) db . session . add ( Model1 ( '1-5' , 'test2' ) ) db . session . commit ( ) client = app . test_client ( ) rv = client . post ( '/admin/model1/ajax/update/' , data = { 'list_form_pk' : '1-1' , 'val1' : 'change-success-1' } ) data = rv . data . decode ( 'utf-8' ) ok_ ( ( 'Record was successfully saved.' == data ) ) rv = client . get ( '/admin/model1/' ) data = rv . data . decode ( 'utf-8' ) ok_ ( ( 'change-success-1' in data ) )
tests editable list view + a primary key with special characters .