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


Python E.span方法代码示例

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


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

示例1: buttons2pager

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

示例2: question

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import span [as 别名]
    def question(self, obj, ar):
        if obj.question.number:
            txt = obj.question.NUMBERED_TITLE_FORMAT % (
                obj.question.number, obj.question.title)
        else:
            txt = obj.question.title

        attrs = {}
        if obj.question.details:
            attrs.update(title=obj.question.details)
        if obj.question.is_heading:
            txt = E.b(txt, **attrs)
        return ar.html_text(E.span(txt, **attrs))
开发者ID:lino-framework,项目名称:xl,代码行数:15,代码来源:models.py

示例3: info

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import span [as 别名]
 def info(self, row, ar):
     elems = []
     if row.project:
         elems.append(ar.obj2html(row.project))
     if row.partner:
         elems.append(ar.obj2html(row.partner))
         # elems.append(row.partner.address)
     if row.bank_account:
         elems.append(ar.obj2html(row.bank_account))
     if row.account:
         elems.append(ar.obj2html(row.account))
     # return E.span(*join_elems(elems, ' / '))
     return E.span(*join_elems(elems, E.br))
开发者ID:khchine5,项目名称:xl,代码行数:15,代码来源:ui.py

示例4: get_table_summary

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

示例5: get_html_chunks

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import span [as 别名]
 def get_html_chunks(self, level=1):
     h = headertag(level)
     if self.title:
         yield h(self.title)
         level += 1
         h = headertag(level)
         
     #~ for v in Verse.objects.filter(section=self).order_by('seqno'):
     for v in VerseText.objects.filter(section=self):
         yield E.span(v.text)
         
     for s in Section.objects.filter(parent=self).order_by('seqno'):
         for chunk in s.get_html_chunks(level):
             yield chunk
开发者ID:lsaffre,项目名称:lino-logos,代码行数:16,代码来源:models.py

示例6: description

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import span [as 别名]
 def description(self, obj, ar):
     # pv = dict(start_date=obj.day, end_date=obj.day)
     # pv.update(observed_event=dd.PeriodEvents.active)
     # pv.update(user=ar.param_values.user)
     # sar = ar.spawn(MySessionsByDate, param_values=pv)
     elems = [obj.sar.ar2button(label=six.text_type(obj))]
     tickets = [
         ar.obj2html(t, "#{0}".format(t.id), title=t.summary)
         for t in obj._tickets]
     if len(tickets) > 0:
         elems.append(" (")
         elems += join_elems(tickets, ', ')
         elems.append(")")
     return E.span(*elems)
开发者ID:khchine5,项目名称:xl,代码行数:16,代码来源:ui.py

示例7: get_table_summary

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

        """
        sar = self.request_from(ar, master_instance=obj)

        html = []
        states = {}
        for s, d in VoteStates.choices:
            states[s] = []

        u = ar.get_user()

        for o in sar:
            states[o.state].append(ar.obj2html(o, o.user.initials or str(o.user), title=o.state))
            if u == o.user:
                html.insert(0, E.span(
                    E.b(str(o.state)),
                    u" \u2192 ",
                    *join_elems([sar.action_button(ba, o) for ba in sar.actor.get_actions()
                                 if ba.action.show_in_workflow and
                                 sar.actor.get_row_permission(o, sar, o.state, ba) and
                                 isinstance(ba.action, dd.ChangeStateAction)],
                                " ")
                ))


        html.append(E.ul(
            *[E.li(*([str(s.text),  ": "] + join_elems(states[s], sep=", "))) for s, c in VoteStates.choices
              if states[s]
              ]
        ))
        # print(tostring(html))
        # items = [
        #     ar.obj2html(o, o.user.username or str(o.user))
        #     for o in rt.models.votes.Vote.objects.filter(
        #             votable=obj).order_by('-id')]
        # sar.get_user() == v.user
        sar = self.insert_action.request_from(sar)
        if sar.get_permission():
            # btn = sar.ar2button(None, _("Add voter"), icon_name=None)
            btn = sar.ar2button()
            # btn = sar.ar2button(None, u"⏍", icon_name=None)  # 23CD SQUARE FOOT
            # btn = sar.ar2button(None, u"⊞", icon_name=None) # 229e SQUARED PLUS
            
            html.append(E.div(btn))

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

示例8: welcome_messages

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import span [as 别名]
            def welcome_messages(ar):
                def fmt(model, pk):
                    try:
                        obj = model.objects.get(pk=pk)
                    except model.DoesNotExist:
                        return "{}{}".format(model.__name__, pk)
                    return ar.obj2html(obj)

                up = ar.get_user().get_preferences()
                if len(up.locked_rows):
                    chunks = [
                        ugettext("You have a dangling edit lock on"), " "]
                    chunks += join_elems(
                        [fmt(m, pk) for m, pk in up.locked_rows], ", ")
                    chunks.append('.')
                    yield E.span(*chunks)
开发者ID:lino-framework,项目名称:lino,代码行数:18,代码来源:__init__.py

示例9: needed_skills

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

            This means: all skill demands for this object.

            """
            if ar is None:
                return ''
            if not isinstance(self, dd.plugins.skills.demander_model):
                return ''
            Demand = rt.models.skills.Demand
            elems = []
            for dem in Demand.objects.filter(demander=self):
                elems.append(dem.skill.obj2href(ar))
            elems = join_elems(elems, ', ')
            return E.span(*elems)
开发者ID:lino-framework,项目名称:xl,代码行数:18,代码来源:mixins.py

示例10: welcome_messages

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import span [as 别名]
def welcome_messages(ar):
    """Yield a message "Your stars are X, Y, ..." for the welcome page.

    This message mentions all starred objects of the requesting user
    and whose :attr:`nickname <Star.nickname>` is not empty.

    """
    Star = rt.models.stars.Star
    qs = Star.objects.filter(user=ar.get_user()).exclude(nickname='')
    if qs.count() > 0:
        chunks = [unicode(_("Your stars are "))]
        chunks += join_elems([
            ar.obj2html(obj.owner, obj.nickname or unicode(obj.owner))
            for obj in qs])
        chunks.append('.')
        yield E.span(*chunks)
开发者ID:khchine5,项目名称:xl,代码行数:18,代码来源:models.py

示例11: answer_buttons

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import span [as 别名]
    def answer_buttons(self, obj, ar):
        # assert isinstance(obj, Answer)
        cs = obj.question.get_choiceset()
        if cs is None:
            return ''

        elems = []
        pv = dict(question=obj.question)

        # ia = obj.response.toggle_choice
        sar = obj.response.toggle_choice.request_from(
            ar, is_on_main_actor=False)
        # print(20170731, sar.is_on_main_actor)
        if False:  # since 20170129
            ba = Responses.actions.toggle_choice
            if ba is None:
                raise Exception("No toggle_choice on {0}?".format(ar.actor))
            sar = ba.request_from(ar)

            # print("20150203 answer_buttons({0})".format(sar))

            # if the response is registered, just display the choice, no
            # toggle buttons since answer cannot be toggled:
            # 20151211
            sar.selected_rows = [obj.response]
            
        if not sar.get_permission():
            return str(obj)

        AnswerChoice = rt.models.polls.AnswerChoice
        for c in cs.choices.all():
            pv.update(choice=c)
            text = str(c)
            qs = AnswerChoice.objects.filter(
                response=obj.response, **pv)
            if qs.count() == 1:
                text = [E.b('[', text, ']')]
            elif qs.count() == 0:
                pass
            else:
                raise Exception(
                    "Oops: %s returned %d rows." % (qs.query, qs.count()))
            sar.set_action_param_values(**pv)
            e = sar.ar2button(obj.response, text, style="text-decoration:none")
            elems.append(e)
        return ar.html_text(E.span(*join_elems(elems)))
开发者ID:lino-framework,项目名称:xl,代码行数:48,代码来源:models.py

示例12: welcome_messages

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

示例13: get_workflow_buttons

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import span [as 别名]
    def get_workflow_buttons(obj, ar):
        l = []
        actor = ar.actor
        # print(20170102, actor)
        state = actor.get_row_state(obj)
        sep = ''
        show = True  # whether to show the state
        # logger.info('20161219 workflow_buttons %r', state)

        def show_state():
            l.append(sep)
            #~ l.append(E.b(unicode(state),style="vertical-align:middle;"))
            if state.button_text:
                l.append(E.b(u"{} {}".format(state.button_text, state)))
            else:
                l.append(E.b(str(state)))
            # l.append(E.b(str(state)))
            #~ l.append(u" » ")
            #~ l.append(u" \u25b8 ")
            #~ l.append(u" \u2192 ")
            #~ sep = u" \u25b8 "

        df = actor.get_disabled_fields(obj, ar)
        # print(20170909, df)
        for ba in actor.get_actions():
            assert ba.actor == actor  # 20170102
            if ba.action.show_in_workflow:
                # if actor.model.__name__ == 'Vote':
                #     if ba.action.__class__.__name__ == 'MarkVoteAssigned':
                #         print(20170115, actor, ar.get_user())
                if ba.action.action_name not in df:
                  if actor.get_row_permission(obj, ar, state, ba):
                    if show and isinstance(ba.action, ChangeStateAction):
                        show_state()
                        sep = u" \u2192 "  # "→"
                        show = False
                    l.append(sep)
                    l.append(ar.action_button(ba, obj))
                    sep = ' '
        if state and show:
            show_state()
        return E.span(*l)
