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


Python E.ul方法代码示例

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


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

示例1: get_sidebar_html

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import ul [as 别名]
    def get_sidebar_html(self, request):
        items = []
        #~ loop over top-level nodes
        for n in Page.objects.filter(parent__isnull=True).order_by('seqno'):
            #~ items += [li for li in n.get_sidebar_items(request,self)]
            items.append(n.get_sidebar_item(request, self))
            if self.is_parented(n):
                children = []
                for ch in n.children.order_by('seqno'):
                    children.append(ch.get_sidebar_item(request, self))
                if len(children):
                    items.append(E.ul(*children, **{'class':'nav nav-list'}))

        e = E.ul(*items, **{'class':'nav nav-list'})
        return tostring_pretty(e)
开发者ID:khchine5,项目名称:xl,代码行数:17,代码来源:models.py

示例2: get_table_summary

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import ul [as 别名]
    def get_table_summary(self, master, ar):
        # master is None when called on a master table.
        if master is None:
            sar = ar
        else:
            sar = self.request_from(ar, master_instance=master)
            
        # every element of `items` is a tuple `(state,
        # list-of-objects)`.  in ar are ordered by state. we just group
        # them 
        items = []
        ci = None
            
        for obj in sar:  # self.get_request_queryset(ar):
            btn = obj.obj2href(ar)
            if ci is not None and ci[0] is obj.state:
                ci[1].append(btn)
            else:
                ci = (obj.state, [btn])
                items.append(ci)

        # now render them as a UL containing on LI per item
        items = [E.li(str(i[0]), ' : ', *join_elems(i[1], ", "))
                 for i in items]

        return E.ul(*items)
开发者ID:khchine5,项目名称:xl,代码行数:28,代码来源:ui.py

示例3: get_table_summary

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import ul [as 别名]
    def get_table_summary(self, obj, ar):
        items = []

        def add(title, flt):
            links = []
            sar = self.request(master_instance=obj, filter=flt)
            # logger.info("20141009 %s", sar.data_iterator.query)
            n = sar.get_total_count()
            if n:
                for i, ex in enumerate(sar):
                    txt = self.format_excerpt(ex)
                    if ex.build_time is not None:
                        txt += " (%s)" % naturaltime(ex.build_time)
                    links.append(ar.obj2html(ex, txt))
                    if i >= self.MORE_LIMIT:
                        # links.append(ar.href_to_request(sar, _("more")))
                        links.append('...')
                        break

                items.append(E.li(title, " : ", *join_elems(links, sep=', ')))

        # qs = sar.data_iterator
        Q = models.Q
        add(gettext("not printed"), Q(build_time__isnull=True))
        add(gettext("Today"), Q(build_time__gte=dd.today() - ONE_DAY))
        t7 = dd.today() - ONE_WEEK
        add(gettext("Last week"),
            Q(build_time__lte=dd.today(), build_time__gte=t7))
        add(gettext("Older"), Q(build_time__lt=t7))
        return E.ul(*items)
开发者ID:lino-framework,项目名称:xl,代码行数:32,代码来源:models.py

示例4: get_table_summary

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import ul [as 别名]
    def get_table_summary(cls, obj, ar):
        """Customized :meth:`summary view
        <lino.core.actors.Actor.get_table_summary>` for this table.

        """
        sar = cls.request_from(ar, master_instance=obj)
        html = []
        # items = [ar.obj2html(o, str(o.milestone)) for o in sar]
        qs = cls.model.objects.filter(ticket=obj)
        qs = dd.plugins.tickets.milestone_model.add_param_filter(
            qs, lookup_prefix='milestone__',
            # show_active=dd.YesNo.yes
            )
        items = E.ul()
        for o in qs:
            items.append(
                E.li(o.obj2href(ar, text=getattr(o.wish_type,'text', _("Wish"))), " in ", o.milestone.obj2href(ar), " : ", o.remark)
            )
        if len(items) > 0:
            html.append(tostring(items))
        # items = [o.milestone.obj2href(ar) for o in sar]
        sar = cls.insert_action.request_from(sar)
        if sar.get_permission():
            btn = sar.ar2button()
            html.append(btn)

        return ar.html_text(ar.parse_memo(tostring(html)))
开发者ID:khchine5,项目名称:xl,代码行数:29,代码来源:desktop.py

