def test_sql_field_attributes(self): # # test a generic SQLA field type # column_1 = schema.Column(types.Unicode(), nullable=False) fa_1 = EntityAdmin.get_sql_field_attributes([column_1]) self.assertTrue(fa_1['editable']) self.assertFalse(fa_1['nullable']) self.assertEqual(fa_1['delegate'], delegates.PlainTextDelegate) # # test sql standard types # column_2 = schema.Column(types.FLOAT(), nullable=True) fa_2 = EntityAdmin.get_sql_field_attributes([column_2]) self.assertTrue(fa_2['editable']) self.assertTrue(fa_2['nullable']) self.assertEqual(fa_2['delegate'], delegates.FloatDelegate) # # test a vendor specific field type # from sqlalchemy.dialects import mysql column_3 = schema.Column(mysql.BIGINT(), default=2) fa_3 = EntityAdmin.get_sql_field_attributes([column_3]) self.assertTrue(fa_3['default']) self.assertEqual(fa_3['delegate'], delegates.IntegerDelegate)
def get_query(self): """Redefino para devolver ordenado por fecha desc""" return EntityAdmin.get_query(self).order_by(desc('fecha'))
def get_field_attributes( self, field_name ): fa = EntityAdmin.get_field_attributes( self, field_name ) if field_name in [role[1] for role in roles]: fa['delegate'] = delegates.BoolDelegate fa['editable'] = True return fa
def get_query(self, *args, **kwargs): query = EntityAdmin.get_query(self, *args, **kwargs) query = query.order_by(self.entity.id.desc()) query = query.options(orm.subqueryload('status')) return query
def get_query(self): """Redefino para devolver ordenado por edad asc""" return EntityAdmin.get_query(self).order_by("fecha_nac")