Ejemplo n.º 1
0
    def to_rst(cls, ar, column_names=None, header_level=None, **kwargs):
        "Better name would be table2rst (analog to table2xhtml())"
        fields, headers, widths = ar.get_field_info(column_names)
        # ~ # in case column_names contains remote fields
        #~ settings.SITE.startup()
        #~ settings.SITE.resolve_virtual_fields()

        #~ grid = ar.ah.list_layout.main

        sums = [fld.zero for fld in fields]
        rows = []
        recno = 0
        #~ for row in ar:
        for row in ar.sliced_data_iterator:
            recno += 1
            rows.append([x for x in ar.row2text(fields, row, sums)])
            #~ rows.append([x for x in grid.row2html(ar,fields,row,sums)])

        has_sum = False
        for i in sums:
            if i:
                #~ print '20120914 zero?', repr(i)
                has_sum = True
                break
        if has_sum:
            rows.append([x for x in ar.sums2html(fields, sums)])

        t = RstTable(headers, **kwargs)
        s = t.to_rst(rows)
        if header_level is not None:
            s = E.tostring(E.h2(ar.get_title())) + s
        return s
Ejemplo n.º 2
0
    def to_rst(cls, ar, column_names=None, header_level=None, **kwargs):
        "Better name would be table2rst (analog to table2xhtml())"
        fields, headers, widths = ar.get_field_info(column_names)

        sums = [fld.zero for fld in fields]
        rows = []
        recno = 0
        for row in ar.sliced_data_iterator:
            recno += 1
            rows.append([x for x in ar.row2text(fields, row, sums)])

        has_sum = False
        for i in sums:
            if i:
                #~ print '20120914 zero?', repr(i)
                has_sum = True
                break
        if has_sum:
            rows.append([x for x in ar.sums2html(fields, sums)])

        t = RstTable(headers, **kwargs)
        s = t.to_rst(rows)
        if header_level is not None:
            s = E.tostring(E.h2(ar.get_title())) + s
        return s
Ejemplo n.º 3
0
def get_poll_result(self):
    # ~ yield E.h1(self.title)
    for cs in ChoiceSet.objects.all():
        questions = self.questions.filter(choiceset=cs)
        if questions.count() > 0:
            yield E.h2(unicode(cs))
            for question in questions:
                yield E.p(question.text)
Ejemplo n.º 4
0
 def table2xhtml(self, header_level=None, **kw):
     t = xghtml.Table()
     self.dump2html(t, self.sliced_data_iterator, **kw)
     e = t.as_element()
     if header_level is not None:
         # return E.div(E.h2(self.get_title()), e)
         return E.div(E.h2(self.actor.label), e)
     return e
Ejemplo n.º 5
0
def get_poll_result(self):
    #~ yield E.h1(self.title)
    for cs in ChoiceSet.objects.all():
        questions = self.questions.filter(choiceset=cs)
        if questions.count() > 0:
            yield E.h2(unicode(cs))
            for question in questions:
                yield E.p(question.text)
Ejemplo n.º 6
0
    def get_story(cls, obj, ar):
        if ar.param_values.job_type:
            jobtypes = [ar.param_values.job_type]
        else:
            jobtypes = JobType.objects.all()

        for jobtype in jobtypes:
            yield E.h2(unicode(jobtype))
            sar = ar.spawn(JobsOverviewByType, master_instance=jobtype, param_values=dict(date=ar.param_values.today))
            yield sar
Ejemplo n.º 7
0
 def table2xhtml(self, header_level=None, **kw):
     """
     Return an HTML representation of this table request.
     """
     t = xghtml.Table()
     self.dump2html(t, self.sliced_data_iterator, **kw)
     e = t.as_element()
     # print "20150822 table2xhtml", E.tostring(e)
     if header_level is not None:
         return E.div(E.h2(self.actor.label), e)
     return e
