Beispiel #1
0
class SimpleTitleElement(Table):
    def __init__(self, title, **attributes):
        Table.__init__(self, **attributes)
        self.row = TableRow()
        self.cell = TableCell()
        self.set(self.row)
        self.row.set(self.cell)
        self.h1 = Header(level=1)
        self._font = Font(color='gold')
        self.cell.set(self.h1)
        self.h1.set(self._font)
        self.set_title(title)

    def set_font(self, **attributes):
        self._font.attributes.clear()
        self._font.attributes.update(attributes)

    def set_title(self, title):
        self._title = title
        self._font.set(self._title)

    # use this to make action links to the right of the title
    def create_rightside_table(self):
        self._rstable = Table(border=0)
        self.row.append(TableCell(self._rstable, align='right'))

    def append_rightside_anchor(self, anchor):
        row = TableRow()
        self._rstable.append(row)
        cell = TableCell(align='right', rowspan=1)
        row.set(cell)
        font = Font(color='gold')
        cell.set(font)
        font.set(anchor)
Beispiel #2
0
 def __init__(self, fields, idcol, action, record, **atts):
     Table.__init__(self, **atts)
     self.record = record
     refdata = None
     if hasattr(record, '_refdata'):
         refdata = record._refdata
     for field in fields:
         # make url first if action
         if action:
             stringlist = map(str, [action, field, record[idcol]])
             url = '.'.join(stringlist)
         row = TableRow()
         keycell = TableCell()
         keycell.set(Bold(field))
         row.append(keycell)
         valcell = TableCell()
         # the following code needs more comments
         # this should be a private method called _make_valcell
         if refdata is not None and field in refdata.cols:
             ridcol = refdata.cols[field]
             refrec = refrec.data[field][record[ridcol]]
             node = refdata.object[field](refrec)
             if action:
                 valcell.set(Anchor(node, href=url))
             else:
                 valcell.set(node)
         elif action:
             valcell.set(Anchor(record[field], href=url))
         else:
             valcell.set(record[field])
         row.append(valcell)
         self.val = valcell
         self.key = keycell
         self.append(row)
Beispiel #3
0
 def append_rightside_anchor(self, anchor):
     row = TableRow()
     self._rstable.append(row)
     cell = TableCell(align='right', rowspan=1)
     row.set(cell)
     font = Font(color='gold')
     cell.set(font)
     font.set(anchor)
class SimpleTitleTable(Table):
    def __init__(self, title, **args):
        Table.__init__(self, **args)
        self.row = TableRow()
        self.td = TableCell()
        self.append(self.row)
        self.row.append(self.td)
        self.set_title(title)
        
    def set_title(self, title):
        self._title = title
        self.td.set(Header(title, 1))
Beispiel #5
0
 def set_rows(self, rows):
     for row in rows:
         tablerow = TableRow()
         show_anchor = Anchor(row.template, href='show.template.%s' % row.template)
         tablerow.append(TableCell(show_anchor))
         template_data = '%s:%s (%s)' % (row.owner, row.grp_owner, row.mode)
         data_anchor = Anchor(template_data, href='edit.templatedata.%s' % row.template)
         edit_anchor = Anchor('(edit)', href='edit.template.%s' % row.template)
         del_anchor = Anchor('(delete)', href='delete.template.%s' % row.template)
         tablerow.append(TableCell(data_anchor))
         cmdcell = TableCell()
         cmdcell.set(edit_anchor)
         cmdcell.append(del_anchor)
         tablerow.append(cmdcell)
         #tablerow.append(TableCell(edit_anchor))
         #tablerow.append(TableCell(del_anchor))
         self.append(tablerow)
