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


Python E.p方法代码示例

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


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

示例1: calender_header

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import p [as 别名]
 def calender_header(ar):
     header = "Calendar Type"
     elems = [E.h2(*header, align="center")]
     today_url = ar.renderer.js2url("""
             Lino.cal.DailyView.detail.run(null, {"record_id": 0})
             """)
     week_url = ar.renderer.js2url("""
                     Lino.cal.WeeklyView.detail.run(null, {"record_id": 0})
                     """)
     elems.append(E.p(ar.renderer.href(today_url, gettext("Day")), align="center"))
     elems.append(E.p(ar.renderer.href(week_url, gettext("Week")), align="center"))
     elems.append(E.p(ar.goto_pk(0, gettext("This month")), align="center"))
     return elems
开发者ID:lino-framework,项目名称:xl,代码行数:15,代码来源:ui.py

示例2: get_table_summary

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

示例3: about_html

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

示例4: suppliers

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import p [as 别名]
        def suppliers(self, ar):
            """Displays a list of candidate suppliers.

            This means: all suppliers who have at least one of the
            skills required by this object.

            """
            if ar is None:
                return ''

            if not isinstance(self, dd.plugins.skills.demander_model):
                return ''
            
            Offer = rt.models.skills.Competence
            Demand = rt.models.skills.Demand
            skills = set()
            for dem in Demand.objects.filter(demander=self):
                skills.add(dem.skill)
                # skills |= set(dem.skill.get_parental_line())

            elems = []
            for spl in Offer.objects.filter(faculty__in=skills):
                if spl.end_user is not None:
                    elems.append(spl.end_user.obj2href(ar))
            elems = join_elems(elems, ', ')
            return E.p(*elems)
开发者ID:lino-framework,项目名称:xl,代码行数:28,代码来源:mixins.py

示例5: print_actions

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import p [as 别名]
 def print_actions(self, ar):
     if ar is None:
         return ''
     elems = []
     elems.append(ar.instance_action_button(
         self.write_xml))
     return E.p(*join_elems(elems, sep=", "))
开发者ID:khchine5,项目名称:xl,代码行数:9,代码来源:models.py

示例6: get_table_summary

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

        def fmt(obj):
            return str(obj)

        elems = []
        for obj in sar:
            # if len(elems) > 0:
            #     elems.append(', ')

            lbl = fmt(obj)
            # if obj.state.button_text:
            #     lbl = "{0}{1}".format(lbl, obj.state.button_text)
            elems.append(ar.obj2html(obj, lbl))
        elems = join_elems(elems, sep=', ')
        toolbar = []
        ar2 = self.insert_action.request_from(sar)
        if ar2.get_permission():
            btn = ar2.ar2button()
            toolbar.append(btn)

        if len(toolbar):
            toolbar = join_elems(toolbar, sep=' ')
            elems.append(E.p(*toolbar))

        return ar.html_text(E.div(*elems))
开发者ID:khchine5,项目名称:xl,代码行数:31,代码来源:models.py

示例7: weeklyNavigation

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import p [as 别名]
 def weeklyNavigation(cls, obj, ar):
     today = obj.date
     prev = cls.date2pk(DurationUnits.months.add_duration(today, -1))
     next = cls.date2pk(DurationUnits.months.add_duration(today, 1))
     elems = cls.calender_header(ar)
     header = [
         ar.goto_pk(prev, "<<"), " ",
         "{} {}".format(monthname(today.month), today.year),
         " ", ar.goto_pk(next, ">>")]
     elems.append(E.h2(*header, align="center"))
     rows = []
     for week in CALENDAR.monthdatescalendar(today.year, today.month):
         # each week is a list of seven datetime.date objects.
         cells = []
         current_week = week[0].isocalendar()[1]
         cells.append(E.td(str(current_week)))
         for day in week:
             pk = cls.date2pk(day)
             if day.isocalendar()[1] == today.isocalendar()[1]:
                 cells.append(E.td(str(day.day)))
             else:
                 cells.append(E.td(ar.goto_pk(pk, str(day.day))))
         rows.append(E.tr(*cells, align="center"))
     elems.append(E.table(*rows, align="center"))
     elems.append(E.p(ar.goto_pk(0, gettext("This week")), align="center"))
     # for o in range(-10, 10):
     #     elems.append(ar.goto_pk(o, str(o)))
     #     elems.append(" ")
     return E.div(*elems)
开发者ID:lino-framework,项目名称:xl,代码行数:31,代码来源:ui.py

示例8: get_change_body

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

示例9: what

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import p [as 别名]
 def what(self, obj, ar):
     chunks = []
     if obj.name:
         chunks += [E.b(str(obj)), E.br()]
     chunks += sepjoin(obj.features.all())
     #~ if obj.url:
         #~ chunks += [E.br(),E.a(_("More"),href=obj.url)]
     return E.p(*chunks)
开发者ID:lino-framework,项目名称:xl,代码行数:10,代码来源:models.py

