Пример #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)
Пример #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)
Пример #3
0
 def set_apt_source(self, row):
     self._content = []
     fields = ['apt_id', 'uri', 'dist', 'sections', 'local_path']
     for field in fields:
         fieldrow = TableRow()
         fieldrow.append(TableCell(Bold(field)))
         fieldrow.append(TableCell(row[field]))
         self.append(fieldrow)
Пример #4
0
 def __init__(self, fields, row, **atts):
     Table.__init__(self, **atts)
     for field in fields:
         row = TableRow()
         field_cell = TableCell(field)
         row.append(field_cell)
         value_cell = TableCell(row[field])
         row.append(value_cell)
         self.append(row)
Пример #5
0
    def _set_generic_entity(self, entity):
        db = self.app.db
        # edata = db.get(entityid)
        # main = edata['main']
        # extras = edata['extras']
        # tags = edata['tags']

        # set name and main action links
        name = TableHeader(str(entity.name), colspan=2, align="center")
        name_row = TableRow(name)
        self.set(name_row)
        edit_anchor = Anchor("(edit)", href=myurl.make("edit", "entity", str(entity.entityid)))
        delete_anchor = Anchor("(delete)", href=myurl.make("delete", "entity", str(entity.entityid)))
        cell = TableCell(edit_anchor)
        self.append(TableRow(cell))
        cell = TableCell(delete_anchor)
        self.append(TableRow(cell))

        # set type
        cell = TableCell("type:  %s" % str(entity.type), colspan=2)
        self.append(TableRow(cell))

        # extra fields
        if entity.extfields:
            self.append(TableRow(TableCell(Bold("Extra Fields"))))
            for field in entity.extfields:
                label = str("%s:  %s" % (field, str(entity.extfields[field].value)))
                cell = TableCell(label)
                self.append(TableRow(cell))

        # back to main data
        if entity.url:
            urlanchor = Anchor("url", href=str(entity.url))
            self.append(TableRow(TableCell(urlanchor, colspan=2)))
        if entity.desc:
            self.append(TableRow(TableCell(Bold("Description"), colspan=2)))
            desc = Paragraph(str(entity.desc))
            cell = TableCell(desc)
            self.append(TableRow(cell, colspan=2))

        # handle tags
        tagrow = TableRow()
        tagrow.append(TableCell(Bold("Tags"), colspan=2))
        span = Span(style="font-size: xx-small")
        add_anchor = Anchor("(add)", href=myurl.make("addtag", "entity", str(entity.entityid)))
        del_anchor = Anchor("(remove)", href=myurl.make("deltag", "entity", str(entity.entityid)))
        span.set(add_anchor)
        span.append(del_anchor)
        cell = TableCell(span, colspan=2)
        tagrow.append(cell)
        self.append(tagrow)
        for tag in entity.tags:
            row = TableRow()
            cell = TableCell(str(tag.tagname))
            row.set(cell)
            self.append(row)
Пример #6
0
 def _add_table_header(self, table, fields, **atts):
     if atts:
         print 'Warning, use of atts here is questionable', atts
         print 'in _MachineBaseDocument._add_table_header'
     tablerow = TableRow(**atts)
     table.append(tablerow)
     for field in fields:
         tablerow.append(TableHeader(Bold(field)))
     # we should check if we need the header attribute here
     table.header = tablerow
Пример #7
0
 def _add_table_header(self, table, fields, **atts):
     if atts:
         print 'Warning, use of atts here is questionable', atts
         print 'in _MachineBaseDocument._add_table_header'
     tablerow = TableRow(**atts)
     table.append(tablerow)
     for field in fields:
         tablerow.append(TableHeader(Bold(field)))
     # we should check if we need the header attribute here
     table.header = tablerow
Пример #8
0
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))
Пример #9
0
 def _add_table_row(self, table, fields, row):
     tablerow = TableRow()
     for field in fields:
         tablerow.append(TableCell(str(row[field])))
     durl = 'delete.%s.%s' % (table.context, row[fields[0]])
     eurl = 'edit.%s.%s' % (table.context, row[fields[0]])
     delanchor = Anchor('delete', href=durl)
     editanchor = Anchor('edit', href=eurl)
     cell = TableCell(editanchor)
     cell.append(Break())
     cell.append(delanchor)
     tablerow.append(cell)
     table.append(tablerow)
