本文整理汇总了Python中uliweb.utils.generic.ListView类的典型用法代码示例。如果您正苦于以下问题:Python ListView类的具体用法?Python ListView怎么用?Python ListView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ListView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: admin_category
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
示例2: _get_users_list_view
def _get_users_list_view(self, c):
from uliweb.utils.generic import ListView
from uliweb.orm import get_model
from uliweb import request
from uliweb.core.html import Tag
from uliweb import orm
def username(value, obj):
return str(Tag('a', value, href='/users/view/%d' % obj.id))
def boolean_convert(b, obj):
if b:
return '<div class="ui-icon ui-icon-check"></div>'
else:
return '<div class="ui-icon ui-icon-closethick"></div>'
pageno = int(request.values.get('page', 1)) - 1
rows_per_page = int(request.values.get('rows', settings.get_var('PARA/ROWS_PER_PAGE', 10)))
User = get_model('user')
query = None
condition = None
if c.get('username'):
condition = (User.c.username.like('%'+c['username']+'%')) & condition
fields_convert_map = {'username':username}
view = ListView(User, condition=condition, query=query,
rows_per_page=rows_per_page, pageno=pageno,
fields_convert_map=fields_convert_map, id='users_table')
view.types_convert_map = {orm.BooleanProperty:boolean_convert}
return view
示例3: list
def list(self):
from uliweb.utils.generic import ListView
pageno = request.GET.get("page", 0)
view = ListView(self.model, pageno=pageno, order_by=self.model.c.publish_date.desc())
return {"blogs": view.query(), "view": view, "count": view.query().count()}
示例4: list
def list(self):
from uliweb import request
from uliweb.utils.generic import ListView
from uliweb.utils.common import get_choice
import math
pageno = int(request.values.get('page', 1)) - 1
rows_per_page=int(request.values.get('rows', settings.get_var('MESSAGES/PAGE_NUMS', 10)))
read_flag = request.GET.get('read', '')
type_flag = request.GET.get('type', '')
condition = None
condition = (self.model.c.user == request.user.id) & condition
condition = (self.model.c.send_flag == 'r') & condition
if read_flag:
condition = (self.model.c.read_flag == bool(read_flag=='1')) & condition
if type_flag:
condition = (self.model.c.type == type_flag) & condition
def create_date(value, obj):
from uliweb.utils.timesince import timesince
return timesince(value)
def user_image(value, obj):
return functions.get_user_image(obj.sender, size=20)
def message(value, obj):
return value
fields_convert_map = {'create_date':create_date,
'user_image':user_image,
'message':message}
view = ListView(self.model, condition=condition,
order_by=[self.model.c.create_date.desc()],
rows_per_page=rows_per_page, pageno=pageno,
fields_convert_map=fields_convert_map)
view.query()
result = {}
result['read_flag'] = read_flag
result['type_flag'] = type_flag
result['message_type_name'] = get_choice(settings.get_var('MESSAGES/MESSAGE_TYPE'), type_flag, '全部类型')
pages = int(math.ceil(1.0*view.total/rows_per_page))
# result['page'] = pageno+1
# result['total'] = view.total
# result['pages'] = pages
result['pagination'] = functions.create_pagination(functions.request_url(), view.total, pageno+1, rows_per_page)
result['objects'] = list(view.objects())
ids = []
for row in result['objects']:
ids.append(row._obj_.id)
self.model.filter(self.model.c.id.in_(ids)).update(read_flag=True)
_del_key(request.user.id)
return result
示例5: tasks
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
示例6: list
def list(self):
from uliweb.utils.generic import ListView
pageno = request.GET.get('page', 0)
view = ListView(self.model, pageno=pageno, order_by=self.model.c.publish_date.desc())
return {'blogs':view.query(), 'view':view, 'count':view.query().count()}
示例7: sended_list
def sended_list(self):
from uliweb import request
from uliweb.utils.generic import ListView
from uliweb.utils.common import get_choice
import math
pageno = int(request.values.get("page", 1)) - 1
rows_per_page = int(request.values.get("rows", settings.get_var("MESSAGES/PAGE_NUMS", 10)))
read_flag = request.GET.get("read", "")
type_flag = request.GET.get("type", "")
condition = None
condition = (self.model.c.sender == request.user.id) & condition
condition = (self.model.c.send_flag == "s") & condition
if read_flag:
condition = (self.model.c.read_flag == bool(read_flag == "1")) & condition
if type_flag:
condition = (self.model.c.type == type_flag) & condition
def create_date(value, obj):
from uliweb.utils.timesince import timesince
return timesince(value)
def user_image(value, obj):
return functions.get_user_image(obj.user, size=20)
def message(value, obj):
return value
fields_convert_map = {"create_date": create_date, "user_image": user_image, "message": message}
view = ListView(
self.model,
condition=condition,
order_by=[self.model.c.create_date.desc()],
rows_per_page=rows_per_page,
pageno=pageno,
fields_convert_map=fields_convert_map,
)
view.query()
result = {}
result["read_flag"] = read_flag
result["type_flag"] = type_flag
result["message_type_name"] = get_choice(settings.get_var("MESSAGES/MESSAGE_TYPE"), type_flag, "全部类型")
pages = int(math.ceil(1.0 * view.total / rows_per_page))
# result['page'] = pageno+1
# result['total'] = view.total
# result['pages'] = pages
result["pagination"] = functions.create_pagination(request.url, view.total, pageno + 1, rows_per_page)
result["objects"] = view.objects()
return result
示例8: forum_index
def forum_index(self, id):
"""
显示某论坛页面
"""
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/FORUM_INDEX_NUMS")))
Topic = get_model("forumtopic")
Forum = get_model("forum")
forum = Forum.get(int(id))
condition = Topic.c.forum == int(id)
order_by = [Topic.c.sticky.desc(), Topic.c.created_on.desc()]
if not forum.managers.has(request.user):
condition = (Topic.c.hidden == False) & condition
filter = request.GET.get("filter", "all")
if filter == "essence":
condition = (Topic.c.essence == True) & condition
def created_on(value, obj):
return value.strftime("%Y-%m-%d")
def last_reply_on(value, obj):
return timesince(value)
def subject(value, obj):
if obj.topic_type:
_type = u"[%s]" % obj.get_display_value("topic_type")
else:
_type = ""
s = ""
if obj.sticky:
s += u'<font color="red">[顶]</font>'
if obj.hidden:
s += u'<font color="red">[隐]</font>'
if obj.closed:
s += u'<font color="red">[关]</font>'
if obj.essence:
s += u'<font color="red">[精]</font>'
return _type + '<a href="/forum/%d/%d">%s</a>' % (int(id), obj.id, obj.subject) + s
fields_convert_map = {"created_on": created_on, "subject": subject, "last_reply_on": last_reply_on}
view = ListView(
Topic,
condition=condition,
order_by=order_by,
rows_per_page=rows_per_page,
pageno=pageno,
fields_convert_map=fields_convert_map,
)
if "data" in request.values:
return json(view.json())
else:
return {"forum": forum, "filter": filter}
示例9: list
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()
示例10: forum_index
def forum_index(self, id):
"""
显示某论坛页面
"""
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/FORUM_INDEX_NUMS')))
Topic = get_model('forumtopic')
Forum = get_model('forum')
forum = Forum.get(int(id))
condition = Topic.c.forum == int(id)
order_by = [Topic.c.sticky.desc(), Topic.c.created_on.desc()]
if not forum.managers.has(request.user):
condition = (Topic.c.hidden==False) & condition
filter = request.GET.get('filter', 'all')
if filter == 'essence':
condition = (Topic.c.essence==True) & condition
def created_on(value, obj):
return value.strftime('%Y-%m-%d')
def last_reply_on(value, obj):
return timesince(value)
def subject(value, obj):
if obj.topic_type:
_type = u'[%s]' % obj.get_display_value('topic_type')
else:
_type = ''
s = ''
if obj.sticky:
s += u'<font color="red">[顶]</font>'
if obj.hidden:
s += u'<font color="red">[隐]</font>'
if obj.closed:
s += u'<font color="red">[关]</font>'
if obj.essence:
s += u'<font color="red">[精]</font>'
if obj.homepage:
s += u'<font color="red">[首]</font>'
return _type+ '<a href="/forum/%d/%d">%s</a>' % (int(id), obj.id, obj.subject) + s
fields_convert_map = {'created_on':created_on, 'subject':subject,
'last_reply_on':last_reply_on}
view = ListView(Topic, condition=condition, order_by=order_by,
rows_per_page=rows_per_page, pageno=pageno,
fields_convert_map=fields_convert_map)
if 'data' in request.values:
return json(view.json())
else:
return {'forum':forum, 'filter':filter}
示例11: admin_categories
def admin_categories(self):
"""
返回版块信息
"""
from uliweb.utils.generic import ListView
def ordering(value, obj):
return obj.ordering
view = ListView('forumcategory', pagination=False, fields_convert_map={'ordering':ordering})
return json(view.json())
示例12: list
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
示例13: view
def view(self):
#objects = self.blogs.all()
# model = functions.get_model('blogs').all()
# print self.blogs
# print model
# return {'objects':model}
from uliweb.utils.generic import ListView
pageno = int(request.GET.get('page',1)) - 1
rows_per_page = int(request.GET.get('rows', 8))
view = ListView(self.blogs, order_by=self.blogs.c.modified_time.desc(), pageno=pageno, rows_per_page=rows_per_page)
view.query()
pagination = functions.create_pagination(request.url, view.total, pageno+1, rows_per_page)
return {'objects': view.objects(),'pagination': pagination}
示例14: generic_list
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
示例15: list
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