>
> This is my code
>
def federados():
# Tablas de la BBDD
t_licencias = db.t_licencias
t_licencias_agrupaciones = db.t_licencias_agrupaciones
t_federados = db.t_federados
# Campos del grid
fields = [
t_federados.id,
t_federados.f_foto,
t_federados.f_fecha_nacimiento,
t_federados.f_dni,
t_federados.f_pasaporte,
t_federados.f_nombre,
t_federados.f_apellido1,
t_federados.f_apellido2,
t_federados.f_nacionalidad,
t_federados.f_direccion,
t_federados.f_poblacion,
t_federados.f_provincia,
t_federados.f_pais,
t_federados.f_codigo_postal,
t_federados.f_telefono_fijo,
t_federados.f_telefono_movil,
t_federados.f_email,
]
# Campos ocultos
t_federados.f_foto.readable = False
t_federados.f_fecha_nacimiento.readable = False
t_federados.f_dni.readable = False
t_federados.f_pasaporte.readable = False
t_federados.f_nombre.readable = False
t_federados.f_apellido1.readable = False
t_federados.f_apellido2.readable = False
t_federados.f_nacionalidad.readable = False
t_federados.f_direccion.readable = False
t_federados.f_poblacion.readable = False
t_federados.f_provincia.readable = False
t_federados.f_pais.readable = False
t_federados.f_codigo_postal.readable = False
t_federados.f_telefono_fijo.readable = False
t_federados.f_telefono_movil.readable = False
t_federados.f_email.readable = False
def represent_federado(f, r):
represent = DIV(_class="row")
nacimiento = Fechas.nacimiento_edad(r.f_fecha_nacimiento)
nombre = f'{r.f_apellido1} {r.f_apellido2}, {r.f_nombre}'
# foto
represent.insert(0, IMG(_height='100', _width='75',
_class='grid-foto m-1',
_src=URL(c='federados', f='download',
args=r.f_foto)))
represent.append(CAT(
DIV(
DIV(nombre), DIV(r.f_dni), DIV(r.f_nacionalidad),
DIV(nacimiento),
_class='grid-datos-federado m-1'),
))
represent.append(CAT(
DIV(
DIV(r.f_telefono_fijo), DIV(r.f_telefono_movil),
DIV(r.f_email),
_class='grid-datos-federado m-1'),
))
return represent
id_entidad = auth.user.f_id_entidad
query = (t_licencias.f_id_entidad == id_entidad) & \
(t_licencias_agrupaciones.f_id_temporada == temporada_actual.id)
left = [
t_licencias_agrupaciones.on((t_licencias_agrupaciones.f_id_federado
== t_federados.id)),
t_licencias.on(t_licencias.f_id_agrupacion ==
t_licencias_agrupaciones.id),
]
groupby = [t_licencias_agrupaciones.f_id_federado]
orderby = [t_federados.f_apellido1, t_federados.f_apellido2,
t_federados.f_nombre]
t_federados.id.represent = lambda f, r: represent_federado(f, r)
t_federados.id.label = T('Datos de los federados')
grid = SQLFORM.grid(query,
fields=fields,
field_id=db.t_federados.id,
left=left,
groupby=groupby,
orderby=orderby,
paginate=10,
advanced_search=False,
deletable=False,
editable=False,
details=False,
create=False,
csv=False)
return dict(grid=grid)
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/web2py/75b80fb4-c5b3-4eab-b88e-2bcf83252450%40googlegroups.com.