Пример #10
0
 def _add_table_row(self, table, fields, row):
     tablerow = TableRow()
     for field in fields:
         tablerow.append(TableCell(str(row[field])))
     durl = 'delete.%s.%s' % (table.context, row[fields[0]])
     eurl = 'edit.%s.%s' % (table.context, row[fields[0]])
     delanchor = Anchor('delete', href=durl)
     editanchor = Anchor('edit', href=eurl)
     cell = TableCell(editanchor)
     cell.append(Break())
     cell.append(delanchor)
     tablerow.append(cell)
     table.append(tablerow)
Пример #11
0
 def _add_variables_table_row(self, table, fields, row):
     tablerow = TableRow()
     for field in fields:
         tablerow.append(TableCell(str(row[field])))
     ident = '%s||%s' % (row['trait'], row['name'])
     durl = 'delete.%s.%s' % (table.context, ident)
     eurl = 'edit.%s.%s' % (table.context, ident)
     delanchor = Anchor('delete', href=durl)
     editanchor = Anchor('edit', href=eurl)
     cell = TableCell(editanchor)
     cell.append(Break())
     cell.append(delanchor)
     tablerow.append(cell)
     table.append(tablerow)
Пример #12
0
 def _add_variables_table_row(self, table, fields, row):
     tablerow = TableRow()
     for field in fields:
         tablerow.append(TableCell(str(row[field])))
     ident = '%s||%s' % (row['trait'], row['name'])
     durl = 'delete.%s.%s' % (table.context, ident)
     eurl = 'edit.%s.%s' % (table.context, ident)
     delanchor = Anchor('delete', href=durl)
     editanchor = Anchor('edit', href=eurl)
     cell = TableCell(editanchor)
     cell.append(Break())
     cell.append(delanchor)
     tablerow.append(cell)
     table.append(tablerow)
Пример #13
0
 def refresh_page(self):
     self.clear_body()
     title = SectionTitle('Kernels')
     self.body.append(title)
     kernels = self.kernels.get_kernels()
     table = Table()
     self.body.append(table)
     for kernel in kernels:
         tablerow = TableRow()
         cell = TableCell(kernel)
         tablerow.append(cell)
         del_anchor = Anchor('(delete)', href='delete||kernel||%s' % kernel)
         cell = TableCell(del_anchor)
         tablerow.append(cell)
         table.append(tablerow)
Пример #14
0
 def refresh_page(self):
     self.clear_body()
     title = SectionTitle('Kernels')
     self.body.append(title)
     kernels = self.kernels.get_kernels()
     table = Table()
     self.body.append(table)
     for kernel in kernels:
         tablerow = TableRow()
         cell = TableCell(kernel)
         tablerow.append(cell)
         del_anchor = Anchor('(delete)', href='delete||kernel||%s' % kernel)
         cell = TableCell(del_anchor)
         tablerow.append(cell)
         table.append(tablerow)
Пример #15
0
 def _make_scripts_table(self, trait):
     rows = self.trait._scripts.scripts(trait=trait)
     if rows:
         bgcolor = self.cfg.get('management_gui', 'traitdoc_variables_table_color')
         table = Table(bgcolor=bgcolor)
         for row in rows:
             script  = row.script
             sa = Anchor(script, href='show.script.%s' % script)
             ea = Anchor('(edit)', href='edit.script.%s' % script)
             da = Anchor('(delete)', href='delete.script.%s' % script)
             trow = TableRow()
             trow.append(TableCell(sa))
             trow.append(TableCell(ea))
             trow.append(TableCell(da))
             table.append(trow)
         return table