Ejemplo n.º 8
0
 def table2xhtml(self, header_level=None, **kw):
     """
     Return an HTML representation of this table request.
     """
     t = xghtml.Table()
     self.dump2html(t, self.sliced_data_iterator, **kw)
     e = t.as_element()
     # print "20150822 table2xhtml", E.tostring(e)
     if header_level is not None:
         return E.div(E.h2(self.actor.label), e)
     return e
Ejemplo n.º 9
0
    def get_story(cls, self, ar):
        """Yield a sequence of story items. These can be (1)
        ElementTree elements or (2) AbstractTable or (3) action
        requests.

        """
        if cls.report_items is None:
            raise Exception("{0} has no report_items".format(cls))
        for A in cls.report_items:
            yield E.h2(str(A.label))
            if A.help_text:
                yield E.p(str(A.help_text))
            yield A
Ejemplo n.º 10
0
    def get_story(cls, self, ar):
        """Yield a sequence of story items. These can be (1)
        ElementTree elements or (2) AbstractTable or (3) action
        requests.

        """
        if cls.report_items is None:
            raise Exception("{0} has no report_items".format(cls))
        for A in cls.report_items:
            yield E.h2(str(A.label))
            # if A.help_text:
            #     yield E.p(str(A.help_text))
            yield A
Ejemplo n.º 11
0
 def get_story(cls,self,ar):
     #~ yield E.h2(_("Introduction"))
     #~ yield E.p("Ceci est un ",E.b("rapport"),""", 
         #~ càd un document complet généré par Lino, contenant des 
         #~ sections, des tables et du texte libre.
         #~ Dans la version écran cliquer sur un chiffre pour voir d'où 
         #~ il vient.
         #~ """)
     #~ yield E.h1(isip.Contract._meta.verbose_name_plural)
     for A in (GeneralAccountsBalance,ClientAccountsBalance,SupplierAccountsBalance):
         yield E.h2(A.label)
         if A.help_text:
             yield E.p(unicode(A.help_text))
         yield A
Ejemplo n.º 12
0
    def render(self, ar):
        T = self.actor
        sar = ar.spawn(T, limit=T.preview_limit)
        if sar.get_total_count():
            if self.header_level is None:
                s = ''
            else:
                s = E.tostring(E.h2(
                    T.label, ' ', ar.window_action_button(
                        T.default_action,
                        label="🗗",
                        style="text-decoration:none; font-size:80%;",
                        title=_("Show this table in own window"))))

            s += E.tostring(ar.show(sar))
            return s
Ejemplo n.º 13
0
    def render(self, ar):
        """Render this table to the dashboard.

        - Do nothing if there is no data.

        - If :attr:`header_level` is not None, add a header

        - Render the table itself by calling
          :meth:`lino.core.requests.BaseRequest.show`

        """
        T = self.actor
        sar = ar.spawn(T, limit=T.preview_limit)
        if not sar.get_total_count():
            return ''
        if self.header_level is None:
            s = ''
        else:
            s = E.tostring(
                E.h2(
                    T.label,
                    ' ',
                    ar.window_action_button(
                        T.default_action,
                        # label="🗗",
                        # label="☌",  # conjunction
                        # label="◱", # 25F1
                        # label="◳", # 25F3
                        # label="⏍", # 23CD
                        label="⍐",  # 2350
                        # style="text-decoration:none; font-size:80%;",
                        style="text-decoration:none;",
                        title=_("Show this table in own window"))))

        s += E.tostring(ar.show(sar))
        return s
Ejemplo n.º 14
0
 def get_story(cls, self, ar):
     for A in cls.report_items:
         yield E.h2(A.label)
         if A.help_text:
             yield E.p(unicode(A.help_text))
         yield A
Ejemplo n.º 15
0
 def render(t):
     sar = ar.spawn(t, master_instance=self)
     if sar.get_total_count():
         yield E.h2(unicode(sar.get_title()))
         yield sar