示例5: get_table_summary

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import ul [as 别名]
    def get_table_summary(cls, mi, ar):
        qs = rt.models.notify.Message.objects.filter(
            user=ar.get_user()).order_by(cls.created_order)
        qs = qs.filter(seen__isnull=True)
        # mark_all = rt.models.notify.MyMessages.get_action_by_name(
        #     'mark_all_seen')
        # html = tostring(ar.action_button(mark_all, None))
        # TODO: make action_button() work with list actions
        # html = ''
        ba = rt.models.notify.MyMessages.get_action_by_name('mark_seen')

        def fmt(obj):
            s = tostring(ar.action_button(ba, obj))
            s += fds(obj.created) + " " + obj.created.strftime(
                settings.SITE.time_format_strftime) + " "
            if obj.body:
                s += ar.parse_memo(obj.body)
            else:
                s += ar.parse_memo(obj.subject)
            e = etree.parse(StringIO(s), html_parser)
            return E.li(E.div(*e.iter()))
            # s += obj.body
            # return "<li>{}</li>".format(s)

        items = []
        for obj in qs:
            items.append(fmt(obj))
        return E.ul(*items)
开发者ID:lino-framework,项目名称:lino,代码行数:30,代码来源:models.py

示例6: as_ul

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import ul [as 别名]
 def as_ul(action_spec):
     a = settings.SITE.models.resolve(action_spec)
     ar = a.request(
         user=settings.SITE.user_model.get_anonymous_user())
     # 20150810
     ar.renderer = self
     # ar.renderer = settings.SITE.plugins.bootstrap3.renderer
     return tostring(E.ul(*[obj.as_list_item(ar) for obj in ar]))
开发者ID:lino-framework,项目名称:lino,代码行数:10,代码来源:renderer.py

示例7: to_html

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import ul [as 别名]
 def to_html(self, ar):
     self.analyze_view()
     get_rnd = rt.models.cal.EventGenerator.get_cal_entry_renderer
     if self.mode == TABLE_MODE:
         sep = ' '
         fmt = get_rnd(day_and_weekday)
     elif self.mode == UL_MODE:
         sep = ' '
         fmt = get_rnd(day_and_weekday)
     elif self.mode == PLAIN_MODE:
         sep = ', '
         fmt = get_rnd(dd.fds)
         
     def xxx(list_of_entries):
         elems = []
         for e in list_of_entries:
             if len(elems):
                 elems.append(sep)
             elems.extend(fmt(e, ar))
         return elems
     
     if self.mode == TABLE_MODE:
         rows = []
         cells = [E.th("")] + [E.th(monthname(m+1)) for m in range(12)]
         # print(''.join([tostring(c) for c in cells]))
         rows.append(E.tr(*cells))
         for y in self.years.values():
             cells = [E.td(str(y.year), width="4%")]
             for m in y.months:
                 # every m is a list of etree elems
                 cells.append(E.td(*xxx(m), width="8%", **ar.renderer.cellattrs))
             # print(str(y.year) +":" + ''.join([tostring(c) for c in cells]))
             rows.append(E.tr(*cells))
         return E.table(*rows, **ar.renderer.tableattrs)
     
     if self.mode == UL_MODE:
         items = []
         for y in self.years.values():
             for m, lst in enumerate(y.months):
                 if len(lst):
                     items.append(E.li(
                         monthname(m+1), " ", str(y.year), ": ", *xxx(lst)))
         return E.ul(*items)
     
     if self.mode == PLAIN_MODE:
         elems = []
         for y in self.years.values():
             for lst in y.months:
                 if len(lst):
                     if len(elems):
                         elems.append(sep)
                     elems.extend(xxx(lst))
         return E.p(*elems)
     
     raise Exception("20180720")
开发者ID:khchine5,项目名称:xl,代码行数:57,代码来源:ui.py

示例8: show_menu

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import ul [as 别名]
    def show_menu(self, ar, mnu, level=1):
        """
        Render the given menu as an HTML element.
        Used for writing test cases.
        """
        if not isinstance(mnu, Menu):
            assert isinstance(mnu, MenuItem)
            if mnu.bound_action:
                sar = mnu.bound_action.actor.request(
                    action=mnu.bound_action,
                    user=ar.user, subst_user=ar.subst_user,
                    requesting_panel=ar.requesting_panel,
                    renderer=self, **mnu.params)
                # print("20170113", sar)
                url = sar.get_request_url()
            else:
                url = mnu.href
            assert mnu.label is not None
            if url is None:
                return E.p()  # spacer
            return E.li(E.a(str(mnu.label), href=url, tabindex="-1"))

        items = [self.show_menu(ar, mi, level + 1) for mi in mnu.items]
        #~ print 20120901, items
        if level == 1:
            return E.ul(*items, **{'class':'nav navbar-nav'})
        if mnu.label is None:
            raise Exception("%s has no label" % mnu)
        if level == 2:
            cl = 'dropdown'
            menu_title = E.a(
                str(mnu.label), E.b(' ', **{'class': "caret"}), href="#",
                data_toggle="dropdown", **{'class':'dropdown-toggle'})
        elif level == 3:
            menu_title = E.a(str(mnu.label), href="#")
            cl = 'dropdown-submenu'
        else:
            raise Exception("Menu with more than three levels")
        return E.li(
            menu_title,
            E.ul(*items, **{'class':'dropdown-menu'}),
            **{'class':cl})