Пример #16
0
 def __init__(self, fields, idcol, action, record, **args):
     Table.__init__(self, **args)
     self.record = record
     for field in fields:
         row = TableRow()
         row.append(TableCell(Bold(field)))
         val = TableCell()
         data = str(record[field])
         if action:
             href = '%s?%s=%s' % (action, idcol, record[idcol])
             a = Anchor(data, href=href)
             val.append(a)
         else:
             val.append(data)
         row.append(val)
         self.append(row)
Пример #17
0
 def _make_scripts_table(self, trait):
     rows = self.trait._scripts.scripts(trait=trait)
     if rows:
         bgcolor = self.cfg.get('management_gui',
                                'traitdoc_variables_table_color')
         table = Table(bgcolor=bgcolor)
         for row in rows:
             script = row.script
             sa = Anchor(script, href='show.script.%s' % script)
             ea = Anchor('(edit)', href='edit.script.%s' % script)
             da = Anchor('(delete)', href='delete.script.%s' % script)
             trow = TableRow()
             trow.append(TableCell(sa))
             trow.append(TableCell(ea))
             trow.append(TableCell(da))
             table.append(trow)
         return table
Пример #18
0
 def set_options(self, items):
     hrow = TableRow()
     self.set(hrow)
     hrow.append(TableHeader('Option'))
     hrow.append(TableHeader('Value'))
     for k, v in items:
         row = TableRow()
         self.append(row)
         row.append(TableCell(k))
         row.append(TableCell(str(v)))
Пример #19
0
 def set_info(self, works):
     for row in works:
         # the result is from a table join
         # so the row elements are in the form
         # table.column
         title = row['all_works.title']
         url = row['all_works.url']
         wtype = row['all_works.type']
         work_anchor = Anchor(title, href=url)
         cell = TableCell(wtype, colspan=1)
         trow = TableRow(cell)
         cell = TableCell(work_anchor, colspan=3)
         trow.append(cell)
         workid = row['all_works.workid']
         edit_anchor = Anchor('edit',
                              href='work||edit||%d' % workid)
         trow.append(TableCell(edit_anchor, colspan=1))
         self.append(trow)
Пример #20
0
 def __init__(self, fields, idcol, action, record, **args):
     Table.__init__(self, **args)
     self.record = record
     refdata = None
     if hasattr(record, '_refdata'):
         refdata = record._refdata
     for field in fields:
         row = TableRow()
         row.append(TableCell(Bold(field)))
         val = TableCell()
         data = str(record[field])
         if refdata is not None and field in refdata.cols:
             print 'hello there - fix me'
         elif action:
             val.append(Anchor(data, href=action))
         else:
             val.append(data)
         row.append(val)
         self.append(row)
Пример #21
0
 def set_machine(self, machine):
     self.machine.set_machine(machine)
     self.clear_body()
     title = SectionTitle('Machine:  %s' % machine)
     title['bgcolor'] = 'IndianRed'
     title['width'] = '100%'
     self.body.append(title)
     mtable = Table()
     for k, v in self.machine.current.items():
         tablerow = TableRow()
         tablerow.append(TableCell(Bold(k)))
         tablerow.append(TableCell(v))
         mtable.append(tablerow)
     self.body.append(mtable)
     newanchor = Anchor('new', href='new.machine.foo')
     editanchor = Anchor('edit', href='edit.machine.%s' % machine)
     self.body.append(Ruler())
     self.body.append(editanchor)
     self.body.append(Break())
     self.body.append(newanchor)
Пример #22
0
 def set_machine(self, machine):
     self.machine.set_machine(machine)
     self.clear_body()
     title = SectionTitle('Machine:  %s' % machine)
     title['bgcolor'] = 'IndianRed'
     title['width'] = '100%'
     self.body.append(title)
     mtable = Table()
     for k,v in self.machine.current.items():
         tablerow = TableRow()
         tablerow.append(TableCell(Bold(k)))
         tablerow.append(TableCell(v))
         mtable.append(tablerow)
     self.body.append(mtable)
     newanchor = Anchor('new', href='new.machine.foo')
     editanchor = Anchor('edit', href='edit.machine.%s' % machine)
     self.body.append(Ruler())
     self.body.append(editanchor)
     self.body.append(Break())
     self.body.append(newanchor)
