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)))
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
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)
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)
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')
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')