开发者ID:lino-framework,项目名称:lino,代码行数:44,代码来源:renderer.py

示例9: buttons2pager

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import ul [as 别名]
def buttons2pager(buttons, title=None):
    items = []
    if title:
        items.append(E.li(E.span(title)))
    for symbol, label, url in buttons:
        if url is None:
            items.append(E.li(E.span(symbol), **{'class':"disabled"}))
        else:
            items.append(E.li(E.a(symbol, href=url)))
    # Bootstrap version 2.x
    # return E.div(E.ul(*items), class_='pagination')
    return E.ul(*items, **{'class':'pagination pagination-sm'})
开发者ID:lino-framework,项目名称:lino,代码行数:14,代码来源:views.py

示例10: get_table_summary

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import ul [as 别名]
    def get_table_summary(self, obj, ar):
        if ar is None:
            return ''
        elems = []

        # Button for starting a session from ticket
        sar = obj.start_session.request_from(ar)
        # if ar.renderer.is_interactive and sar.get_permission():
        # if sar.get_permission():
        #     btn = sar.ar2button(obj)
        #     elems += [E.p(btn)]

        # Active sessions:
        active_sessions = []
        session_summaries = E.ul()
        qs = rt.models.working.Session.objects.filter(ticket=obj)
        tot = Duration()
        for ses in qs:
            d = ses.get_duration()
            if d is not None:
                tot += d
            if ses.end_time is None:
                txt = "{0} since {1}".format(ses.user, ses.start_time)
                lnk = ar.obj2html(ses, txt)
                sar = ses.end_session.request_from(ar)
                if sar.get_permission():
                    lnk = E.span(lnk, " ", sar.ar2button(ses))
                active_sessions.append(lnk)
            if ses.summary:
                session_summaries.insert(0,
                    E.li(
                        "%s %s: %s"%(ses.user,
                                     naturaltime(datetime.combine(
                                                 ses.start_date, ses.start_time))
                                     ,ses.summary)
                    )
                )


        # elems.append(E.p(_("Total {0} hours.").format(tot)))
        elems.append(E.p(_("Total %s hours.") % tot))

        if len(active_sessions) > 0:
            elems.append(E.p(
                ensureUtf(_("Active sessions")), ": ",
                *join_elems(active_sessions, ', ')))
        if len(session_summaries) > 0:
            elems.append(session_summaries)

        return ar.html_text(E.div(*elems))
开发者ID:lino-framework,项目名称:xl,代码行数:52,代码来源:ui.py

示例11: about_html

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import ul [as 别名]
    def about_html(cls):

        body = []

        body.append(settings.SITE.welcome_html())

        if settings.SITE.languages:
            body.append(E.p(str(_("Languages")) + ": " + ', '.join([
                lng.django_code for lng in settings.SITE.languages])))

        # print "20121112 startup_time", settings.SITE.startup_time.date()
        def dtfmt(dt):
            if isinstance(dt, float):
                dt = datetime.datetime.fromtimestamp(dt)
                # raise ValueError("Expected float, go %r" % dt)
            return str(_("%(date)s at %(time)s")) % dict(
                date=dd.fds(dt.date()),
                time=settings.SITE.strftime(dt.time()))

        value = settings.SITE.startup_time
        label = _("Server uptime")
        body.append(E.p(
            str(label), ' : ', E.b(dtfmt(value)),
            ' ({})'.format(settings.TIME_ZONE)))
        if settings.SITE.is_demo_site:
            s = str(_("This is a Lino demo site."))
            body.append(E.p(s))
        if settings.SITE.the_demo_date:
            s = _("We are running with simulated date set to {0}.").format(
                dd.fdf(settings.SITE.the_demo_date))
            body.append(E.p(s))
            
        body.append(E.p(str(_("Source timestamps:"))))
        items = []
        times = []
        packages = set(['lino', 'django', 'atelier'])
        for p in settings.SITE.installed_plugins:
            packages.add(p.app_name.split('.')[0])
        for src in packages:
            label = src
            value = codetime('%s.*' % src)
            if value is not None:
                times.append((label, value))

        times.sort(key=lambda x: x[1])
        for label, value in times:
            items.append(E.li(str(label), ' : ', E.b(dtfmt(value))))
        body.append(E.ul(*items))
        return rt.html_text(E.div(*body))
开发者ID:lino-framework,项目名称:lino,代码行数:51,代码来源:models.py

示例12: get_table_summary

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import ul [as 别名]
 def get_table_summary(self, obj, ar):
     sar = self.request_from(ar, master_instance=obj)
     items = []
     for c in sar:
         # todo have another js button that will expand the summary
         # into the complete description.
         items.append(E.li(
             E.a(c.sha[:6], href=c.url, target="_BLANK"),
             ":" if c.user else "",
             ar.obj2html(c.user) if c.user else "",
             ":",
             ar.obj2html(
                 c, naturaltime(c.created),
                 title=c.created.strftime('%Y-%m-%d %H:%M')),
             E.br(), c.summary))
     return E.ul(*items)
开发者ID:lino-framework,项目名称:xl,代码行数:18,代码来源:desktop.py

示例13: get_change_body

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import ul [as 别名]
 def get_change_body(self, ar, cw):
     ctx = dict(user=ar.user, what=ar.obj2memo(self))
     if cw is None:
         elems = [E.p(
             _("{user} created {what}").format(**ctx), ".")]
         elems += list(self.get_change_info(ar, cw))
     else:
         items = list(cw.get_updates_html(["_user_cache"]))
         if len(items) == 0:
             return
         elems = []
         elems += list(self.get_change_info(ar, cw))
         elems.append(E.p(
             _("{user} modified {what}").format(**ctx), ":"))
         elems.append(E.ul(*items))
     # print("20170210 {}".format(tostring(E.div(*elems))))
     return tostring(E.div(*elems))
开发者ID:lino-framework,项目名称:lino,代码行数:19,代码来源:mixins.py

示例14: to_html

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import ul [as 别名]
    def to_html(self, ar):
        self.analyze_view()
        
        if self.mode == TABLE_MODE:
            sep = ' '
            fmt = day_and_weekday
        elif self.mode == UL_MODE:
            sep = ' '
            fmt = day_and_weekday
        elif self.mode == PLAIN_MODE:
            sep = ', '
            fmt = dd.fds

        def rnd(obj, ar):
            if self.model is rt.models.cal.Guest:
                d = obj.event.start_date
                evt = obj.event
            else:
                d = obj.start_date
                evt = obj
            # if show_auto_num and evt.auto_type:
            #     yield str(evt.auto_type)+":"
            yield ar.obj2html(evt, fmt(d))
            if obj.state.button_text:
                yield str(obj.state.button_text)
            # return (fdmy(d) + ": ", ar.obj2html(evt, lbl))

        
            
        def xxx(list_of_entries):
            elems = []
            # for e in reversed(list_of_entries):
            for e in list_of_entries:
                if len(elems):
                    elems.append(sep)
                elems.extend(rnd(e, ar))
            return elems
        
        if self.mode == TABLE_MODE:
            rows = []
            cells = [E.th("")] + [E.th(monthname(m+1)) for m in range(12)]
            # print(''.join([tostring(c) for c in cells]))
            rows.append(E.tr(*cells))
            for y in self.years.values():
                cells = [E.td(str(y.year), width="4%")]
                for m in y.months:
                    # every m is a list of etree elems
                    cells.append(E.td(*xxx(m), width="8%", **ar.renderer.cellattrs))
                # print(str(y.year) +":" + ''.join([tostring(c) for c in cells]))
                rows.append(E.tr(*cells))
            return E.table(*rows, **ar.renderer.tableattrs)
        
        if self.mode == UL_MODE:
            items = []
            for y in self.years.values():
                for m, lst in enumerate(reversed(y.months)):
                    # January is [11], Dec is [0]
                    if len(lst):
                        items.append(E.li(
                            monthname(12-m), " ", str(y.year), ": ", *xxx(lst)))
            return E.ul(*items)
        
        if self.mode == PLAIN_MODE:
            elems = []
            for y in self.years.values():
                for lst in y.months:
                    if len(lst):
                        if len(elems):
                            elems.append(sep)
                        elems.extend(xxx(lst))
            return E.p(*elems)
        
        raise Exception("20180720")
开发者ID:lino-framework,项目名称:xl,代码行数:75,代码来源:ui.py


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