Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
    def __init__(self, context = None):
        context = context or {}
        
        if not context.get('title'):
            context['title'] = 'Daphne'
            if context.get('user') and context.get('corba_server'):
                context['title'] += ' - %s' % context.get('corba_server')

        super(BaseSite, self).__init__(context)
        c = self.context

        self.add_media_files('/css/basesite.css')
        self.header.add(
            div(attr(id='branding'), save(self, 'branding'),
                div(attr(id='user_tools'), save(self, 'user_tools'))),
            div(
                div(attr(id='menu_container'), save(self, 'menu_container')),
                div(attr(id='right_menu_container'), save(self, 'right_menu_container'), 
                )
            )
        )
        self.branding.add(h1('Daphne'))
        
        if c.get('user') and c.get('corba_server'):
            self.user_tools.add(span('Server: %s' % c.corba_server),
                                '|',
                                span('User: %s(%s %s)' % (c.user.login, c.user.firstname, c.user.surname)), 
                                '|', 
                                a(attr(href="/logout"), 'Log out'))

        if c.get('main'):
            self.main.add(c.main)
Exemplo n.º 3
0
    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)
Exemplo n.º 4
0
 def make_content(self):
     self.add(self.fields[3],
              span(attr(cssc='date_interval'),
                   save(self, 'date_interval_span'),
                   _('from') + ':', self.fields[0],
                   _('to') + ':', self.fields[1],
              ),
              span(save(self, 'date_interval_offset_span'),
                   attr(cssc='date_interval_offset'), _('offset') + ':', self.fields[4]),
                  
              span(attr(cssc='date_day'),
                   save(self, 'date_day_span'),
                   _('day') + ':', self.fields[2]
                  ),
             )
     self.content_initialized = True
     self.set_iterval_date_display()
Exemplo n.º 5
0
 def make_content(self):
     self.content = []
     if self.value:
         cssc = 'disclose' + unicode(bool(self.value[1])) # => 'discloseTrue' or 'discloseFalse'
         if self.value[0] == '':
             self.add(div(attr(cssc=cssc + ' field_empty')))
         else:
             self.add(span(attr(cssc=cssc), self.value[0]))
     else:
         self.add(div(attr(cssc='field_empty'))) # in case no access (from permissions)
Exemplo n.º 6
0
 def make_content(self):
     self.add(
         self.fields[3],
         span(
             attr(cssc='date_interval'),
             save(self, 'date_interval_span'),
             _('from') + ':',
             self.fields[0],
             _('to') + ':',
             self.fields[1],
         ),
         span(save(self, 'date_interval_offset_span'),
              attr(cssc='date_interval_offset'),
              _('offset') + ':', self.fields[4]),
         span(attr(cssc='date_day'), save(self, 'date_day_span'),
              _('day') + ':', self.fields[2]),
     )
     self.content_initialized = True
     self.set_iterval_date_display()
Exemplo n.º 7
0
 def make_content(self):
     self.content = []
     if self.value:
         cssc = 'disclose' + unicode(bool(
             self.value[1]))  # => 'discloseTrue' or 'discloseFalse'
         if self.value[0] == '':
             self.add(div(attr(cssc=cssc + ' field_empty')))
         else:
             self.add(span(attr(cssc=cssc), self.value[0]))
     else:
         self.add(div(attr(
             cssc='field_empty')))  # in case no access (from permissions)
Exemplo n.º 8
0
 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')
Exemplo n.º 9
0
 def make_content(self):
     self.content = []
     for value, caption in self.choices:
         if unicode(value) in self.value:
             checked = 'checked'
         else:
             checked = None
         self.add(
             span(
                 input(
                     attr(type='checkbox',
                          checked=checked,
                          name=self.name,
                          value=value)), caption, br()))
Exemplo n.º 10
0
    def _render_test_status(self, test_row, status, test_handle,
                            is_current_status):
        test_row.add(td(status.err_msg))
        status_td = td(attr(cssc='no-wrap status_col'))

        if is_current_status and self.resolve:
            status_td.add(self.form.fields[test_handle])
        else:
            status_td.add(
                span(attr(title=enums.TEST_STATUS_DESCS[status.status]),
                     enums.TEST_STATUS_NAMES[status.status]))
        test_row.add(status_td)

        if status.logd_request_id:
            log_req_detail = get_detail('logger', status.logd_request_id)
            test_row.add(td(log_req_detail.user_name))
        else:
            test_row.add(td(_('automat')))

        test_row.add(td(attr(cssc='no-wrap'), status.update))
Exemplo n.º 11
0
    def _render_col(self, col_num, col):
        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)

        if col_num == 0:
            val = span(
                input(
                    attr(
                        type='checkbox',
                        name='object_selection',
                        value=col.get('value'),
                        cssc='object_selection',
                    ), val))

        return td(attr(cssc=col.get('cssc')), val)
Exemplo n.º 12
0
 def render(self, *args, **kwargs):
     if self.permitted:
         return super(Field, self).render(*args, **kwargs)
     else:
         return span().render()
Exemplo n.º 13
0
 def make_content(self):
     self.content = []
     if self.value == ['', '', '', '']:
         self.add(div(attr(cssc='field_empty')))
     self.add(strong(self.value[0]), span(_(u'(%s + %s of %s%% VAT)') % tuple(self.value[1:])))
Exemplo n.º 14
0
 def make_content(self):
     self.content = []
     if self.value == ['', '']:
         self.add(div(attr(cssc='field_empty')))
     self.add(strong(self.value[0]), span(attr(cssc='epp'), '(EPP id:', self.value[1], ')'))
Exemplo n.º 15
0
 def render(self, *args, **kwargs):
     if self.permitted:
         return super(Field, self).render(*args, **kwargs)
     else:
         return span().render()
Exemplo n.º 16
0
 def make_content(self):
     self.content = []
     if self.value == ['', '', '', '']:
         self.add(div(attr(cssc='field_empty')))
     self.add(strong(self.value[0]),
              span(_(u'(%s + %s of %s%% VAT)') % tuple(self.value[1:])))
Exemplo n.º 17
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")))
Exemplo n.º 18
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))))
Exemplo n.º 19
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))))
        
Exemplo n.º 20
0
 def make_content(self):
     self.content = []
     if self.value == ['', '']:
         self.add(div(attr(cssc='field_empty')))
     self.add(strong(self.value[0]),
              span(attr(cssc='epp'), '(EPP id:', self.value[1], ')'))