Пример #23
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)
Пример #24
0
 def set_suite(self, suite):
     self.suite = suite
     self.cursor.set_suite(suite)
     self.clear_body()
     attributes = dict(bgcolor='IndianRed', width='100%')
     title = SimpleTitleElement('Suite:  %s' % suite, **attributes)
     title.cell.attributes['align'] = 'center'
     self.body.append(title)
     apt_rows = self.cursor.get_apt_rows()
     if len(apt_rows):
         aptsrc_table = Table(bgcolor='khaki')
         self.body.append(aptsrc_table)
         fields = ['apt_id', 'uri', 'dist', 'sections', 'local_path']
         headrow = TableRow()
         for field in fields:
             headrow.append(TableCell(Bold(field)))
         for row in apt_rows:
             tblrow = TableRow()
             aptsrc_table.append(tblrow)
             for field in fields:
                 tblrow.append(TableCell(row[field]))
Пример #25
0
 def set_suite(self, suite):
     self.suite = suite
     self.cursor.set_suite(suite)
     self.clear_body()
     attributes = dict(bgcolor='IndianRed', width='100%')
     title = SimpleTitleElement('Suite:  %s' % suite, **attributes)
     title.cell.attributes['align'] = 'center'
     self.body.append(title)
     apt_rows = self.cursor.get_apt_rows()
     if len(apt_rows):
         aptsrc_table = Table(bgcolor='khaki')
         self.body.append(aptsrc_table)
         fields = ['apt_id', 'uri', 'dist', 'sections', 'local_path']
         headrow = TableRow()
         for field in fields:
             headrow.append(TableCell(Bold(field)))
         for row in apt_rows:
             tblrow = TableRow()
             aptsrc_table.append(tblrow)
             for field in fields:
                 tblrow.append(TableCell(row[field]))
Пример #26
0
    def _add_script_table_row(self, table, scriptname, parent):
        tablerow = TableRow()
        # scriptname cell
        scriptname_cell = TableCell(scriptname)

        # command cell (we use
        # an empty cell as default)
        command_cell = TableCell()

        # parent cell
        if parent is None:
            parent = '(defined here)'
            # if script is defined here, instead of inherited
            # we make the command anchors.
            durl = 'delete.%s.%s' % (table.context, scriptname)
            eurl = 'edit.%s.%s' % (table.context, scriptname)
            delanchor = Anchor('delete', href=durl)
            editanchor = Anchor('edit', href=eurl)
            command_cell = TableCell(editanchor)
            command_cell.append(Break())
            command_cell.append(delanchor)
        parent_cell = TableCell(parent)

        # append the cells to the rows
        tablerow.append(scriptname_cell)
        tablerow.append(parent_cell)
        tablerow.append(command_cell)
        table.append(tablerow)
Пример #27
0
    def _add_script_table_row(self, table, scriptname, parent):
        tablerow = TableRow()
        # scriptname cell
        scriptname_cell = TableCell(scriptname)
        
        # command cell (we use
        # an empty cell as default)
        command_cell = TableCell()

        # parent cell
        if parent is None:
            parent = '(defined here)'
            # if script is defined here, instead of inherited
            # we make the command anchors.
            durl = 'delete.%s.%s' % (table.context, scriptname)
            eurl = 'edit.%s.%s' % (table.context, scriptname)
            delanchor = Anchor('delete', href=durl)
            editanchor = Anchor('edit', href=eurl)
            command_cell = TableCell(editanchor)
            command_cell.append(Break())
            command_cell.append(delanchor)
        parent_cell = TableCell(parent)

        # append the cells to the rows
        tablerow.append(scriptname_cell)
        tablerow.append(parent_cell)
        tablerow.append(command_cell)
        table.append(tablerow)
Пример #28
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)
Пример #29
0
 def __init__(self, rows, **atts):
     Table.__init__(self, **atts)
     headrow = TableRow()
     headrow.append(TableCell(Bold('Trait')))
     headrow.append(TableCell(Bold('Order')))
     self.set(headrow)
     for row in rows:
         tablerow = TableRow()
         tablerow.append(TableCell(row.trait))
         tablerow.append(TableCell(str(row.ord)))
         self.append(tablerow)
