本文整理汇总了Python中uliweb.utils.generic.ListView.run方法的典型用法代码示例。如果您正苦于以下问题:Python ListView.run方法的具体用法?Python ListView.run怎么用?Python ListView.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类uliweb.utils.generic.ListView
的用法示例。
在下文中一共展示了ListView.run方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generic_list
# 需要导入模块: from uliweb.utils.generic import ListView [as 别名]
# 或者: from uliweb.utils.generic.ListView import run [as 别名]
def generic_list(model=None, get_url=get_url, layout='layout.html',
template=None, key_field='id', add_button_text=None, view=None, data=None,
json_result=True, pagination=True, rows=10):
from uliweb.utils.generic import ListView
from uliweb import request, response
from uliweb.core.html import Tag
if not view:
def key(value, obj):
url = get_url('view', id=obj.id)
return str(Tag('a', value, href="%s" % url))
if not model or not get_model(model):
error("Can't find model [%s], please check it" % model)
pageno = int(request.GET.get('pageno', 0))
rows_per_page=rows
if json_result:
pageno = int(request.values.get('page', 1)) - 1
rows_per_page = int(request.values.get('rows', rows))
fields_convert_map = {key_field:key}
_id = '%s_table' % model
view = ListView(model, rows_per_page=rows_per_page,
pageno=pageno, id=_id, fields_convert_map=fields_convert_map,
pagination=pagination)
else:
_id = view.id
if 'data' in request.values:
if json_result:
return json(view.json())
else:
result = view.run(head=False, body=True)
return json(result)
else:
result = view.run(head=True, body=False)
if isinstance(result, dict):
template = template or 'generic_list.html'
data = data or {}
result['layout'] = layout
result['get_url'] = get_url
result['add_button_text'] = add_button_text or _('New')
if json_result:
result['table'] = view
result.update(data)
return render_template(template, layout, result)
else:
return result
示例2: tasks
# 需要导入模块: from uliweb.utils.generic import ListView [as 别名]
# 或者: from uliweb.utils.generic.ListView import run [as 别名]
def tasks(self):
from uliweb.utils.generic import ListView, get_sort_field
workflow_id = int(request.GET.get("workflow", -1))
cond = None
if workflow_id > 0:
cond = (self.wftask_model.c.workflow == workflow_id)
fields = [ 'id',
{'name': 'spec_name', 'width':200}, 'desc',
'state',
{'name': 'workflow', 'width':200},
'alias_name', 'created_user', 'created_date', 'modified_user', 'modified_date']
def workflow(value, obj):
from uliweb.core.html import Tag
display = obj.workflow.spec_name + ("%04d"%obj.workflow.id)
tag = Tag('a', display, href='/redbreast/workflow/%d' % obj.workflow.id)
return str(tag) + (" <a class='btn btn-small btn-primary' href='/redbreast/tasks?workflow=%d'>Filter</a>" % obj.workflow.id)
fields_convert_map = {'workflow':workflow, 'id': task_id}
view = ListView(self.wftask_model, condition=cond,
fields_convert_map=fields_convert_map, fields=fields)
if 'data' in request.values:
return json(view.json())
else:
result = view.run(head=True, body=False)
result.update({'table':view})
return result
示例3: admin_category
# 需要导入模块: from uliweb.utils.generic import ListView [as 别名]
# 或者: from uliweb.utils.generic.ListView import run [as 别名]
def admin_category(self):
"""
显示管理板块页面
"""
from uliweb.utils.generic import ListView
category = get_model("forumcategory")
pageno = int(request.values.get("page", 1)) - 1
rows_per_page = int(request.values.get("rows", 10))
def action(value, obj):
return '<a href="%s">%s</a> <a href="%s" onclick="return confirm(\'确定要删除当前板块吗?\');">%s</a>' % (
url_for(ForumView.category_edit, id=obj.id),
"编辑",
url_for(ForumView.category_delete, id=obj.id),
"删除",
)
view = ListView(category, rows_per_page=rows_per_page, pageno=pageno, fields_convert_map={"action": action})
if "data" in request.values:
return json(view.json())
else:
result = view.run(head=True, body=False)
result.update({"table": view})
return result
示例4: list
# 需要导入模块: from uliweb.utils.generic import ListView [as 别名]
# 或者: from uliweb.utils.generic.ListView import run [as 别名]
def list(self):
from uliweb.utils.generic import ListView
def title(value, obj):
return obj.get_url()
view = ListView(self.model,
fields_convert_map={'title':title},
pagination=False)
return view.run()
示例5: list
# 需要导入模块: from uliweb.utils.generic import ListView [as 别名]
# 或者: from uliweb.utils.generic.ListView import run [as 别名]
def list(self):
from uliweb.utils.generic import ListView, get_sort_field
fields_convert_map = {"title": approve_title}
view = ListView(self.model, fields_convert_map=fields_convert_map)
if "data" in request.values:
return json(view.json())
else:
result = view.run(head=True, body=False)
result.update({"table": view})
return result
示例6: list
# 需要导入模块: from uliweb.utils.generic import ListView [as 别名]
# 或者: from uliweb.utils.generic.ListView import run [as 别名]
def list(self):
from uliweb.utils.generic import ListView, get_sort_field
def id(value, obj):
return "<a href='/yesno/view/%d'>%d</a>" % (value, value)
fields_convert_map = {'id': id}
view = ListView(self.model, fields_convert_map=fields_convert_map)
if 'data' in request.values:
return json(view.json())
else:
result = view.run(head=True, body=False)
result.update({'table':view})
return result
示例7: admin_forumtopictype
# 需要导入模块: from uliweb.utils.generic import ListView [as 别名]
# 或者: from uliweb.utils.generic.ListView import run [as 别名]
def admin_forumtopictype(self):
"""
显示管理论坛主题类型页面
"""
from uliweb.utils.generic import ListView
pageno = int(request.values.get('page', 1)) - 1
rows_per_page=int(request.values.get('rows', 10))
def action(value, obj):
return '<a href="%s">%s</a> <a href="%s" onclick="return confirm(\'确定要删除当前主题类型吗?\');">%s</a>' % (url_for(ForumView.forumtopictype_edit, id=obj.id), '编辑', url_for(ForumView.forumtopictype_delete, id=obj.id), '删除')
view = ListView('forumtopictype', rows_per_page=rows_per_page, pageno=pageno,
fields_convert_map={'action':action})
if 'data' in request.values:
return json(view.json())
else:
result = view.run(head=True, body=False)
result.update({'table':view})
return result
示例8: todolist
# 需要导入模块: from uliweb.utils.generic import ListView [as 别名]
# 或者: from uliweb.utils.generic.ListView import run [as 别名]
def todolist(self):
from uliweb.utils.generic import ListView, get_sort_field
from sqlalchemy.sql import or_
fields_convert_map = {"title": approve_title}
helper = ApproveHelper()
spec_names = helper.get_task_spec_names(request.user)
cond = None
if len(spec_names) > 0:
cond = or_(*[self.model.c.task_spec_name == name for name in spec_names])
print cond
view = ListView(self.model, condition=cond, fields_convert_map=fields_convert_map)
if "data" in request.values:
return json(view.json())
else:
result = view.run(head=True, body=False)
result.update({"table": view})
return result
示例9: workflows
# 需要导入模块: from uliweb.utils.generic import ListView [as 别名]
# 或者: from uliweb.utils.generic.ListView import run [as 别名]
def workflows(self):
from uliweb.utils.generic import ListView, get_sort_field
fields = ['id',
{'name':'spec_name','width':200}, 'desc', 'state',
'created_user', 'created_date',
'modified_user', 'modified_date']
def id(value, obj):
from uliweb.core.html import Tag
return str(Tag('a', ("%04d"%obj.id), href='/redbreast/workflow/%d' % obj.id))
fields_convert_map = {'id': id}
view = ListView(self.wf_model,
fields_convert_map=fields_convert_map, fields=fields)
if 'data' in request.values:
return json(view.json())
else:
result = view.run(head=True, body=False)
result.update({'table':view})
return result
示例10: workflow
# 需要导入模块: from uliweb.utils.generic import ListView [as 别名]
# 或者: from uliweb.utils.generic.ListView import run [as 别名]
def workflow(self, id):
from uliweb.utils.generic import DetailView, ListView
obj = self.wf_model.get(int(id))
def get_wf_detail():
fields1 = ['id', 'spec_name',
'desc', 'state', 'created_user', 'created_date',
'modified_user', 'modified_date']
layout1 = [
'-- 基本信息 --',
('id', 'state', 'spec_name'),
('desc'),
('created_user', 'created_date'),
('modified_user', 'modified_date'),
]
view1 = DetailView(self.wf_model, obj=obj, fields=fields1, layout=layout1)
result1 = view1.run()
return result1['view']
fields2 = [ 'id',
{'name': 'spec_name', 'width':200}, 'desc',
'state',
'alias_name', 'created_user', 'created_date', 'modified_user', 'modified_date']
cond = self.wftask_model.c.workflow == obj.id
fields_convert_map = {'id': task_id}
view2 = ListView(self.wftask_model, condition=cond,
fields_convert_map=fields_convert_map, fields=fields2)
if 'data' in request.values:
return json(view2.json())
else:
result2 = view2.run(head=True, body=False)
result2.update({'table':view2, 'detailview': get_wf_detail(), 'workflow': obj})
return result2
示例11: list
# 需要导入模块: from uliweb.utils.generic import ListView [as 别名]
# 或者: from uliweb.utils.generic.ListView import run [as 别名]
def list(self):
from uliweb.utils.generic import ListView
pageno = int(request.values.get('page', 1)) - 1
rows_per_page=int(request.values.get('rows', settings.get_var('PARA/ROWS_PER_PAGE', 10)))
def name(value, obj):
return '<a href="%s">%s</a>' % (url_for(PermissionView.view, id=obj.id), value)
fields = [
{'name':'name', 'verbose_name':_('Name'), 'width':200},
{'name':'description', 'verbose_name':_('Description'), 'width':200},
]
fields_convert_map = {'name':name}
view = ListView(self.model, rows_per_page=rows_per_page, pageno=pageno,
fields=fields, fields_convert_map=fields_convert_map)
if 'data' in request.values:
return json(view.json())
else:
result = view.run(head=True, body=False)
result.update({'table':view})
return result