Esempio n. 1
0
    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))
Esempio n. 2
0
    def printout(self, handle, **kwd):
        lang_code = config.lang[:2]
        if lang_code == 'cs':  # conversion between cs and cz identifier of lagnguage
            lang_code = 'cz'
        context = {'main': div()}
        context['main'].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 cherrypy.request.method == 'POST':
            form = ObjectPrintoutForm(data=kwd)
            if form.is_valid():
                for_time = form.cleaned_data['for_time']
                props = [('handle', handle), ('for_time', for_time)]
                log_req = create_log_request('RecordStatement',
                                             properties=props)
                try:
                    return self._get_printout_pdf(handle, for_time)
                except Registry.RecordStatement.OBJECT_NOT_FOUND:
                    form.add_error(
                        'for_time',
                        _('Object "{}" was not found for the given date.'.
                          format(handle)))
                finally:
                    log_req.close()
        else:
            form = ObjectPrintoutForm()

        context['heading'] = _('Download printout')
        context['form'] = form
        return self._render('printout', context)
Esempio n. 3
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())
Esempio n. 4
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())
Esempio n. 5
0
 def create_layout(self):
     self.add(tbody(tagid('tbody')))
     form_count = len(self.form.forms)
     for i, inner_form in enumerate(self.form.forms):
         if i > 0 and i < form_count:
             self.tbody.add(tr(attr(cssc='or_row'), self.build_or_row()))
         self.tbody.add(tr(td(inner_form)))
     self.tbody.add(self.get_submit_row())
     self.tbody.add(script(attr(type='text/javascript'), noesc(self.union_form_js())))
     debug('After create unionlayout')
Esempio n. 6
0
 def create_layout(self):
     self.add(tbody(tagid('tbody')))
     form_count = len(self.form.forms)
     for i, inner_form in enumerate(self.form.forms):
         if i > 0 and i < form_count:
             self.tbody.add(tr(attr(cssc='or_row'), self.build_or_row()))
         self.tbody.add(tr(td(inner_form)))
     self.tbody.add(self.get_submit_row())
     self.tbody.add(
         script(attr(type='text/javascript'), noesc(self.union_form_js())))
     debug('After create unionlayout')
Esempio n. 7
0
 def __init__(self, context = None):
     super(AllFiltersPage, self).__init__(context)
     c = self.context
     if c.has_key('filters_list'):
         self.main.add(c['filters_list'])
         lang_code = config.lang[: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))
Esempio n. 8
0
 def __init__(self, *args, **kwd):
     super(DetailPage, self).__init__(*args, **kwd)
     lang_code = config.lang[: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))
Esempio n. 9
0
 def __init__(self, context):
     super(ContactCheckList, self).__init__(context)
     c = self.context
     self.head.add(
         script(attr(type='text/javascript'),
                'ajaxSourceURLOfChecks = "%s";' % c.ajax_json_filter_url))
     if 'default_js_type_filter' in c:
         self.head.add(
             script(attr(type='text/javascript'),
                    'defaultTypeFilter = "%s";' % c.default_js_type_filter))
     self.main.add(h1(c.heading))
     self.main.add(c.table_tag)
     lang_code = config.lang[: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))
Esempio n. 10
0
 def __init__(self, context=None):
     super(GroupEditorPage, self).__init__(context)
     c = self.context
     if c.get('form'):
         self.main.add(c.form)
         lang_code = config.lang[: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_edit))
Esempio n. 11
0
    def __init__(self, context):
        super(DomainBlocking, self).__init__(context)
        c = self.context
        self.main.add(h1(c['heading']))
        if c.get('form'):
            self.main.add(c['form'])

        lang_code = config.lang[: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))
Esempio n. 12
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('&laquo;')),
                        a(attr(cssc='pager-button', href='?page=%s' % itertable.prev_page), noesc('&lsaquo;')),
                        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('&rsaquo;')),
                        a(attr(cssc='pager-button', href='?page=%s' % itertable.last_page), noesc('&raquo;'))
                    ))
                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")))
Esempio n. 13
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('witertable'):
            if c.get('blocking_mode'):
                self.main.add(
                    h1(attr(id='blocking_text'), _('Administrative blocking')))
            self.main.add(c.witertable)
            if not c.get('blocking_mode'):
                self.main.add(
                    p(tagid('exports'), _('Table_as'),
                      a(attr(href='?txt=1'), 'TXT'), ',',
                      a(attr(href='?csv=1'), 'CSV')))

        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")))

        if c.get('blocking_possible') and not c.get('blocking_mode'):
            self.main.add(
                p(
                    a(attr(href='./blocking_start/'),
                      _('Administrative blocking'))))