def resolve_value(self, value): """ Handles displayed value formatting. Args: value: List of ccReg.RequestProperty objects. Returns: WebWidget subclass representing the HTML content of the field. """ if not value: return u'' vals = self._process_negations(value) inprops, outprops = self._separate_properties(vals) def cmp_props(a, b): if a['name'] > b['name']: return 1 elif a['name'] == b['name']: return 0 else: return -1 table_in = table([self._format_property(prop) for prop in inprops]) if \ inprops else span() table_out = table([self._format_property(prop) for prop in outprops]) if \ outprops else span() return div(h4("input", attr(style="margin: 1px 1px 1px 1px;")), table_in, hr(), h4("output", attr(style="margin: 1px 1px 1px 1px;")), table_out)
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 __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 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_start(self): section_name = self.section_spec[0] section_id = self.section_spec[1] link_id = "%s_display" % section_id if section_name: self.add(legend(section_name)) 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, title="Click to show or hide the fieldset contents."))) self.add(table( tagid('table'), attr(cssc="form_table"), id=section_id))
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 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 layout_start(self): section_name = self.section_spec[0] if section_name: self.add(legend(section_name)) self.add(table(tagid('table'), attr(cssc="form_table")))
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")))