Пример #30
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)
Пример #31
0
 def __init__(self, rows, **atts):
     Table.__init__(self, **atts)
     packages = []
     package_actions = {}
     for row in rows:
         if row.package not in packages:
             packages.append(row.package)
             package_actions[row.package] = [row.action]
         else:
             package_actions[row.package].append(row.action)
     for package in packages:
         tablerow = TableRow()
         tablerow.append(TableCell(package))
         tablerow.append(TableCell(', '.join(package_actions[package])))
         anchor = Anchor('delete', href='delete.package.%s' % package)
         tablerow.append(anchor)
         self.append(tablerow)
Пример #32
0
 def __init__(self, rows, **atts):
     Table.__init__(self, **atts)
     packages = []
     package_actions = {}
     for row in rows:
         if row.package not in packages:
             packages.append(row.package)
             package_actions[row.package] = [row.action]
         else:
             package_actions[row.package].append(row.action)
     for package in packages:
         tablerow = TableRow()
         tablerow.append(TableCell(package))
         tablerow.append(TableCell(', '.join(package_actions[package])))
         anchor = Anchor('delete', href='delete.package.%s' % package)
         tablerow.append(anchor)
         self.append(tablerow)
Пример #33
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)
Пример #34
0
 def _setup_parent_table(self):
     machine = self.machine.current_machine
     parent_table = Table(bgcolor=self._bgcolor_table, border=1)
     parent = self.machine.parent
     if parent is None:
         parent = '(No Parent Set)'
     headrow = TableRow(bgcolor=self._bgcolor_thead)
     for col in ['parent', 'command']:
         headrow.append(TableHeader(col))
     parent_table.append(headrow)
     mainrow = TableRow()
     parent_cell = TableCell(parent)
     mainrow.append(parent_cell)
     select_anchor = Anchor('select', href='select.parent.%s' % machine)
     delete_anchor = Anchor('delete', href='delete.parent.%s' % machine)
     command_cell = TableCell()
     command_cell.append(select_anchor)
     if self.machine.parent is not None:
         #command_cell.append(Break())
         command_cell.append('|=====|')
         command_cell.append(delete_anchor)
     mainrow.append(command_cell)
     parent_table.append(mainrow)
     self.body.append(parent_table)
Пример #35
0
 def _setup_parent_table(self):
     machine = self.machine.current_machine
     parent_table = Table(bgcolor=self._bgcolor_table, border=1)
     parent = self.machine.parent
     if parent is None:
         parent = '(No Parent Set)'
     headrow = TableRow(bgcolor=self._bgcolor_thead)
     for col in ['parent', 'command']:
         headrow.append(TableHeader(col))
     parent_table.append(headrow)
     mainrow = TableRow()
     parent_cell = TableCell(parent)
     mainrow.append(parent_cell)
     select_anchor = Anchor('select', href='select.parent.%s' % machine)
     delete_anchor = Anchor('delete', href='delete.parent.%s' % machine)
     command_cell = TableCell()
     command_cell.append(select_anchor)
     if self.machine.parent is not None:
         #command_cell.append(Break())
         command_cell.append('|=====|')
         command_cell.append(delete_anchor)
     mainrow.append(command_cell)
     parent_table.append(mainrow)
     self.body.append(parent_table)
Пример #36
0
 def _add_table_row(self, table, fields, row):
     tablerow = TableRow()
     for field in fields:
         tablerow.append(TableCell(str(row[field])))
     table.append(tablerow)
Пример #37
0
 def __init__(self, rows, **atts):
     Table.__init__(self, **atts)
     headrow = TableRow(bgcolor='MistyRose3')
     headrow.append(TableHeader('Trait'))
     headrow.append(TableHeader('Name'))
     headrow.append(TableHeader('Value'))
     self.set(headrow)
     for row in rows:
         tablerow = TableRow()
         tablerow.append(TableCell(row.trait))
         tablerow.append(TableCell(row.name))
         tablerow.append(TableCell(row.value))
         self.append(tablerow)