示例10: print_actions

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import p [as 别名]
 def print_actions(self, ar):
     if ar is None:
         return ''
     elems = []
     elems.append(ar.instance_action_button(
         self.print_presence_sheet))
     elems.append(ar.instance_action_button(
         self.print_presence_sheet_html))
     return E.p(*join_elems(elems, sep=", "))
开发者ID:lino-framework,项目名称:xl,代码行数:11,代码来源:models.py

示例11: welcome_messages

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import p [as 别名]
def welcome_messages(ar):
    """Yield messages for the welcome page."""
    #todo show all users active sessions

    Session = rt.models.working.Session
    # Ticket = rt.models.tickets.Ticket
    # TicketStates = rt.models.tickets.TicketStates
    me = ar.get_user()

    # your open sessions (i.e. those you are busy with)
    qs = Session.objects.filter(end_time__isnull=True)
    working = {me:[E.b(six.text_type(_("You are busy with ")))]}
    if qs.count() == 0:
        return
    for ses in qs:
        if ses.user not in working:
            working[ses.user] = [ar.obj2html(ses.user),
                                 gettext(" is working on: ")]
        txt = six.text_type(ses.ticket)
        working[ses.user].append(
            ar.obj2html(ses.ticket, txt, title=getattr(ses.ticket,'summary',"") or
                                               getattr(ses.ticket,'name',"")))

        if ses.user == me:
            working[ses.user] += [
                ' (',
                ar.instance_action_button(
                    ses.end_session, EndTicketSession.label),
                ')']
        working[ses.user].append(', ')

    if len(working[me]) > 1:

        working[me][-1] = working[me][-1].replace(", ", ".")
        result = E.p(*working.pop(me))
    else:
        result = E.p()
        working.pop(me)
    for u, s in working.items():
        if len(result):
            result.append(E.br())
        s[-1] = s[-1].replace(", ", ".")
        result.append(E.span(*s))
    yield result
开发者ID:lino-framework,项目名称:xl,代码行数:46,代码来源:models.py

示例12: get_table_summary

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import p [as 别名]
 def get_table_summary(self, obj, ar):
     chunks = []
     for other in ar.spawn(self, master_instance=obj):
         chunks.append(ar.obj2html(other))
     if len(chunks):
         s = getattr(obj, obj.dupable_words_field)
         words = ', '.join(obj.get_dupable_words(s))
         chunks.append(_("Phonetic words: {0}").format(words))
         return E.p(*join_elems(chunks))
     return ''
开发者ID:lino-framework,项目名称:lino,代码行数:12,代码来源:dupable.py

示例13: get

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import p [as 别名]
    def get(self, request, app_label=None, actor=None, pk=None):
        ar = action_request(app_label, actor, request, request.GET, False)
        ar.renderer = settings.SITE.plugins.bootstrap3.renderer

        navigator = None
        if pk and pk != '-99999' and pk != '-99998':
            elem = ar.get_row_by_pk(pk)
            if elem is None:
                raise http.Http404("%s has no row with primary key %r" %
                                   (ar.actor, pk))
                #~ raise Exception("20120327 %s.get_row_by_pk(%r)" % (rpt,pk))
            if ar.actor.show_detail_navigator:

                ni = navinfo(ar.data_iterator, elem)
                if ni:
                    # m = elem.__class__
                    buttons = []
                    #~ buttons.append( ('*',_("Home"), '/' ))

                    buttons.append(
                        ('<<', _("First page"), ar.pk2url(ni['first'])))
                    buttons.append(
                        ('<', _("Previous page"), ar.pk2url(ni['prev'])))
                    buttons.append(
                        ('>', _("Next page"), ar.pk2url(ni['next'])))
                    buttons.append(
                        ('>>', _("Last page"), ar.pk2url(ni['last'])))

                    navigator = buttons2pager(buttons)
                else:
                    navigator = E.p("No navinfo")
        else:
            elem = None

        main = layout2html(ar, elem)
       
        # The `method="html"` argument isn't available in Python 2.6,
        # only 2.7.  It is useful to avoid side effects in case of
        # empty elements: the default method (xml) writes an empty
        # E.div() as "<div/>" while in HTML5 it must be "<div></div>"
        # (and the ending / is ignored).
        
        #~ return tostring(main, method="html")
        #~ return tostring(main)
        # return main

        context = dict(
            title=ar.get_action_title(),
            obj=elem,
            form=main,
            navigator=navigator,
        )
        #~ template = web.jinja_env.get_template('detail.html')
        context.update(ar=ar)
        return http_response(ar, ar.actor.detail_html_template, context)
开发者ID:lino-framework,项目名称:lino,代码行数:57,代码来源:views.py

示例14: to_html

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

示例15: pupil_info

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import p [as 别名]
 def pupil_info(self, ar):
     txt = self.pupil.get_full_name(nominative=True)
     if ar is None:
         elems = [txt]
     else:
         elems = [ar.obj2html(self.pupil, txt)]
     elems += [', ']
     elems += join_elems(
         list(self.pupil.address_location_lines()),
         sep=', ')
     return E.p(*elems)
开发者ID:lino-framework,项目名称:xl,代码行数:13,代码来源:models.py


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