本文整理汇总了Python中gluon.SQLFORM.grid方法的典型用法代码示例。如果您正苦于以下问题:Python SQLFORM.grid方法的具体用法?Python SQLFORM.grid怎么用?Python SQLFORM.grid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gluon.SQLFORM
的用法示例。
在下文中一共展示了SQLFORM.grid方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Inicio
# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import grid [as 别名]
def Inicio():
session.flashed = False
#####classes#################
myinstance = MyClass(3, 4)
print myinstance.add()
b = MyList(3, 4, 5)
print b[1]
b.a[1] = 7
print b.a
##############################
if not session.flashed:
response.flash = T('Bem vindo a loja de carros!')
#response.write('Venha conhecer nossos carros!!!')
###############################
agora = request.now
#lista todos os carros na tela
#car_smartgrid = SQLFORM.smartgrid(db2.carro)
#lista todos os carros na tela
car_grid = SQLFORM.grid(db2.carro)
#contador de sessão
session.counter = (session.counter or 0) + 1
counter = session.counter
#mostrar o nome do usuário na tela
if auth2.user:
visitor_name = auth2.user.first_name
else:
visitor_name = 'nenhum'
table_hora = []
table_hora.append(TR('Hora Atual:',agora))
table_hora.append(TR('Visitante:',visitor_name))
table_hora.append(TR('Número de visitas:',counter))
table = TABLE(table_hora)
form_hora = FORM(table)
order = db2.carro.marca
#selecionar apenas os que possuem fotos
registros = db2(db2.carro.foto!=None).select(orderby=order)
form_teste = FORM(registros)
form_carro = detalhes_geral(db2.carro, 2)
(form_crud,table_crud) = pesquisa_geral(db2.carro)
title = "Loja de Carros"
# showcase = SHOWCASE(registros)
return locals()
示例2: history
# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import grid [as 别名]
def history(self, option, origin, user_timezone=None):
if option == 'chart':
from datetime import date, timedelta
time = date.today() - timedelta(days=30)
rows = self.db(self.db.auth_event.origin == origin and self.db.auth_event.time_stamp > str(time)).select(self.db.auth_event.ALL)
result = []
time_to_search = rows[0].time_stamp.strftime("%Y-%m-%d")
count_login = 0
count_logout = 0
for r in rows:
if r.time_stamp.strftime("%Y-%m-%d") == time_to_search:
if 'Logged-in' in r.description: count_login += 1
elif 'Logged-out' in r.description: count_logout += 1
else:
result.append({'period': time_to_search, 'login': count_login, 'logout': count_logout})
count_login = 0
count_logout = 0
if 'Logged-in' in r.description: count_login = 1
elif 'Logged-out' in r.description: count_logout = 1
time_to_search = r.time_stamp.strftime("%Y-%m-%d")
result.append({'period': time_to_search, 'login': count_login, 'logout': count_logout})
return result
elif option == 'list':
rows = self.db(self.db.auth_event.origin == origin).select(self.db.auth_event.ALL, limitby=(0,7),
orderby=~self.db.auth_event.time_stamp)
# In case the server does not have UTC time, we should convert time server to UTC
import pytz
from tzlocal import get_localzone
from datetime import datetime
for r in rows:
if 'Logged-in' in r.description: r.description = 'logged in'
elif 'Logged-out' in r.description: r.description = 'logged out'
# Covert to the local server and to date object
r.time_stamp = datetime.strptime(pytz.UTC.localize(r.time_stamp).
astimezone(pytz.timezone(str(get_localzone()))).
strftime("%Y-%m-%d %H:%M:%S"), "%Y-%m-%d %H:%M:%S")
return rows
elif option == 'full-list':
import pytz
self.db.auth_event.time_stamp.represent = lambda value, row :pytz.UTC.localize(value).astimezone(pytz.timezone(user_timezone))
sqlform = SQLFORM.grid(self.db.auth_event,
csv=False,
orderby=~self.db.auth_event.time_stamp,
editable=False,
deletable=False,
create=False)
return sqlform
示例3: build_accessories_grid
# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import grid [as 别名]
def build_accessories_grid(query, extra_parameters):
default_parameters = {
'fields': [db.accessory.accessory_name, db.accessory.accessory_price],
'csv': False,
'details': False,
'searchable': False
}
parameters = merge_dicts(default_parameters, extra_parameters)
grid = SQLFORM.grid(query, **parameters)
remove_grid_counter(grid)
return grid
示例4: custom_accessory_widget
# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import grid [as 别名]
def custom_accessory_widget(field,value):
#accessories_ids=fetch_id_list()
id_list = request.vars.id
if isinstance(id_list,str):
id_list = [id_list]
accessories_ids= id_list
#####################################
if accessories_ids:
#return accessories_grid_from_ids(accessories_ids)
query = db.accessory.id.belongs(accessories_ids)
params = {}
#grid = build_accessories_grid(query, params)
default_parameters = {
'fields': [db.accessory.accessory_name, db.accessory.accessory_price],
'csv': False,
'details': False,
'searchable': False
}
#parameters = merge_dicts(default_parameters, params)
resulting_dict = default_parameters.copy()
resulting_dict.update(params)
parameters = resulting_dict
###################################################
grid = SQLFORM.grid(query, **parameters)
remove_grid_counter(grid)
##############################################################
link = change_accessories_link()
grid.append(link)
return grid
#################################################
else:
return accessory_bt()
return
示例5: index
# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import grid [as 别名]
def index():
"""
Show notifications for the current user
"""
tbl = db.notification
query = (tbl.id > 0)
query &= (tbl.to_user == auth.user.id)
def p_seen_rpr(v, r):
if v:
return I(_class="fa fa-envelope-open-o")
return I(_class="fa fa-envelope")
tbl.seen.represent = p_seen_rpr
if request.args(0) == 'view':
tbl.seen.readable = False
tbl.message_content.represent = lambda v, r: XML(v)
msg = tbl(request.args(2))
msg.update_record(seen=True)
tbl.from_user.represent = lambda v, r: db.auth_user(v).email
grid = SQLFORM.grid(
query,
fields=[tbl.subject, tbl.from_user, tbl.seen, tbl.msg_date],
paginate=10,
showbuttontext=False,
editable=False,
csv=False,
maxtextlengths={'notification.subject': 100},
create=False,
searchable=False,
orderby=[~tbl.msg_date],
formstyle='bootstrap',
)
return dict(grid=grid)
示例6: list
# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import grid [as 别名]
def list(self):
if 'view' in self.request.args or 'edit' in self.request.args:
ignore_rw = True
else:
ignore_rw = False
self.context.form = SQLFORM.grid(self.db.Page, ignore_rw=ignore_rw)
示例7: attempts
# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import grid [as 别名]
def attempts():
if len(request.args) > 0:
form = SQLFORM.grid(db.attempt_log.name == request.args[0])
else:
form = SQLFORM.grid(db.attempt_log)
return dict(form=form)
示例8: list
# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import grid [as 别名]
def list(self):
self.context.form = SQLFORM.grid(self.db.Page)
示例9: grid_simple
# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import grid [as 别名]
def grid_simple(query, **kawrgs):
'''Construye un SQLFORM.grid con una pila de valores por defecto'''
T = current.T
auth = current.auth
myconf = current.conf
if not kawrgs.has_key('details'):
kawrgs['details'] = False
if not kawrgs.has_key('deletable'):
kawrgs['deletable'] = False
if not kawrgs.has_key('csv'):
kawrgs['csv'] = False
if not kawrgs.has_key('editable'):
kawrgs['editable'] = False
if not kawrgs.has_key('showbuttontext'):
kawrgs['showbuttontext'] = False
if not kawrgs.has_key('sortable'):
kawrgs['sortable'] = False
if not kawrgs.has_key('history'):
history = True
else:
history = kawrgs['history']
del kawrgs['history']
puede_historial = auth.has_membership(role=myconf.take('roles.admin'))
def _history_link(row):
co = CAT()
db = query._db
tablas = db._adapter.tables(query)
if len(tablas) > 1:
for tbl in tablas:
#print row.keys()
if row.has_key(tbl):
if row[tbl].has_key('id'):
enl = URL('escuela',
'historial',
args=[tbl,
row[tbl].id])
co.append(Accion(SPAN('',
_class='glyphicon glyphicon-time'),
enl,
puede_historial,
_class="btn btn-default btn-xs",
_title=T("Historial {}".format(tbl))))
else:
enl = URL('escuela', 'historial', args=[tablas[0], row.id])
co.append(Accion(SPAN('', _class='glyphicon glyphicon-time'),
enl,
puede_historial,
_class="btn btn-default btn-xs",
_title=T("Historial {}".format(tablas[0]))))
return co
# agregar enlace para historial de cambios
if history:
if kawrgs.has_key('links'):
kawrgs['links'].append(dict(header='',body=_history_link))
else:
kawrgs['links'] = [dict(header='',body=_history_link)]
return SQLFORM.grid(query, **kawrgs)