Пример #38
0
 def _add_table_row(self, table, fields, row):
     tablerow = TableRow()
     for field in fields:
         tablerow.append(TableCell(str(row[field])))
     table.append(tablerow)
Пример #39
0
    def set_info(self, guestid):
        guests_db = self.app.guests
        data = guests_db.get_guest_data(guestid)
        name = '%s %s' % (data['firstname'], data['lastname'])
        fullname = TableHeader(name, colspan=0, align='center')
        fullname_row = TableRow(fullname)
        edit_anchor = Anchor('edit',
                             href='guest||edit||%d' % guestid)
        cell = TableCell(edit_anchor)
        fullname_row.append(cell)
        self.maintable.set(fullname_row)
        title = data['title']
        if title:
            title = TableCell(title, colspan=2)
            title_row = TableRow(title)
            self.maintable.append(title_row)
        desc = data['description']
        if desc:
            desc = self.app.guests.unescape_text(desc)
            desc = TableCell(desc, colspan=2)
            desc_row = TableRow(desc)
            self.maintable.append(desc_row)
        #################
        # works section #
        #################
        workheader = TableHeader('Works', colspan=0, align='center')
        new_work_anchor = Anchor('add',
                                 href='work||new||%d' % guestid)
        cell = TableCell(new_work_anchor)
        workheader_row = TableRow(workheader)
        workheader_row.append(cell)
        self.maintable.append(workheader_row)
        # add works
        works = guests_db.get_guest_works(guestid)
        if works:
            worktable = Table(border=1)
            for row in works:
                # the result is from a table join
                # so the row elements are in the form
                # table.column
                title = row['all_works.title']
                url = row['all_works.url']
                wtype = row['all_works.type']
                work_anchor = Anchor(title, href=url)
                cell = TableCell(wtype, colspan=1)
                trow = TableRow(cell)
                cell = TableCell(work_anchor, colspan=3)
                trow.append(cell)
                workid = row['all_works.workid']
                edit_anchor = Anchor('edit',
                                     href='work||edit||%d' % workid)
                trow.append(TableCell(edit_anchor, colspan=1))
                worktable.append(trow)
                cell = TableCell(worktable, colspan=2)
                trow = TableRow(cell)
            self.maintable.append(trow)
        else:
            workheader.set('No Works')
        #######################
        # appearances section #
        #######################
        appearance_header = TableHeader('Appearances',
                                        colspan=0, align='center')
        new_appearance_anchor = Anchor('add',
                                       href='appearance||new||%d' % guestid)

        cell = TableCell(new_appearance_anchor)
        appearance_header_row = TableRow(appearance_header)
        appearance_header_row.append(cell)
        self.maintable.append(appearance_header_row)
        appearances = guests_db.get_appearances(guestid)
        if appearances:
            for row in appearances:
                #print row
                url = row['url']
                sdate = parse_appearance_m3u_url(url)
                app_anchor = Anchor(sdate, href=url)
                cell = TableCell(app_anchor)
                trow = TableRow(cell)
                edit_anchor = Anchor('edit',
                                     href='appearance||edit||%s' % url)
                trow.append(TableCell(edit_anchor))
                self.maintable.append(trow)
        else:
            appearance_header.set('No Appearances')
        
        #######################
        # pictures section    #
        #######################
        pix_header = TableHeader('Pictures',
                                 colspan=0, align='center')
        newpix_anchor = Anchor('add',
                               href='picture||new||%d' % guestid)
        cell = TableCell(newpix_anchor)
        pix_header_row = TableRow(pix_header)
        pix_header_row.append(cell)
        self.maintable.append(pix_header_row)
        pictures = guests_db.get_guest_pictures(guestid)
        if pictures:
            datadir = self.app.datadir
            for row in pictures:
                filename = row['all_pictures.filename']
                fullpath = os.path.join(datadir, filename)
                image = Image(src=fullpath, width='100', height='100')
                print image
                cell = TableCell(image)
                trow = TableRow(cell)
                cell = TableCell(filename)
                trow.append(cell)
                self.maintable.append(trow)
        else:
            pix_header.set('No Pictures')
