Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_nombre(record):
- stock = db.stock(record.stock)
- return '%s' % stock.nombre
- def get_min_precio_banner():
- precio_banner = 0.0
- try:
- vg = db.valores_generales(1)
- precio_banner = vg.precio_banner
- except:
- pass
- return precio_banner
- def _():
- db.define_table(
- 'centro_deportivo',
- Field('stock', 'reference stock', label=T('Stock')),
- Field('descripcion', 'text', label=T(u'Descripción')),
- Field('imagen', 'upload', uploadseparate=True, autodelete=True),
- # Teléfonos
- Field('telefonos', 'list:string', label=T(u'Teléfonos'), default=[]),
- # Web y redes sociales
- Field('web', label=T('Sitio web'), requires=IS_EMPTY_OR(IS_URL())),
- Field('twitter', 'string', length=100, requires=IS_EMPTY_OR(IS_URL())),
- Field('facebook', 'string', length=100, requires=IS_EMPTY_OR(IS_URL())),
- Field('googleplus', 'string', length=100, label='Google+', requires=IS_EMPTY_OR(IS_URL())),
- Field('instagram', 'string', length=100, requires=IS_EMPTY_OR(IS_URL())),
- Field('youtube', 'string', length=100, requires=IS_EMPTY_OR(IS_URL())),
- Field('precio_banner', 'double', label=T('Precio del banner')),
- format=get_nombre)
- min_precio_banner = get_min_precio_banner()
- db.centro_deportivo.precio_banner.default = min_precio_banner
- db.centro_deportivo.precio_banner.requires = IS_FLOAT_IN_RANGE(min_precio_banner, )
- db.centro_deportivo.tiene_redes_sociales = Field.Method(
- lambda row: row.centro_deportivo.twitter or row.centro_deportivo.facebook or row.centro_deportivo.googleplus or row.centro_deportivo.instagram or row.centro_deportivo.youtube
- )
- db.centro_deportivo.tiene_direccion = Field.Method(
- lambda row: row.centro_deportivo.stock.pais or row.centro_deportivo.stock.ciudad or row.centro_deportivo.stock.calle
- )
- _()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement