• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python generic.ListView类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中uliweb.utils.generic.ListView的典型用法代码示例。如果您正苦于以下问题:Python ListView类的具体用法?Python ListView怎么用?Python ListView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ListView类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
开发者ID:datakungfu,项目名称:plugs,代码行数:25,代码来源:views.py


示例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
开发者ID:pyhunterpig,项目名称:plugs,代码行数:31,代码来源:views_admin.py


示例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()}
开发者ID:neoyoung,项目名称:uliwebzone,代码行数:7,代码来源:views.py


示例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
开发者ID:lypinggan,项目名称:plugs,代码行数:60,代码来源:views.py


示例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) + ("&nbsp; <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
开发者ID:chu888chu888,项目名称:Python--uliweb-redbreast,代码行数:31,代码来源:views.py


示例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()}
开发者ID:chu888chu888,项目名称:Python-uliwebzone,代码行数:7,代码来源:views.py


示例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
开发者ID:woerwin,项目名称:uliwebzone,代码行数:58,代码来源:views.py


示例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}
开发者ID:datakungfu,项目名称:plugs,代码行数:56,代码来源:views.py


示例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()
开发者ID:damonchen,项目名称:uliweb-doc,代码行数:10,代码来源:views.py


示例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}
开发者ID:pyhunterpig,项目名称:plugs,代码行数:54,代码来源:views.py


示例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())
开发者ID:qq40660,项目名称:forum2,代码行数:11,代码来源:views.py


示例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
开发者ID:uliwebext,项目名称:uliweb-redbreast-doc,代码行数:12,代码来源:views.py


示例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}
开发者ID:seyrenhe,项目名称:uliweb-myblog,代码行数:13,代码来源:views.py


示例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
开发者ID:chyhutu,项目名称:plugs,代码行数:51,代码来源:views.py


示例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
开发者ID:uliwebext,项目名称:uliweb-redbreast-doc,代码行数:15,代码来源:views.py


示例16: admin_forumtopictype

 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
开发者ID:pyhunterpig,项目名称:plugs,代码行数:20,代码来源:views.py


示例17: admin_forum_query

 def admin_forum_query(self):
     """
     显示管理论坛页面
     """
     from uliweb.utils.generic import ListView
     
     cat = request.GET.get('category_id', 0)
     condition = self.model.c.category == int(cat)
     
     def ordering(value, obj):
         return obj.ordering
     
     def topictype(value, obj):
         return dict([(x.id,unicode(x)) for x in obj.forum_topictypes.all()])
     
     view = ListView(self.model, pagination=False, condition=condition,
         fields_convert_map={'managers':convert_managers, 
             'ordering':ordering,
             'topictype':topictype})
     return json(view.json())
开发者ID:qq40660,项目名称:forum2,代码行数:20,代码来源:views.py


示例18: todolist

    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
开发者ID:uliwebext,项目名称:uliweb-redbreast-doc,代码行数:20,代码来源:views.py


示例19: test

    def test(self):
        from uliweb.utils.generic import ListView
        print functions
        #页面编号
        pageno = int(request.GET.get('page', 1)) - 1
        #每页文章数量,5为每页显示的文章
        rows_per_page = int(request.GET.get('rows', 8))
        print int(request.GET.get('rows', 1))
        #后面的参数为请求网址,所有记录数, 总页数, 每页文章数


        def modified_date(value, obj):
            return self._get_date(obj.modified_date)

        #fields_convert_map = {'modified_date': modified_date}

        #view = ListView(self.model, order_by=self.model.c.modified_time.desc(), pageno=pageno, rows_per_page=rows_per_page, fields_convert_map=fields_convert_map)
        view = ListView(self.model, order_by=self.model.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}
开发者ID:seyrenhe,项目名称:uliweb-myblog,代码行数:21,代码来源:views.py


示例20: index

    def index(self):
        """
        教程显示首页
        """
        from uliweb.utils.generic import ListView

        condition = (self.model.c.deleted==False)

        pageno = int(request.GET.get('page', 1)) - 1
        rows_per_page = int(request.GET.get('rows', 10))
        cateobjects = self.model_cate.all()

#        def render(r, obj):
#            from uliweb import Storage
#            
#            data = Storage(dict(r))
#            data['image'] = obj.get_image()
#            data['author'] = unicode(obj.modified_user)
#            data['modified_date'] = self._get_date(obj.modified_date)
#            return data

        def image(value, obj):
            return obj.get_image()
    
        def author(value, obj):
            return unicode(obj.modified_user)
        
        def modified_date(value, obj):
            return self._get_date(obj.modified_date)
        
        fields_convert_map = {'image':image, 'author':author, 'modified_date':modified_date}
        
        view = ListView(self.model, condition=condition, 
            order_by=self.model.c.modified_date.desc(), pageno=pageno,
            rows_per_page=rows_per_page, fields_convert_map=fields_convert_map)
            
        view.query()
        pagination = functions.create_pagination(request.url, view.total, pageno+1, 
            rows_per_page)
        return {'pagination':pagination, 'objects':view.objects(),'cateobjects':cateobjects}
开发者ID:kooksee,项目名称:uliwebzone,代码行数:40,代码来源:views.py



注:本文中的uliweb.utils.generic.ListView类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python ultrajson.decode函数代码示例发布时间:2022-05-27
下一篇:
Python generic.EditView类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap