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


Python E.li方法代码示例

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


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

示例1: get_sidebar_item

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import li [as 别名]
 def get_sidebar_item(self, request, other):
     kw = dict()
     add_user_language(kw, request)
     url = self.get_absolute_url(**kw)
     a = E.a(self.get_sidebar_caption(), href=url)
     if self == other:
         return E.li(a, **{'class':'active'})
     return E.li(a)
开发者ID:khchine5,项目名称:xl,代码行数:10,代码来源:models.py

示例2: buttons2pager

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import li [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

示例3: get_change_desc_html

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import li [as 别名]
 def get_change_desc_html(self, f, old, new):
     from lino.core.choicelists import ChoiceListField
     if isinstance(f, models.TextField):
         old = old or ''
         new = new or ''
         if False:
             diff = difflib.unified_diff(
                 old.splitlines(), new.splitlines(),
                 fromfile="before", tofile="after", lineterm='')
             txt = E.pre('\n'.join(diff))
         else:
             labels = {
                 '+': _("lines added"),
                 '-': _("lines removed"),
                 '?': _("modifications"),
                 ' ': _("lines changed")}
             diff = list(difflib.ndiff(
                 old.splitlines(), new.splitlines()))
             counters = {}
             for ln in diff:
                 if ln:
                     k = ln[0]
                     c = counters.get(k, 0)
                     counters[k] = c + 1
             txt = ', '.join([
                 "{0} {1}".format(n, labels[op])
                 for op, n in counters.items()])
         return E.li(
             E.b(str(f.verbose_name)), " : ", txt)
         
     if isinstance(f, models.DateTimeField):
         return
     if isinstance(f, models.ForeignKey):
         if old:
             old = f.remote_field.model.objects.get(pk=old)
         if new:
             new = f.remote_field.model.objects.get(pk=new)
     elif isinstance(f, ChoiceListField):
         if isinstance(old, six.string_types):
             old = f.choicelist.get_by_value(old)
         if isinstance(new, six.string_types):
             new = f.choicelist.get_by_value(new)
     else:
         old = obj2unicode(old)
         new = obj2unicode(new)
     return E.li(
         E.b(str(f.verbose_name)), " : ",
         u"{0} --> {1}".format(old, new))
开发者ID:lino-framework,项目名称:lino,代码行数:50,代码来源:diff.py

示例4: get_table_summary

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import li [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

示例5: get_table_summary

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

        visible_polls = Poll.objects.filter(state__in=(
            PollStates.active, PollStates.closed)).order_by('ref')

        qs = Response.objects.filter(partner=obj).order_by('date')
        polls_responses = {}
        for resp in qs:
            polls_responses.setdefault(resp.poll.pk, []).append(resp)

        items = []
        for poll in visible_polls:
            iar = self.insert_action.request_from(
                ar, obj, known_values=dict(poll=poll))
            elems = [str(poll), ' : ']
            responses = polls_responses.get(poll.pk, [])
            elems += join_elems(
                [ar.obj2html(r, dd.fds(r.date))
                 for r in responses], sep=', ')
            if poll.state == PollStates.active:
                elems += [' ', iar.ar2button()]
                #elems += [' ', iar.insert_button()]
            items.append(E.li(*elems))
        return E.div(E.ul(*items))
开发者ID:lino-framework,项目名称:xl,代码行数:28,代码来源:models.py

示例6: get_table_summary

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import li [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

示例7: fmt

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import li [as 别名]
 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()))
开发者ID:lino-framework,项目名称:lino,代码行数:12,代码来源:models.py

示例8: to_html

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import li [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

示例9: show_menu

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import li [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

示例10: get_table_summary

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import li [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 li [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 li [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: as_list_item

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import li [as 别名]
 def as_list_item(self, ar):
     pv = dict(username=self.username)
     if settings.SITE.is_demo_site:
         pv.update(password='1234')
     btn = rt.models.users.UsersOverview.get_action_by_name('sign_in')
     # print btn.get_row_permission(ar, None, None)
     btn = btn.request(
         action_param_values=pv,
         renderer=settings.SITE.kernel.default_renderer)
     btn = btn.ar2button(label=self.username)
     items = [ btn, ' : ',
               str(self), ', ',
               str(self.user_type)]
     if self.language:
         items += [', ',
         E.strong(str(settings.SITE.LANGUAGE_DICT.get(self.language)))]
     return E.li(*items)
开发者ID:lino-framework,项目名称:lino,代码行数:19,代码来源:models.py

示例14: add

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import li [as 别名]
        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=', ')))
开发者ID:lino-framework,项目名称:xl,代码行数:19,代码来源:models.py

示例15: as_list_item

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import li [as 别名]
 def as_list_item(self, ar):
     return E.li(str(self))
开发者ID:lino-framework,项目名称:lino,代码行数:4,代码来源:model.py


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