Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. def get_nombre(record):
  2. stock = db.stock(record.stock)
  3. return '%s' % stock.nombre
  4.  
  5.  
  6. def get_min_precio_banner():
  7. precio_banner = 0.0
  8. try:
  9. vg = db.valores_generales(1)
  10. precio_banner = vg.precio_banner
  11. except:
  12. pass
  13. return precio_banner
  14.  
  15.  
  16. def _():
  17. db.define_table(
  18. 'centro_deportivo',
  19. Field('stock', 'reference stock', label=T('Stock')),
  20. Field('descripcion', 'text', label=T(u'Descripción')),
  21. Field('imagen', 'upload', uploadseparate=True, autodelete=True),
  22. # Teléfonos
  23. Field('telefonos', 'list:string', label=T(u'Teléfonos'), default=[]),
  24. # Web y redes sociales
  25. Field('web', label=T('Sitio web'), requires=IS_EMPTY_OR(IS_URL())),
  26. Field('twitter', 'string', length=100, requires=IS_EMPTY_OR(IS_URL())),
  27. Field('facebook', 'string', length=100, requires=IS_EMPTY_OR(IS_URL())),
  28. Field('googleplus', 'string', length=100, label='Google+', requires=IS_EMPTY_OR(IS_URL())),
  29. Field('instagram', 'string', length=100, requires=IS_EMPTY_OR(IS_URL())),
  30. Field('youtube', 'string', length=100, requires=IS_EMPTY_OR(IS_URL())),
  31. Field('precio_banner', 'double', label=T('Precio del banner')),
  32. format=get_nombre)
  33.  
  34. min_precio_banner = get_min_precio_banner()
  35. db.centro_deportivo.precio_banner.default = min_precio_banner
  36. db.centro_deportivo.precio_banner.requires = IS_FLOAT_IN_RANGE(min_precio_banner, )
  37.  
  38. db.centro_deportivo.tiene_redes_sociales = Field.Method(
  39. 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
  40. )
  41.  
  42. db.centro_deportivo.tiene_direccion = Field.Method(
  43. lambda row: row.centro_deportivo.stock.pais or row.centro_deportivo.stock.ciudad or row.centro_deportivo.stock.calle
  44. )
  45.  
  46.  
  47. _()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement