当前位置: 首页>>代码示例>>Python>>正文


Python ListView.json方法代码示例

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


在下文中一共展示了ListView.json方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: tasks

# 需要导入模块: from uliweb.utils.generic import ListView [as 别名]
# 或者: from uliweb.utils.generic.ListView import json [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) + ("&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,代码行数:33,代码来源:views.py

示例2: admin_category

# 需要导入模块: from uliweb.utils.generic import ListView [as 别名]
# 或者: from uliweb.utils.generic.ListView import json [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
开发者ID:datakungfu,项目名称:plugs,代码行数:27,代码来源:views.py

示例3: forum_index

# 需要导入模块: from uliweb.utils.generic import ListView [as 别名]
# 或者: from uliweb.utils.generic.ListView import json [as 别名]
    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,代码行数:58,代码来源:views.py

示例4: admin_categories

# 需要导入模块: from uliweb.utils.generic import ListView [as 别名]
# 或者: from uliweb.utils.generic.ListView import json [as 别名]
 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,代码行数:13,代码来源:views.py

示例5: forum_index

# 需要导入模块: from uliweb.utils.generic import ListView [as 别名]
# 或者: from uliweb.utils.generic.ListView import json [as 别名]
 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,代码行数:56,代码来源:views.py

示例6: list

# 需要导入模块: from uliweb.utils.generic import ListView [as 别名]
# 或者: from uliweb.utils.generic.ListView import json [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
开发者ID:uliwebext,项目名称:uliweb-redbreast-doc,代码行数:14,代码来源:views.py

示例7: generic_list

# 需要导入模块: from uliweb.utils.generic import ListView [as 别名]
# 或者: from uliweb.utils.generic.ListView import json [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
开发者ID:chyhutu,项目名称:plugs,代码行数:53,代码来源:views.py

示例8: list

# 需要导入模块: from uliweb.utils.generic import ListView [as 别名]
# 或者: from uliweb.utils.generic.ListView import json [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
开发者ID:uliwebext,项目名称:uliweb-redbreast-doc,代码行数:17,代码来源:views.py

示例9: admin_forumtopictype

# 需要导入模块: from uliweb.utils.generic import ListView [as 别名]
# 或者: from uliweb.utils.generic.ListView import json [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
开发者ID:pyhunterpig,项目名称:plugs,代码行数:22,代码来源:views.py

示例10: admin_forum_query

# 需要导入模块: from uliweb.utils.generic import ListView [as 别名]
# 或者: from uliweb.utils.generic.ListView import json [as 别名]
 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,代码行数:22,代码来源:views.py

示例11: todolist

# 需要导入模块: from uliweb.utils.generic import ListView [as 别名]
# 或者: from uliweb.utils.generic.ListView import json [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
开发者ID:uliwebext,项目名称:uliweb-redbreast-doc,代码行数:22,代码来源:views.py

示例12: workflows

# 需要导入模块: from uliweb.utils.generic import ListView [as 别名]
# 或者: from uliweb.utils.generic.ListView import json [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
开发者ID:chu888chu888,项目名称:Python--uliweb-redbreast,代码行数:24,代码来源:views.py

示例13: workflow

# 需要导入模块: from uliweb.utils.generic import ListView [as 别名]
# 或者: from uliweb.utils.generic.ListView import json [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
开发者ID:chu888chu888,项目名称:Python--uliweb-redbreast,代码行数:40,代码来源:views.py

示例14: list

# 需要导入模块: from uliweb.utils.generic import ListView [as 别名]
# 或者: from uliweb.utils.generic.ListView import json [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
开发者ID:limodou,项目名称:plugs,代码行数:25,代码来源:views.py

示例15: query

# 需要导入模块: from uliweb.utils.generic import ListView [as 别名]
# 或者: from uliweb.utils.generic.ListView import json [as 别名]
 def query(self):
     from uliweb.utils.generic import ListView
     
     view = ListView(self.model, pagination=False)
     return json(view.json())
开发者ID:Yixiaohan,项目名称:uliwebzone,代码行数:7,代码来源:views.py


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