def create_layout(self): form = self.form self.add(tbody(tagid('tbody'))) if form.non_field_errors(): self.tbody.add(tr(td(attr(colspan=self.columns_count), _('Errors:'), form.non_field_errors()))) hidden_fields = [] for field in form.fields.values(): if field.is_hidden: hidden_fields.append(field) continue label_str = self.get_label_name(field) if field.required: cell_tag = th else: cell_tag = td errors = form.errors.get(field.name_orig, None) self.tbody.add(tr( cell_tag(label(label_str)), td(errors, field))) self.add(hidden_fields) if not form.is_nested: self.tbody.add(self.get_submit_row())
def _render_keyset(self, keyset_detail): registrar_detail = keyset_detail.fields.get("registrar").current_field.inner_detail # registrar of keyset handle_field = keyset_detail.fields["handle_url"] registrar_field = registrar_detail.fields["handle_url"] admins_field = keyset_detail.fields["admins"] dsrecords_field = keyset_detail.fields["dsrecords"] dnskeys_field = keyset_detail.fields["dnskeys"] handle_label = self.get_label_name(handle_field) registrar_label = self.get_label_name(_("Registrar")) admins_label = self.get_label_name(_("Tech. contacts")) dsrecords_label = self.get_label_name(_("DS records")) dnskeys_label = self.get_label_name(_("DNSKeys")) self.add(tr(td(attr(cssc="left_label"), handle_label), td(handle_field))) self.add(tr(td(attr(cssc="left_label"), registrar_label), td(registrar_field))) for i, admin_detail in enumerate(admins_field.current_field.inner_details): row = tr() if i == 0: row.add( td(attr(cssc="left_label", rowspan=len(admins_field.current_field.inner_details)), admins_label) ) email_part = "" if admin_detail.fields["email"].value: email_part = [", ", admin_detail.fields["email"]] row.add(td(attr(enclose_content=True), admin_detail.fields["handle_url"], email_part)) self.add(row) for i, dsrecord_detail in enumerate(dsrecords_field.current_field.inner_details): row = tr() if i == 0: row.add( td( attr(cssc="left_label", rowspan=len(dsrecords_field.current_field.inner_details)), dsrecords_label, ) ) cell = td(attr(enclose_content=True)) cell.add(dsrecord_detail.fields["keyTag"]) cell.add(dsrecord_detail.fields["digest"], " (", dsrecord_detail.fields["digestType"], ")") row.add(cell) self.add(row) for i, dnskey_detail in enumerate(dnskeys_field.current_field.inner_details): row = tr() if i == 0: row.add( td(attr(cssc="left_label", rowspan=len(dnskeys_field.current_field.inner_details)), dnskeys_label) ) cell = td(attr(enclose_content=True)) cell.add(dnskey_detail.fields["key"]) row.add(cell) self.add(row)
def make_content(self): self.content = [] self.create_inner_details() if self.inner_details: # Header: thead_row = tr() for field in self.inner_details[0].fields.values(): thead_row.add(th(field.label)) thead_row.add(th(_('From')), th(_('To')), th(_('L.'))) self.add(thead(thead_row)) # rows (each row is made from one detail of object in object list self.add(tbody(tagid('tbody'))) for i, detail in enumerate(self.inner_details): history_rec = self.value[i] date_from = history_rec._from #recoder.corba_to_datetime(history_rec._from) date_to = history_rec.to #recoder.corba_to_datetime(history_rec.to) logger_url = f_urls['logger'] + 'detail/?id=%s' % history_rec.requestId history_tr = tr() if i > 0: history_tr.cssc = 'history_row' log_req_link = a(attr(href=logger_url), img(attr(src='/img/icons/open.png'))) if history_rec.requestId else '' history_tr.add( detail, td(attr(cssc='history_dates_field'), date_from), td(attr(cssc='history_dates_field'), date_to), td(attr(cssc='history_dates_field'), log_req_link) ) self.add(history_tr) else: self.add(div(attr(cssc='field_empty')))
def create_layout(self): form = self.form self.add(tbody(tagid('tbody'))) # Following block creates self.all_fields, self.errors and # non_field_errors from fields and their forms (if they are # compound fields) recursively (obtaining linear structure # from tree structure). non_field_errors = [] # [names, labels, form or field], it is stack (depth-first-search) open_nodes = [[[], [], self.form]] while open_nodes: names, labels, tmp_node = open_nodes.pop() # Add errors from this tmp_node - for fields using composed name # and join all non_field_errors together. if isinstance(tmp_node, filterforms.FilterForm): if tmp_node.is_bound: non_field_errors.extend(tmp_node.non_field_errors()) for error_name, error in tmp_node.errors.items(): if error_name == forms.NON_FIELD_ERRORS: continue self.all_errors['-'.join(names + [error_name])] = error # 'reversed': compensation for the reverse order onstack for field in reversed(tmp_node.fields.values()): if not isinstance(field, CompoundFilterField): open_nodes.append([names, labels, field]) else: open_nodes.append([ names + [field.name], labels + [field.label], field.form ]) else: filter_name = tmp_node.name composed_name = '-'.join(names + [filter_name]) tmp_node.label = '.'.join(labels + [tmp_node.label]) self.all_fields.append([composed_name, tmp_node]) if non_field_errors: self.tbody.add( tr( td(attr(colspan=self.columns_count), 'Errors:', form.non_field_errors()))) self.tbody.add( tr(attr(cssc='filtertable_header'), th(attr(colspan='2'), self.form._get_header_title()), th(div(attr(cssc='for_fields_button extjs'))))) for composed_name, field in self.all_fields: errors = self.all_errors.get(composed_name, None) self.tbody.add( tr(attr(cssc='field_row ' + composed_name), self.build_field_row(field, errors))) self.add( script(attr(type='text/javascript'), 'filterObjectName = "%s"' % self.form.get_object_name())) # global javascript variable self.tbody.add(self.build_fields_button())
def make_content(self): self.content = [] self.create_inner_details() if self.inner_details: # Header: thead_row = tr() for field in self.inner_details[0].fields.values(): thead_row.add(th(field.label)) thead_row.add(th(_('From')), th(_('To')), th(_('L.'))) self.add(thead(thead_row)) # rows (each row is made from one detail of object in object list self.add(tbody(tagid('tbody'))) for i, detail in enumerate(self.inner_details): history_rec = self.value[i] date_from = history_rec._from #recoder.corba_to_datetime(history_rec._from) date_to = history_rec.to #recoder.corba_to_datetime(history_rec.to) logger_url = f_urls[ 'logger'] + 'detail/?id=%s' % history_rec.requestId history_tr = tr() if i > 0: history_tr.cssc = 'history_row' log_req_link = a(attr( href=logger_url), img(attr(src='/img/icons/open.png')) ) if history_rec.requestId else '' history_tr.add( detail, td(attr(cssc='history_dates_field'), date_from), td(attr(cssc='history_dates_field'), date_to), td(attr(cssc='history_dates_field'), log_req_link)) self.add(history_tr) else: self.add(div(attr(cssc='field_empty')))
def make_content(self): state_table = self.compute_state_data() if self.owner_detail.history and len( state_table ): # dont display history if state_table have no row self.content = [] display_state_list = self.state_list[1:] self.tag = 'table' self.tattr_list = table.tattr_list self.cssc = 'state_table section_table' # header self.add( tr(th(_('Date')), [ th( attr(cssc='state_header_cell', title=self.transform_title( _('Status'), self.get_state_title(state_id))), self.states_abbrev[state_id]) for state_id in display_state_list ])) if state_table: # date rows for row in state_table: tr_row = tr( th( attr(cssc='date_cell', title=self.transform_title( _('Statuses'), self.get_states_title_for_row(row))), row['row_date'])) for state_id in display_state_list: state_on = row[state_id] if state_on == True: tr_row.add( td( attr(cssc='state_on', title=self.transform_title( _('Status'), self.get_state_title(state_id))), 'X')) else: tr_row.add( td( attr(title=self.transform_title( _('Status'), self.get_state_title(state_id))))) self.add(tr_row) else: self.tag = 'table' self.tattr_list = table.tattr_list self.cssc = 'section_table' if len(state_table): self.add( tr(td(noesc(self.get_states_title_for_row( state_table[0]))))) else: self.add(tr(td(self.get_state_title(0))))
def create_layout(self): form = self.form self.add(tbody(tagid('tbody'))) # Following block creates self.all_fields, self.errors and # non_field_errors from fields and their forms (if they are # compound fields) recursively (obtaining linear structure # from tree structure). non_field_errors = [] # [names, labels, form or field], it is stack (depth-first-search) open_nodes = [[[], [], self.form]] while open_nodes: names, labels, tmp_node = open_nodes.pop() # Add errors from this tmp_node - for fields using composed name # and join all non_field_errors together. if isinstance(tmp_node, filterforms.FilterForm): if tmp_node.is_bound: non_field_errors.extend(tmp_node.non_field_errors()) for error_name, error in tmp_node.errors.items(): if error_name == forms.NON_FIELD_ERRORS: continue self.all_errors['-'.join(names + [error_name])] = error # 'reversed': compensation for the reverse order onstack for field in reversed(tmp_node.fields.values()): if not isinstance(field, CompoundFilterField): open_nodes.append([names, labels, field]) else: open_nodes.append([ names + [field.name], labels + [field.label], field.form]) else: filter_name = tmp_node.name composed_name = '-'.join(names + [filter_name]) tmp_node.label = '.'.join(labels + [tmp_node.label]) self.all_fields.append([composed_name, tmp_node]) if non_field_errors: self.tbody.add(tr(td( attr(colspan=self.columns_count), 'Errors:', form.non_field_errors()))) self.tbody.add(tr( attr(cssc='filtertable_header'), th(attr(colspan='2'), self.form._get_header_title()), th(div(attr(cssc='for_fields_button extjs'))))) for composed_name, field in self.all_fields: errors = self.all_errors.get(composed_name, None) self.tbody.add(tr( attr(cssc='field_row ' + composed_name), self.build_field_row(field, errors))) self.add(script( attr(type='text/javascript'), 'filterObjectName = "%s"' % self.form.get_object_name())) # global javascript variable self.tbody.add(self.build_fields_button())
def _render_nsset(self, nsset_detail): registrar_detail = nsset_detail.fields[ 'registrar'].current_field.inner_detail # registrar of nsset handle_field = nsset_detail.fields['handle_url'] registrar_field = registrar_detail.fields['handle_url'] admins_field = nsset_detail.fields['admins'] hosts_field = nsset_detail.fields['hosts'] handle_label = self.get_label_name(handle_field) registrar_label = self.get_label_name(_('Registrar')) admins_label = self.get_label_name(_('Tech. contacts')) hosts_label = self.get_label_name(_('DNSs')) self.add( tr(td(attr(cssc='left_label'), handle_label), td(handle_field))) self.add( tr(td(attr(cssc='left_label'), registrar_label), td(registrar_field))) for i, admin_detail in enumerate( admins_field.current_field.inner_details): row = tr() if i == 0: row.add( td( attr(cssc='left_label', rowspan=len( admins_field.current_field.inner_details)), admins_label)) email_part = '' if admin_detail.fields['email'].value: email_part = [', ', admin_detail.fields['email']] row.add( td(attr(enclose_content=True), admin_detail.fields['handle_url'], email_part)) self.add(row) for i, host_detail in enumerate( hosts_field.current_field.inner_details): row = tr() if i == 0: row.add( td( attr(cssc='left_label', rowspan=len( hosts_field.current_field.inner_details)), hosts_label)) cell = td(attr(enclose_content=True)) cell.add(host_detail.fields['fqdn']) if host_detail.fields['inet'].value: cell.add(' (', host_detail.fields['inet'], ')') row.add(cell) self.add(row)
def create_layout(self): self.add(tbody(tagid('tbody'))) form_count = len(self.form.forms) for i, inner_form in enumerate(self.form.forms): if i > 0 and i < form_count: self.tbody.add(tr(attr(cssc='or_row'), self.build_or_row())) self.tbody.add(tr(td(inner_form))) self.tbody.add(self.get_submit_row()) self.tbody.add(script(attr(type='text/javascript'), noesc(self.union_form_js()))) debug('After create unionlayout')
def __init__(self, context): super(ContactCheckDetail, self).__init__(context) c = self.context self.head.add( script(attr(type='text/javascript'), 'ajaxSourceURLOfChecks = "%s";' % c.ajax_json_filter_url, 'dontDisplayFilter = true;')) self.main.add(h1(_('Contact checks detail'), '-', c.test_suit_name)) if c.contact_detail is None: self.main.add(h2(_('Contact was deleted'))) verified_info = None else: if contact_has_state(c.contact_detail, 'validatedContact'): verified_info = _('Contact is validated') elif contact_has_state(c.contact_detail, 'identifiedContact'): verified_info = _('Contact is identified') else: verified_info = None self.main.add( table( attr(cssc='section_table'), tr( td(attr(cssc='left_label'), _('Contact:'), td(a(attr(href=c.contact_url), c.check.contact_handle)))), tr( td(attr(cssc='left_label'), _('Created: '), td(c.check.created))), tr( td(attr(cssc='left_label'), _('Verified status:'), td(strong(attr(cssc='highlight_ok'), verified_info)))) if verified_info else None)) self.main.add(c.detail) if c.contact_detail: self.main.add(h2('Detail of contact:')) self.main.add( adifdetails.ContactDetail(c.contact_detail, c.history, is_nested=True)) if cherrypy.session.get('history', False): self.main.add(h2(_('All checks of this contact:'))) self.main.add(c.table_tag) self.main.add(h2(_('Contact checks messages:'))) self.main.add(c.messages_list) lang_code = config.lang[:2] self.head.add( script( attr(type='text/javascript'), 'scwLanguage = "%s"; //sets language of js_calendar' % lang_code, 'scwDateOutputFormat = "%s"; // set output format for js_calendar' % config.js_calendar_date_format))
def _render_keyset(self, keyset_detail): registrar_detail = keyset_detail.fields.get('registrar').current_field.inner_detail # registrar of keyset handle_field = keyset_detail.fields['handle_url'] registrar_field = registrar_detail.fields['handle_url'] admins_field = keyset_detail.fields['admins'] dsrecords_field = keyset_detail.fields['dsrecords'] dnskeys_field = keyset_detail.fields['dnskeys'] handle_label = self.get_label_name(handle_field) registrar_label = self.get_label_name(_('Registrar')) admins_label = self.get_label_name(_('Tech. contacts')) dsrecords_label = self.get_label_name(_('DS records')) dnskeys_label = self.get_label_name(_('DNSKeys')) self.add(tr(td(attr(cssc='left_label'), handle_label), td(handle_field))) self.add(tr(td(attr(cssc='left_label'), registrar_label), td(registrar_field))) for i, admin_detail in enumerate(admins_field.current_field.inner_details): row = tr() if i == 0: row.add(td(attr(cssc='left_label', rowspan=len(admins_field.current_field.inner_details)), admins_label)) email_part = '' if admin_detail.fields['email'].value: email_part = [', ' , admin_detail.fields['email']] row.add(td(attr(enclose_content=True), admin_detail.fields['handle_url'], email_part)) self.add(row) for i, dsrecord_detail in enumerate(dsrecords_field.current_field.inner_details): row = tr() if i == 0: row.add(td(attr(cssc='left_label', rowspan=len(dsrecords_field.current_field.inner_details)), dsrecords_label)) cell = td(attr(enclose_content=True)) cell.add(dsrecord_detail.fields['keyTag']) cell.add(dsrecord_detail.fields['digest'], ' (', dsrecord_detail.fields['digestType'],')') row.add(cell) self.add(row) for i, dnskey_detail in enumerate(dnskeys_field.current_field.inner_details): row = tr() if i == 0: row.add(td(attr(cssc='left_label', rowspan=len(dnskeys_field.current_field.inner_details)), dnskeys_label)) cell = td(attr(enclose_content=True)) cell.add(dnskey_detail.fields['key']) row.add(cell) self.add(row)
def create_layout(self): self.add(tbody(tagid('tbody'))) form_count = len(self.form.forms) for i, inner_form in enumerate(self.form.forms): if i > 0 and i < form_count: self.tbody.add(tr(attr(cssc='or_row'), self.build_or_row())) self.tbody.add(tr(td(inner_form))) self.tbody.add(self.get_submit_row()) self.tbody.add( script(attr(type='text/javascript'), noesc(self.union_form_js()))) debug('After create unionlayout')
def layout_fields(self): fields_in_section = self.get_fields() for field in fields_in_section: errors = self.form.errors.get(field.name_orig, None) label_str = self.get_label_name(field) self.table.add(tr( td(errors, field)))
def _format_property(self, prop): val = prop["value"] neg = "(neg)" if prop["neg"] else "" indent_style = "padding-left: 2em;" if prop["child"] else "" res = tr(td("%s %s:" % (neg, prop["name"]), attr(style=indent_style)), td("%s" % val)) return res
def make_content(self): self.content = [] self.inner_field.owner_detail = self.owner_detail if self.value: for i, history_rec in enumerate(self.value): val = from_any(history_rec.value, True) inner_field_copy = copy(self.inner_field) inner_field_copy.value = val date_from = history_rec._from #recoder.corba_to_datetime(history_rec._from) date_to = history_rec.to #recoder.corba_to_datetime(history_rec.to) logger_url = f_urls[ 'logger'] + 'detail/?id=%s' % history_rec.requestId history_tr = tr() if i > 0: history_tr.cssc = 'history_row' log_req_link = a(attr( href=logger_url), img(attr(src='/img/icons/open.png')) ) if history_rec.requestId else '' history_tr.add( td(inner_field_copy), td(attr(cssc='history_dates_field'), _('from'), date_from), td(attr(cssc='history_dates_field'), date_to and _('to') or '', date_to), td(attr(cssc='history_dates_field'), log_req_link)) self.add(history_tr) else: self.add(div(attr(cssc='field_empty')))
def layout_fields(self): section_name = self.section_spec[0] section_id = self.section_spec[1] link_id = "%s_display" % section_id self.add(div( attr(style="text-align: right; padding-right: 1em;"), a( "hide", attr(href="JavaScript:void();"), onclick="show_hide('%s', '%s');" % (section_id, link_id), id=link_id))) self.add(table(tagid("table"), id=section_id)) self.add(legend(section_name)) fields_in_section = self.get_fields() hidden_fields = [] for field in fields_in_section: if field.is_hidden: hidden_fields.append(field) continue label_str = self.get_label_name(field) errors = self.form.errors.get(field.name_orig, None) self.table.add(tr( td(label_str), td(errors, field))) self.add(hidden_fields)
def layout_fields(self): fields_in_section = self.get_fields() for field in fields_in_section: label_str = self.get_label_name(field) self.tbody.add( tr(td(attr(cssc='left_label'), label_str), td(field)))
def render(self, indent_level=0): if self.header: self.add(thead(tr([th(item) for item in self.header]))) if self.data: rows = [] for row_num, data_row in enumerate(self.data): row = tr(attr(cssc='row%s' % ((row_num % 2) + 1))) for col in data_row: row.add(td(col)) rows.append(row) self.add(tbody(rows)) if self.footer: self.add(tfoot([th(item) for item in self.footer])) return super(SimpleTable, self).render(indent_level)
def get_submit_row(self, hidden_fields=None): or_plus_button = input( attr(type="button", value="OR+", onclick="addOrForm(this)", style="float: left;")) save_input = input( attr(id='save_input', type="text", name="save_input", value=_('name'), disabled='disabled', style="float: left; margin-left: 0.4em; display:none;")) save_button = input( attr(type="button", value="Save", onclick="saveUnionForm(this)", style="float: left; margin-left: 0.4em")) submit_button = input( attr(type=u'button', value=u'OK', onclick='sendUnionForm(this)', style="float: right;")) return tr( attr(cssc='submit_row'), td(or_plus_button, save_input, save_button, hidden_fields, submit_button), )
def make_content(self): self.content = [] self.inner_field.owner_detail = self.owner_detail if self.value: for i, history_rec in enumerate(self.value): val = from_any(history_rec.value, True) inner_field_copy = copy(self.inner_field) inner_field_copy.value = val date_from = history_rec._from #recoder.corba_to_datetime(history_rec._from) date_to = history_rec.to #recoder.corba_to_datetime(history_rec.to) logger_url = f_urls['logger'] + 'detail/?id=%s' % history_rec.requestId history_tr = tr() if i > 0: history_tr.cssc = 'history_row' log_req_link = a(attr(href=logger_url), img(attr(src='/img/icons/open.png'))) if history_rec.requestId else '' history_tr.add( td(inner_field_copy), td(attr(cssc='history_dates_field'), _('from'), date_from), td(attr(cssc='history_dates_field'), date_to and _('to') or '', date_to), td(attr(cssc='history_dates_field'), log_req_link) ) self.add(history_tr) else: self.add(div(attr(cssc='field_empty')))
def make_content(self): def _add_row(i, j, detail): history_tr = tr() history_tr.cssc = '' if i > 0: history_tr.cssc += ' history_row' if detail: history_tr.add(detail) else: history_tr.add( td(attr(colspan=len(thead_row.content) - 3), div(attr(cssc='field_empty')))) if j == 0: history_tr.cssc += ' history_division_row' rowspan_attr = attr(rowspan=len(self.inner_details[i]) or 1, cssc='history_dates_field') log_req_link = a(attr( href=logger_url), img(src='/img/icons/open.png') ) if history_rec.requestId else '' history_tr.add(td(rowspan_attr, date_from), td(rowspan_attr, date_to), td(rowspan_attr, log_req_link)) self.add(history_tr) self.content = [] self.create_inner_details() if self.inner_details: # Header: thead_row = tr() # Find one (any of them) innter detail for obtaining field labels (cannot take first one, becouse firt can be empty list): some_detail = None for details in self.inner_details: if details: some_detail = details[0] break for field in some_detail.fields.values(): thead_row.add(th(field.label)) thead_row.add(th(_('From')), th(_('To')), th(_('L.'))) self.add(thead(thead_row)) # rows (each row is made from one detail of object in object list self.add(tbody(tagid('tbody'))) for i in range(len(self.inner_details)): history_rec = self.value[i] date_from = history_rec._from #recoder.corba_to_datetime(history_rec._from) date_to = history_rec.to #recoder.corba_to_datetime(history_rec.to) logger_url = f_urls[ 'logger'] + 'detail/?id=%s' % history_rec.requestId if self.inner_details[i]: for j, detail in enumerate(self.inner_details[i]): _add_row(i, j, detail) else: _add_row(i, 0, None) else: self.add(div(attr(cssc='field_empty')))
def layout_fields(self): fields_in_section = self.get_fields() for field in fields_in_section: label_str = self.get_label_name(field) self.tbody.add(tr(td(attr(cssc='left_label'), label_str), td(field) ))
def create_layout(self): self.content = [] formset = self.formset self.add(tbody(tagid('tbody'))) if formset.non_form_errors(): self.tbody.add(tr(td( attr(colspan=self.columns_count), _('Errors:'), formset.non_form_errors()))) for form in formset.forms: self.tbody.add(tr(td(form))) formset.add(formset.management_form.fields.values()) if not formset.is_nested: self.tbody.add(self.get_submit_row())
def _format_property(self, prop): val = prop["value"] neg = "(neg)" if prop["neg"] else "" indent_style = "padding-left: 2em;" if prop["child"] else "" res = tr(td( "%s %s:" % (neg, prop["name"]), attr(style=indent_style)), td("%s" % val)) return res
def create_layout(self): detail = self.detail self.add(tbody(tagid('tbody'))) for field in detail.fields.values(): label_str = self.get_label_name(field) self.tbody.add( tr(td(attr(cssc='left_label'), label(label_str)), td(field)))
def create_layout(self): formset = self.formset self.add(tbody(tagid('tbody'))) if formset.non_form_errors(): self.tbody.add(tr(td( attr(colspan=self.columns_count), _('Errors:'), formset.non_form_errors()))) for form in formset.forms: self.tbody.add(tr(td(form))) formset.add(formset.management_form.fields.values()) if not formset.is_nested: self.tbody.add(self.get_submit_row())
def make_content(self): def _add_row(i, j, detail): history_tr = tr() history_tr.cssc = '' if i > 0: history_tr.cssc += ' history_row' if detail: history_tr.add(detail) else: history_tr.add(td(attr(colspan=len(thead_row.content) - 3), div(attr(cssc='field_empty')))) if j == 0: history_tr.cssc += ' history_division_row' rowspan_attr = attr(rowspan=len(self.inner_details[i]) or 1, cssc='history_dates_field') log_req_link = a(attr(href=logger_url), img(src='/img/icons/open.png')) if history_rec.requestId else '' history_tr.add( td(rowspan_attr, date_from), td(rowspan_attr, date_to), td(rowspan_attr, log_req_link) ) self.add(history_tr) self.content = [] self.create_inner_details() if self.inner_details: # Header: thead_row = tr() # Find one (any of them) innter detail for obtaining field labels (cannot take first one, becouse firt can be empty list): some_detail = None for details in self.inner_details: if details: some_detail = details[0] break for field in some_detail.fields.values(): thead_row.add(th(field.label)) thead_row.add(th(_('From')), th(_('To')), th(_('L.'))) self.add(thead(thead_row)) # rows (each row is made from one detail of object in object list self.add(tbody(tagid('tbody'))) for i in range(len(self.inner_details)): history_rec = self.value[i] date_from = history_rec._from #recoder.corba_to_datetime(history_rec._from) date_to = history_rec.to #recoder.corba_to_datetime(history_rec.to) logger_url = f_urls['logger'] + 'detail/?id=%s' % history_rec.requestId if self.inner_details[i]: for j, detail in enumerate(self.inner_details[i]): _add_row(i, j, detail) else: _add_row(i, 0, None) else: self.add(div(attr(cssc='field_empty')))
def create_layout(self): detail = self.detail self.add(tbody(tagid('tbody'))) for field in detail.fields.values(): label_str = self.get_label_name(field) self.tbody.add(tr(td(attr(cssc='left_label'), label(label_str)), td(field) ) )
def _render_nsset(self, nsset_detail): registrar_detail = nsset_detail.fields["registrar"].current_field.inner_detail # registrar of nsset handle_field = nsset_detail.fields["handle_url"] registrar_field = registrar_detail.fields["handle_url"] admins_field = nsset_detail.fields["admins"] hosts_field = nsset_detail.fields["hosts"] handle_label = self.get_label_name(handle_field) registrar_label = self.get_label_name(_("Registrar")) admins_label = self.get_label_name(_("Tech. contacts")) hosts_label = self.get_label_name(_("DNSs")) self.add(tr(td(attr(cssc="left_label"), handle_label), td(handle_field))) self.add(tr(td(attr(cssc="left_label"), registrar_label), td(registrar_field))) for i, admin_detail in enumerate(admins_field.current_field.inner_details): row = tr() if i == 0: row.add( td(attr(cssc="left_label", rowspan=len(admins_field.current_field.inner_details)), admins_label) ) email_part = "" if admin_detail.fields["email"].value: email_part = [", ", admin_detail.fields["email"]] row.add(td(attr(enclose_content=True), admin_detail.fields["handle_url"], email_part)) self.add(row) for i, host_detail in enumerate(hosts_field.current_field.inner_details): row = tr() if i == 0: row.add(td(attr(cssc="left_label", rowspan=len(hosts_field.current_field.inner_details)), hosts_label)) cell = td(attr(enclose_content=True)) cell.add(host_detail.fields["fqdn"]) if host_detail.fields["inet"].value: cell.add(" (", host_detail.fields["inet"], ")") row.add(cell) self.add(row)
def _render_check_status(self, tests_table, check_status, is_current_status): col_tag = th if is_current_status else td tests_table.footer.add(tr(col_tag(attr(colspan=self.col_count - 3), 'Overall status:'), col_tag(span(attr(title=enums.CHECK_STATUS_DESCS[check_status.status]), enums.CHECK_STATUS_NAMES[check_status.status])), td(get_detail('logger', check_status.logd_request_id).user_name \ if check_status.logd_request_id else _('automat')), td(attr(cssc='no-wrap'), check_status.update))) if is_current_status: if check_status.status == 'ok': tests_table.footer.content[0].add_css_class('status_ok') elif check_status.status == 'fail': tests_table.footer.content[0].add_css_class('status_fail')
def make_content(self): state_table = self.compute_state_data() if self.owner_detail.history and len(state_table): # dont display history if state_table have no row self.content = [] display_state_list = self.state_list[1:] self.tag = 'table' self.tattr_list = table.tattr_list self.cssc = 'state_table section_table' # header self.add(tr(th(_('Date')), [th(attr(cssc='state_header_cell', title=self.transform_title(_('Status'), self.get_state_title(state_id))), self.states_abbrev[state_id]) for state_id in display_state_list ])) if state_table: # date rows for row in state_table: tr_row = tr(th(attr(cssc='date_cell', title=self.transform_title(_('Statuses'), self.get_states_title_for_row(row))), row['row_date'])) for state_id in display_state_list: state_on = row[state_id] if state_on == True: tr_row.add(td(attr(cssc='state_on', title=self.transform_title(_('Status'), self.get_state_title(state_id))), 'X')) else: tr_row.add(td(attr(title=self.transform_title(_('Status'), self.get_state_title(state_id))))) self.add(tr_row) else: self.tag = 'table' self.tattr_list = table.tattr_list self.cssc = 'section_table' if len(state_table): self.add(tr(td(noesc(self.get_states_title_for_row(state_table[0]))))) else: self.add(tr(td(self.get_state_title(0))))
def layout_fields(self): self.add(table(tagid("table"))) self.add(legend(self.section_spec[0])) fields_in_section = self.get_fields() hidden_fields = [] for field in fields_in_section: if field.is_hidden: hidden_fields.append(field) continue label_str = self.get_label_name(field) errors = self.form.errors.get(field.name_orig, None) self.table.add(tr( td(label_str), td(errors, field))) self.add(hidden_fields)
def layout_fields(self): #fields_in_section = self.get_fields() # for field in fields_in_section: # field.create_inner_detail() # creates field.inner_detail # label_str = self.get_label_name(field) # #import pdb; pdb.set_trace() # self.tbody.add(tr(td(attr(cssc='left_label'), label_str), # td(field.inner_detail.fields['name']), # td(field.inner_detail.fields['email']) # )) date_and_registrar_fields_names = [ ['createDate', 'createRegistrar'], ['updateDate', 'updateRegistrar'], ['transferDate', None], ['expirationDate', None], ['valExDate', None], ['outZoneDate', None], ['deleteDate', None], ] date_and_registrar_fields = [[ self.detail.fields.get(date_field_name), self.detail.fields.get(registrar_field_name) ] for date_field_name, registrar_field_name in date_and_registrar_fields_names] for i, [date_field, registrar_field] in enumerate(date_and_registrar_fields): if not date_field: continue row = tr() if registrar_field: colspan_attr = attr() registrar_field.create_inner_detail( ) # creates field.inner_detail else: colspan_attr = attr(colspan=3) label_str = self.get_label_name(date_field) row.add(td(attr(cssc='left_label'), label_str), td(colspan_attr, date_field)) if registrar_field: row.add(th('by_registrar:'), td(registrar_field.inner_detail.fields['handle_url'])) self.tbody.add(row)
def make_content(self): self.content = [] if self.inner_details: # Header: thead_row = tr() for field in self.inner_details[0].fields.values(): thead_row.add(th(field.label)) self.add(thead(thead_row)) # rows (each row is made from one detail of object in object list self.add(tbody(tagid('tbody'))) for detail in self.inner_details: self.tbody.add(detail) else: self.add(div(attr(cssc='field_empty')))
def layout_fields(self): #fields_in_section = self.get_fields() # for field in fields_in_section: # field.create_inner_detail() # creates field.inner_detail # label_str = self.get_label_name(field) # #import pdb; pdb.set_trace() # self.tbody.add(tr(td(attr(cssc='left_label'), label_str), # td(field.inner_detail.fields['name']), # td(field.inner_detail.fields['email']) # )) date_and_registrar_fields_names = [ ['createDate', 'createRegistrar'], ['updateDate', 'updateRegistrar'], ['transferDate', None], ['expirationDate', None], ['valExDate', None], ['outZoneDate', None], ['deleteDate', None], ] date_and_registrar_fields = [ [self.detail.fields.get(date_field_name), self.detail.fields.get(registrar_field_name)] for date_field_name, registrar_field_name in date_and_registrar_fields_names ] for i, [date_field, registrar_field] in enumerate(date_and_registrar_fields): if not date_field: continue row = tr() if registrar_field: colspan_attr = attr() registrar_field.create_inner_detail() # creates field.inner_detail else: colspan_attr = attr(colspan=3) label_str = self.get_label_name(date_field) row.add(td(attr(cssc='left_label'), label_str), td(colspan_attr, date_field)) if registrar_field: row.add(th('by_registrar:'), td(registrar_field.inner_detail.fields['handle_url']) ) self.tbody.add(row)
def get_submit_row(self, hidden_fields=None): or_plus_button = input(attr( type="button", value="OR+", onclick="addOrForm(this)", style="float: left;")) save_input = input(attr( id='save_input', type="text", name="save_input", value=_('name'), disabled='disabled', style="float: left; margin-left: 0.4em; display:none;")) save_button = input(attr( type="button", value="Save", onclick="saveUnionForm(this)", style="float: left; margin-left: 0.4em")) submit_button = input(attr( type=u'button', value=u'OK', onclick='sendUnionForm(this)', style="float: right;")) return tr(attr(cssc='submit_row'), td( or_plus_button, save_input, save_button, hidden_fields, submit_button),)
def make_content(self): self.content = [] self._create_inner_details() if self.inner_details: # Header: thead_row = tr() for field in self.inner_details[0].fields.values(): thead_row.add(th(field.label)) self.add(thead(thead_row)) # rows (each row is made from one detail of object in object list self.add(tbody(tagid('tbody'))) for detail in self.inner_details: self.tbody.add(detail) else: self.add(div(attr(cssc='field_empty')))
def _add_row(i, j, detail): history_tr = tr() history_tr.cssc = '' if i > 0: history_tr.cssc += ' history_row' if detail: history_tr.add(detail) else: history_tr.add(td(attr(colspan=len(thead_row.content) - 3), div(attr(cssc='field_empty')))) if j == 0: history_tr.cssc += ' history_division_row' rowspan_attr = attr(rowspan=len(self.inner_details[i]) or 1, cssc='history_dates_field') log_req_link = a(attr(href=logger_url), img(src='/img/icons/open.png')) if history_rec.requestId else '' history_tr.add( td(rowspan_attr, date_from), td(rowspan_attr, date_to), td(rowspan_attr, log_req_link) ) self.add(history_tr)
def _add_row(i, j, detail): history_tr = tr() history_tr.cssc = '' if i > 0: history_tr.cssc += ' history_row' if detail: history_tr.add(detail) else: history_tr.add( td(attr(colspan=len(thead_row.content) - 3), div(attr(cssc='field_empty')))) if j == 0: history_tr.cssc += ' history_division_row' rowspan_attr = attr(rowspan=len(self.inner_details[i]) or 1, cssc='history_dates_field') log_req_link = a(attr( href=logger_url), img(src='/img/icons/open.png') ) if history_rec.requestId else '' history_tr.add(td(rowspan_attr, date_from), td(rowspan_attr, date_to), td(rowspan_attr, log_req_link)) self.add(history_tr)
def make_content(self): self.content = [] if self.inner_details: parent = self.parent_widget.parent_widget for detail in self.inner_details: if detail.data['type'] == u'MAILING': del detail.fields['type'] del detail.fields['companyName'] detail.layout_class = SectionDetailLayout parent.add( div(attr(cssc='section_label'), 'Mailing address:')) parent.add(detail) self.inner_details.remove(detail) break if self.inner_details: # Header: parent.add( table(tagid('others'), attr(cssc='section_table history_list_table'))) parent.others.add( div(attr(cssc='section_label'), 'Other addresses:')) thead_row = tr() for field in self.inner_details[0].fields.values(): thead_row.add(th(field.label)) parent.others.add(thead(thead_row)) # rows (each row is made from one detail of object in object list parent.others.add(tbody(tagid('tbody'))) for detail in self.inner_details: if not detail.data['type'] == u'MAILING': parent.others.tbody.add(detail) else: self.add(div(attr(cssc='field_empty')))
def layout_fields(self): date_and_registrar_fields_names = [ ['createDate', 'createRegistrar'], ['updateDate', 'updateRegistrar'], ['transferDate', None], ['expirationDate', None], ['valExDate', None], ['outZoneDate', None], ['deleteDate', None], ] date_and_registrar_fields = [[ self.detail.fields.get(date_field_name), self.detail.fields.get(registrar_field_name) ] for date_field_name, registrar_field_name in date_and_registrar_fields_names] for [date_field, registrar_field] in date_and_registrar_fields: if not date_field: continue row = tr() if registrar_field: colspan_attr = attr() registrar_field.create_inner_detail( ) # creates field.inner_detail else: colspan_attr = attr(colspan=3) label_str = self.get_label_name(date_field) row.add(td(attr(cssc='left_label'), label_str), td(colspan_attr, date_field)) if registrar_field: row.add(td(attr(cssc='left_label'), _('By registrar:')), td(registrar_field.inner_detail.fields['handle_url'])) self.tbody.add(row)
def render(self, indent_level=0): col_count = self.col_count = len(self.header) tests_table = table(attr(cssc='verification_check_table'), caption(attr(cssc='section_label'), _('Tests:'))) if self.resolve: self.add( form( attr(method='post', onsubmit='return confirm("%s")' % _('Are you sure?')), tests_table)) else: self.add(tests_table) tests_table.media_files.extend( ['/css/details.css', '/js/contactcheck_detail.js']) tests_table.add_css_class('section_table') if cherrypy.session.get('history', False): tests_table.add_css_class('history') tested_data_changed = self.get_data_info() if tested_data_changed: self.header.insert( self.header.index(_('Tested data')) + 1, _('Changed to')) tests_table.add(thead([th(item) for item in self.header])) if self.check.test_list: for row_num, test_data in enumerate( sorted(self.check.test_list, key=lambda k: enums.TEST_DESCS[k.test_handle])): rows = [] row = tr(attr(cssc='row%s' % ((row_num % 2) + 1))) current_status = test_data.status_history[-1] if current_status.status == 'ok': row.add_css_class('status_ok') elif current_status.status == 'fail': row.add_css_class('status_fail') row.add( td(attr(title=enums.TEST_DESCS[test_data.test_handle]), enums.TEST_NAMES[test_data.test_handle])) row.add( td( self._format_tested_data(test_data.tested_contact_data, test_data.test_handle))) if tested_data_changed: if test_data.current_contact_data != test_data.tested_contact_data: row.add( td( self._format_tested_data( test_data.current_contact_data, test_data.test_handle))) else: row.add(td()) self._render_test_status(row, current_status, test_data.test_handle, True) rows.append(row) if cherrypy.session.get('history', False): for older_status in reversed( test_data.status_history[0:-1]): row = tr(attr(cssc='row%s' % ((row_num % 2) + 1))) row.add( td( attr(colspan=3 if tested_data_changed else 2, cssc='borderless'))) self._render_test_status(row, older_status, test_data.test_handle, False) rows.append(row) # one tbody per test - tbodies have double border in css to separate tests as sections: tests_table.add(tbody(rows)) current_check_status = self.check.status_history[-1] tests_table.add(tfoot(save(tests_table, 'footer'))) self._render_check_status(tests_table, current_check_status, is_current_status=True) if cherrypy.session.get('history', False): for check_status in reversed(self.check.status_history[:-1]): self._render_check_status(tests_table, check_status, is_current_status=False) if self.resolve: tests_table.footer.add( tr( td( attr(colspan=col_count), table( attr(cssc='submit-row'), tr( td( button( attr(type='submit', name='status_action', value=status_action, id=status_action), action_name)) for status_action, action_name in get_status_action( self.check.test_suite_handle, current_check_status.status).items()))))) filters = [[[ _('Domains_owner'), 'domain', [{ 'Registrant.Handle': self.check.contact_handle }] ]]] panel = FilterPanel(filters) self.add(panel) return super(VerificationCheckDetail, self).render(indent_level)
def get_submit_row(self): return tr(td( attr(colspan=self.columns_count, cssc='center'), input(attr(type=u'submit', value=u'Save set', name=u'submit'))))
def get_submit_row(self, hidden_fields=None): return tr( td(attr(colspan=self.columns_count, cssc='center'), hidden_fields, input(attr(type=u'submit', value=_(u'Save'), name=u'submit'))))
def __init__(self, context = None): super(FilterPage, self).__init__(context) c = self.context lang_code = config.lang[0:2] if lang_code == 'cs': # conversion between cs and cz identifier of lagnguage lang_code = 'cz' self.head.add(script(attr(type='text/javascript'), 'scwLanguage = "%s"; //sets language of js_calendar' % lang_code, 'scwDateOutputFormat = "%s"; // set output format for js_calendar' % config.js_calendar_date_format)) if context.get('form') and (config.debug or not c.get('itertable') or c.get('show_form')): self.main.add(c.form) self.main.add(script(attr(type='text/javascript'), 'Ext.onReady(function () {addFieldsButtons()})')) else: self.main.add(a(attr(href=append_getpar_to_url(add_par_dict={'load': 1, 'show_form': 1})), _('Modify filter'))) if c.get('result'): self.main.add(p(c['result'])) if c.get('itertable'): itertable = c.itertable self.main.add(WIterTable(itertable)) self.main.add(p(_('Table_as'), a(attr(href='?txt=1'), 'TXT'), ',', a(attr(href='?csv=1'), 'CSV'))) if config.debug: self.main.add(br(), br()) header = tr(attr(cssc="header")) for htext in itertable.header: header.add(td(htext)) rows = [header] for irow in itertable: row = tr() for col in irow: if col.get('icon'): val = img(attr(src=col['icon'])) else: val = col['value'] if col.get('url'): val = a(attr(href=col['url']), val) row.add(td(attr(cssc=col.get('cssc')), val)) rows.append(row) self.main.add(table(attr(id='objectlist', media_files='/css/objectlist.css'), rows)) # Numbers of entries if itertable.num_rows_over_limit: num_rows = span(attr(cssc='warning'), itertable.num_rows) else: num_rows = itertable.num_rows pageflip = span( '%s: %s,' % (_('Number_of_pages'), itertable.last_page), '%s: ' % _('entries'), num_rows, ',', br()) # Pager if itertable.num_pages > 1: pageflip.add(div( a(attr(cssc='pager-button', href='?page=%s' % itertable.first_page), noesc('«')), a(attr(cssc='pager-button', href='?page=%s' % itertable.prev_page), noesc('‹')), form(attr(style='display: inline;', method='GET'), input(attr(type='text', size='2', name='page', value=itertable.current_page))), a(attr(cssc='pager-button', href='?page=%s' % itertable.next_page), noesc('›')), a(attr(cssc='pager-button', href='?page=%s' % itertable.last_page), noesc('»')) )) self.main.add(pageflip) if c.get("display_jump_links"): # Display the 'previous' and 'next' links (they auto-submit # the form to display results for the prev./next time interval). jump_links_info = c.get("display_jump_links") self.main.add(div(a( attr( title="Jumps to the previous time period.", href=(jump_links_info['url'] + 'filter/?jump_prev=1&field_name=%s' % jump_links_info['field_name'])), "prev"), a(attr( title="Jumps to the next time period.", href=(jump_links_info['url'] + 'filter/?jump_next=1&field_name=%s' % jump_links_info['field_name'])), "next")))
def get_submit_row(self, hidden_fields=None): return tr(td(attr(colspan=self.columns_count, cssc='center'), hidden_fields, input(attr(type=u'submit', value=_(u'Save'), name=u'submit')) ))
def __init__(self, itertable, *content, **kwd): super(WIterTable, self).__init__(*content, **kwd) self.media_files = ['/js/logging.js', '/css/itertable.css', ] self.tag = 'table' self.cssc = 'itertable' self.column_count = len(itertable.header) sort_col_num, sort_direction = itertable.get_sort() header = tr(attr(cssc="wi_header")) for i, htext in enumerate(itertable.header): col_num = i - 1 if col_num == -1: # first column is ID header.add(th(htext)) else: sort_dir = 1 if col_num == sort_col_num and sort_direction: # rendering column, according which is table sorted, so reverse direction for next click on this column sort_dir = 0 th_cell = th(a(attr(href=append_getpar_to_url(add_par_dict={'sort_col': col_num, 'sort_dir': sort_dir}, del_par_list=['load', 'show_form'])), htext)) if col_num == sort_col_num: th_cell.cssc = 'sorted ' + ['ascending', 'descending'][sort_direction] header.add(th_cell) self.add(thead(header)) rows = [] for row_num, irow in enumerate(itertable): row = tr(attr(cssc='row%s' % ((row_num % 2) + 1))) for col in irow: if col.get('icon'): val = img(attr(src=col['icon'])) else: val = col['value'] if col.get('url'): val = a(attr(href=col['url']), val) row.add(td(attr(cssc=col.get('cssc')), val)) rows.append(row) self.add(tbody(rows)) # Pager pager = span() # Numbers of entries #if itertable.total_rows > itertable.num_rows: if itertable.num_rows_over_limit: num_rows = span(attr(cssc='warning'), itertable.num_rows) else: num_rows = itertable.num_rows pager.add(span(attr(cssc='pager_text'), noesc('Displaying results %s - %s of %s' % (itertable.page_start, itertable.page_start + itertable.page_rows, num_rows)) # '%s: %s,' % (_('Number_of_pages'), itertable.last_page), # '%s: ' % _('entries'), num_rows, ',', # '%s: %s' % (_('total'), itertable.total_rows), # #br() )) if itertable.num_pages > 1: # pager.add( # a(attr(cssc='pager-button', href='?page=%s' % itertable.first_page), noesc('«')), # a(attr(cssc='pager-button', href='?page=%s' % itertable.prev_page), noesc('‹')), ## a(attr(cssc='pager-button', href='?page=%s' % itertable._number), itertable._number), # form(attr(style='display: inline;', method='GET'), input(attr(type='text', size='2', name='page', value=itertable.current_page))), # a(attr(cssc='pager-button', href='?page=%s' % itertable.next_page), noesc('›')), # a(attr(cssc='pager-button', href='?page=%s' % itertable.last_page), noesc('»')) # ) if itertable.current_page == 1: first_button = span(attr(cssc='pager-button'), img(attr(src='/css/ext/images/default/grid/page-first-disabled.gif'))) prev_button = span(attr(cssc='pager-button'), img(attr(src='/css/ext/images/default/grid/page-prev-disabled.gif'))), else: first_button = a(attr(cssc='pager-button', href='?page=%s' % itertable.first_page), img(attr(src='/css/ext/images/default/grid/page-first.gif'))), prev_button = a(attr(cssc='pager-button', href='?page=%s' % itertable.prev_page), img(attr(src='/css/ext/images/default/grid/page-prev.gif'))), if itertable.current_page == itertable.last_page: next_button = span(attr(cssc='pager-button'), img(attr(src='/css/ext/images/default/grid/page-next-disabled.gif'))), last_button = span(attr(cssc='pager-button'), img(attr(src='/css/ext/images/default/grid/page-last-disabled.gif'))) else: next_button = a(attr(cssc='pager-button', href='?page=%s' % itertable.next_page), img(attr(src='/css/ext/images/default/grid/page-next.gif'))), last_button = a(attr(cssc='pager-button', href='?page=%s' % itertable.last_page), img(attr(src='/css/ext/images/default/grid/page-last.gif'))) pager.add( first_button, prev_button, # a(attr(cssc='pager-button', href='?page=%s' % itertable._number), itertable._number), form(attr(style='display: inline;', method='GET'), input(attr(type='text', size='2', name='page', value=itertable.current_page)), ' of %d ' % itertable.last_page), next_button, last_button ) self.add(tfoot(tr(td(attr(colspan=self.column_count), pager))))
def create_layout(self): self.add(tbody(tagid('tbody'))) for section_spec in self.detail.sections: self.tbody.add(tr(td(self.create_section(section_spec))))
def __init__(self, itertable, *content, **kwd): super(WIterTable, self).__init__(*content, **kwd) self.media_files = [ '/js/logging.js', '/js/itertable.js', '/css/itertable.css', ] self.tag = 'table' self.cssc = 'itertable' self.column_count = len(itertable.header) sort_col_num, sort_direction = itertable.get_sort() header = tr(attr(cssc="wi_header")) for i, htext in enumerate(itertable.header): col_num = i - 1 if col_num == -1: # first column is ID header.add(th(attr(id='id_column_header_cell'), htext)) else: sort_dir = 1 if col_num == sort_col_num and sort_direction: # rendering column, according which is table sorted, so reverse direction for next click on this column sort_dir = 0 th_cell = th( a( attr(href=append_getpar_to_url( add_par_dict={ 'sort_col': col_num, 'sort_dir': sort_dir }, del_par_list=['load', 'show_form'])), htext)) if col_num == sort_col_num: th_cell.cssc = 'sorted ' + ['descending', 'ascending' ][sort_direction] header.add(th_cell) self.add(thead(header)) rows = [] for row_num, irow in enumerate(itertable): row = tr(attr(cssc='row%s' % ((row_num % 2) + 1))) for col_num, col in enumerate(irow): row.add(self._render_col(col_num, col)) rows.append(row) self.add(tbody(rows)) # Pager pager = span() # Numbers of entries if itertable.num_rows_over_limit: num_rows = span(attr(cssc='warning'), itertable.num_rows) else: num_rows = itertable.num_rows if itertable.pagination: result_text = 'Displaying results %s - %s of %s' % ( itertable.page_start, itertable.page_start + itertable.page_rows, num_rows) else: result_text = 'Displaying %s results' % (num_rows) pager.add(span(attr(cssc='pager_text'), noesc(result_text))) if itertable.pagination: if itertable.num_pages > 1: if itertable.current_page == 1: first_button = span( attr(cssc='pager-button'), img( attr( src= '/css/ext/images/default/grid/page-first-disabled.gif' ))) prev_button = span( attr(cssc='pager-button'), img( attr( src= '/css/ext/images/default/grid/page-prev-disabled.gif' ))), else: first_button = a( attr(cssc='pager-button', href='?page=%s' % itertable.first_page), img( attr( src='/css/ext/images/default/grid/page-first.gif' ))), prev_button = a( attr(cssc='pager-button', href='?page=%s' % itertable.prev_page), img( attr( src='/css/ext/images/default/grid/page-prev.gif' ))), if itertable.current_page == itertable.last_page: next_button = span( attr(cssc='pager-button'), img( attr( src= '/css/ext/images/default/grid/page-next-disabled.gif' ))), last_button = span( attr(cssc='pager-button'), img( attr( src= '/css/ext/images/default/grid/page-last-disabled.gif' ))) else: next_button = a( attr(cssc='pager-button', href='?page=%s' % itertable.next_page), img( attr( src='/css/ext/images/default/grid/page-next.gif' ))), last_button = a( attr(cssc='pager-button', href='?page=%s' % itertable.last_page), img( attr( src='/css/ext/images/default/grid/page-last.gif' ))) pager.add( first_button, prev_button, form( attr(style='display: inline;', method='GET'), input( attr(type='text', size='2', name='page', value=itertable.current_page)), ' of %d ' % itertable.last_page), next_button, last_button) self.add(tfoot(tr(td(attr(colspan=self.column_count), pager))))