Пример #40
0
    def set_info(self, guestid):
        guests_db = self.app.guests
        data = guests_db.get_guest_data(guestid)
        name = '%s %s' % (data['firstname'], data['lastname'])
        fullname = TableHeader(name, colspan=0, align='center')
        fullname_row = TableRow(fullname)
        edit_anchor = Anchor('edit',
                             href='guest||edit||%d' % guestid)
        cell = TableCell(edit_anchor)
        fullname_row.append(cell)
        self.set(fullname_row)
        title = data['title']
        if title:
            title = TableCell(title, colspan=2)
            title_row = TableRow(title)
            self.append(title_row)
        desc = data['description']
        if desc:
            desc = self.app.guests.unescape_text(desc)
            span = Span(desc)
            cell = TableCell(span, colspan=2)
            if len(desc) > 150:
                span['style'] = 'font-size: x-small'
            desc_row = TableRow(cell)
            self.append(desc_row)

        #################
        # works section #
        #################
        workheader = TableHeader('Works', colspan=0, align='center')
        new_work_anchor = Anchor('add',
                                 href='work||new||%d' % guestid)
        cell = TableCell(new_work_anchor)
        workheader_row = TableRow(workheader)
        workheader_row.append(cell)
        self.append(workheader_row)
        # add works
        works = guests_db.get_guest_works(guestid)
        if works:
            worktable = GuestWorksTable(width='100%')
            worktable.set_info(works)
            cell = TableCell(worktable, colspan=2)
            trow = TableRow(cell)
            self.append(trow)
        else:
            workheader.set('No Works')

        #######################
        # appearances section #
        #######################
        appearance_header = TableHeader('Appearances',
                                        colspan=0, align='center')
        new_appearance_anchor = Anchor('add',
                                       href='appearance||new||%d' % guestid)

        cell = TableCell(new_appearance_anchor)
        appearance_header_row = TableRow(appearance_header)
        appearance_header_row.append(cell)
        self.append(appearance_header_row)
        appearances = guests_db.get_appearances(guestid)
        if appearances:
            for row in appearances:
                #print row
                url = row['url']
                sdate = parse_appearance_m3u_url(url)
                app_anchor = Anchor(sdate, href=url)
                cell = TableCell(app_anchor)
                h1, h2 = make_mp3_links(url)
                h1_anchor = Anchor('(hr1)', href=h1)
                h2_anchor = Anchor('(hr2)', href=h2)
                span = Span(style='font-size: xx-small')
                span.append(h1_anchor)
                span.append(h2_anchor)
                cell.append(span)
                trow = TableRow(cell)
                cell = TableCell()
                edit_anchor = Anchor('edit',
                                     href='appearance||edit||%s' % url)
                play_anchor = Anchor('(play)',
                                     href='appearance||play||%s' % url)
                cell.append(edit_anchor)
                cell.append(play_anchor)
                trow.append(cell)
                self.append(trow)
        else:
            appearance_header.set('No Appearances')
        
        #######################
        # pictures section    #
        #######################
        pix_header = TableHeader('Pictures',
                                 colspan=0, align='center')
        newpix_anchor = Anchor('add',
                               href='picture||new||%d' % guestid)
        cell = TableCell(newpix_anchor)
        pix_header_row = TableRow(pix_header)
        pix_header_row.append(cell)
        self.append(pix_header_row)
        pictures = guests_db.get_guest_pictures(guestid)
        if pictures:
            datadir = self.app.datadir
            for row in pictures:
                filename = row['all_pictures.filename']
                fullpath = os.path.join(datadir, filename)
                image = Image(src=fullpath, width='100', height='100')
                cell = TableCell(image)
                trow = TableRow(cell)
                span = Span(style='font-size: xx-small')
                span.append(filename)
                cell = TableCell(span)
                trow.append(cell)
                self.append(trow)
        else:
            pix_header.set('No Pictures')