Пример #1
0
 def _get_blocking_form(self, blocking_action):
     from fred_webadmin.controller.adif import Domain
     return form(
         attr(method='post',
              action='%s/filter/blocking_start/' % f_urls['domain']),
         input(type='hidden', name='pre_blocking_form', value='1'),
         input(type='hidden', name='blocking_action',
               value=blocking_action),
         input(type='hidden',
               name='object_selection',
               value=self.data.get('id')),
         input(type='submit',
               value=Domain.blocking_views[blocking_action].action_name),
     )
Пример #2
0
    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))))
        
Пример #3
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)
Пример #4
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))))
Пример #5
0
    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")))