Beispiel #6
0
 def _setup_main_attributes(self):
     machine = self.machine.current_machine
     attribute_table = Table(bgcolor=self._bgcolor_table, border=1)
     headrow = TableRow(bgcolor=self._bgcolor_thead)
     for col in ['Attribute', 'Value', 'Inherited From', 'Command']:
         headrow.append(TableHeader(col))
     attribute_table.append(headrow)
     for attribute in ['kernel', 'profile', 'diskconfig']:
         errormsg = ''
         try:
             value, inherited_from = self.machine.get_attribute(attribute)
         except AttributeUnsetInAncestryError:
             errormsg = "WARNING: not set anywhere"
             value, inherited_from = errormsg, errormsg
         tablerow = TableRow()
         href = 'select.attribute||%s.%s' % (attribute, machine)
         anchor = Anchor(attribute, href=href)
         cell = TableCell(Bold(anchor, ':'))
         tablerow.append(cell)
         cell = TableCell(value)
         tablerow.append(value)
         cell = TableCell()
         if inherited_from is not None:
             if errormsg:
                 anchor = Bold(errormsg)
             else:
                 anchor = Anchor(inherited_from,
                                 href='select.machine.%s' % inherited_from)
             cell.append(anchor)
         else:
             cell.append('(set here)')
         tablerow.append(cell)
         cell = TableCell()
         anchor = Anchor('clear',
                         href='delete.attribute||%s.%s' %
                         (attribute, machine))
         if inherited_from is None:
             cell.set(anchor)
         tablerow.append(cell)
         attribute_table.append(tablerow)
     self.body.append(attribute_table)
Beispiel #7
0
 def set_rows(self, rows):
     for row in rows:
         tablerow = TableRow()
         show_anchor = Anchor(row.template,
                              href='show.template.%s' % row.template)
         tablerow.append(TableCell(show_anchor))
         template_data = '%s:%s (%s)' % (row.owner, row.grp_owner, row.mode)
         data_anchor = Anchor(template_data,
                              href='edit.templatedata.%s' % row.template)
         edit_anchor = Anchor('(edit)',
                              href='edit.template.%s' % row.template)
         del_anchor = Anchor('(delete)',
                             href='delete.template.%s' % row.template)
         tablerow.append(TableCell(data_anchor))
         cmdcell = TableCell()
         cmdcell.set(edit_anchor)
         cmdcell.append(del_anchor)
         tablerow.append(cmdcell)
         #tablerow.append(TableCell(edit_anchor))
         #tablerow.append(TableCell(del_anchor))
         self.append(tablerow)
Beispiel #8
0
 def _setup_main_attributes(self):
     machine = self.machine.current_machine
     attribute_table = Table(bgcolor=self._bgcolor_table, border=1)
     headrow = TableRow(bgcolor=self._bgcolor_thead)
     for col in ['Attribute', 'Value', 'Inherited From', 'Command']:
         headrow.append(TableHeader(col))
     attribute_table.append(headrow)
     for attribute in ['kernel', 'profile', 'diskconfig']:
         errormsg = ''
         try:
             value, inherited_from = self.machine.get_attribute(attribute)
         except AttributeUnsetInAncestryError:
             errormsg = "WARNING: not set anywhere"
             value, inherited_from = errormsg, errormsg
         tablerow = TableRow()
         href = 'select.attribute||%s.%s' % (attribute, machine)
         anchor = Anchor(attribute, href=href)
         cell = TableCell(Bold(anchor, ':'))
         tablerow.append(cell)
         cell = TableCell(value)
         tablerow.append(value)
         cell = TableCell()
         if inherited_from is not None:
             if errormsg:
                 anchor = Bold(errormsg)
             else:
                 anchor = Anchor(inherited_from, href='select.machine.%s' % inherited_from)
             cell.append(anchor)
         else:
             cell.append('(set here)')
         tablerow.append(cell)
         cell = TableCell()
         anchor = Anchor('clear', href='delete.attribute||%s.%s' % (attribute, machine))
         if inherited_from is None:
             cell.set(anchor)
         tablerow.append(cell)
         attribute_table.append(tablerow)
     self.body.append(attribute_table)