示例#1
0
文件: dfields.py 项目: LANJr4D/FRED
    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')))
示例#2
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())
示例#3
0
    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')))
示例#4
0
    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')))
示例#5
0
    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))))
示例#6
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())
示例#7
0
文件: dfields.py 项目: LANJr4D/FRED
    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')))
示例#8
0
    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)
示例#9
0
文件: dfields.py 项目: LANJr4D/FRED
    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))))
示例#10
0
    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)
示例#11
0
    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')))
示例#12
0
文件: dfields.py 项目: LANJr4D/FRED
    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')))
示例#13
0
    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)
示例#14
0
    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')))
示例#15
0
文件: table.py 项目: LANJr4D/FRED
    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))))
        
示例#16
0
    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)
示例#17
0
    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))))