开发者ID:lino-framework,项目名称:lino,代码行数:44,代码来源:model.py

示例14: workflow_buttons

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import span [as 别名]
    def workflow_buttons(self, ar, **kwargs):
        if ar is None:
            return ''
        l = super(Deployment, self).get_workflow_buttons(ar)

        sar = rt.models.comments.CommentsByRFC.insert_action.request_from(ar)

        owner = ContentType.objects.get(app_label='tickets', model="ticket")
        # sar.bound_action.icon_name = None
        # sar.bound_action.label = _(" New Comment")

        sar.known_values.update(
            owner_id=self.ticket.id,
            owner_type=owner,
            # owner=self.ticket,
            user=ar.get_user()
        )
        if sar.get_permission():
            l.append(E.span(u", "))
            l.append(sar.ar2button(icon_name=None, label=_("New Comment")))
        # print self.E.tostring(l)
        return l
开发者ID:lino-framework,项目名称:xl,代码行数:24,代码来源:models.py

示例15: table2html

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import span [as 别名]
def table2html(ar, as_main=True):
    """Represent the given table request as an HTML table.

    `ar` is the request to be rendered, an instance of
    :class:`lino.core.tablerequest.TableRequest`.

    The returned HTML enclosed in a ``<div>`` tag and generated using
    :mod:`etgen.html`.

    If `as_main` is True, include additional elements such as a paging
    toolbar. (This argument is currently being ignored.)

    """
    # as_main = True
    t = xghtml.Table()
    t.attrib.update(**{'class':"table table-striped table-hover"})
    if ar.limit is None:
        ar.limit = PLAIN_PAGE_LENGTH
    pglen = ar.limit
    if ar.offset is None:
        page = 1
    else:
        """
        (assuming pglen is 5)
        offset page
        0      1
        5      2
        """
        page = int(old_div(ar.offset, pglen)) + 1

    ar.dump2html(t, ar.sliced_data_iterator, header_links=as_main)
    if not as_main:
        url = ar.get_request_url()  # open in own window
        return E.div(
            E.div(
                E.div(
                    E.a(
                        E.span(**{'class':"glyphicon glyphicon-folder-open"}),
                        href=url, style="margin-left: 4px;",
                        **{'class':"btn btn-default pull-right"}),
                    E.h5(ar.get_title(), style="display: inline-block;"),
                    **{'class': "panel-title"}),
                **{'class':"panel-heading"}),
                t.as_element(),
            style="display: inline-block;",
            **{'class':"panel panel-default"})

    buttons = []
    kw = dict()
    kw = {}
    if pglen != PLAIN_PAGE_LENGTH:
        kw[constants.URL_PARAM_LIMIT] = pglen

    if page > 1:
        kw[constants.URL_PARAM_START] = pglen * (page - 2)
        prev_url = ar.get_request_url(**kw)
        kw[constants.URL_PARAM_START] = 0
        first_url = ar.get_request_url(**kw)
    else:
        prev_url = None
        first_url = None
    buttons.append(('<<', _("First page"), first_url))
    buttons.append(('<', _("Previous page"), prev_url))

    next_start = pglen * page
    if next_start < ar.get_total_count():
        kw[constants.URL_PARAM_START] = next_start
        next_url = ar.get_request_url(**kw)
        last_page = int(old_div((ar.get_total_count() - 1), pglen))
        kw[constants.URL_PARAM_START] = pglen * last_page
        last_url = ar.get_request_url(**kw)
    else:
        next_url = None
        last_url = None
    buttons.append(('>', _("Next page"), next_url))
    buttons.append(('>>', _("Last page"), last_url))

    return E.div(buttons2pager(buttons), t.as_element())
开发者ID:lino-framework,项目名称:lino,代码行数:80,代码来源:views.py


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