예제 #1
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)
예제 #2
0
파일: dfields.py 프로젝트: LANJr4D/FRED
 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)
예제 #3
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)
예제 #4
0
    def create_layout(self):
        formset = self.formset

        self.add(div(tagid('div')))

        if formset.non_form_errors():
            self.div.add(div(_('Errors:')), div(formset.non_form_errors()))

        for form in formset.forms:
            self.div.add(div(form))

        formset.add(formset.management_form.fields.values())
        if not formset.is_nested:
            self.div.add(self.get_submit_row())
예제 #5
0
    def create_layout(self):
        formset = self.formset
        
        self.add(div(tagid('div')))
        
        if formset.non_form_errors():
            self.div.add(div(_('Errors:')), div(formset.non_form_errors()))

        for form in formset.forms:
            self.div.add(div(form))
        
        formset.add(formset.management_form.fields.values())
        if not formset.is_nested:
            self.div.add(self.get_submit_row())
예제 #6
0
    def create_layout(self):
        form = self.form

        if form.non_field_errors():
            self.add(div(_('Errors:'), form.non_field_errors()))
        hidden_fields = []

        for index, section in enumerate(form.sections):
            section_layout_class = section[-1]
            self.add(div(
                attr(cssc="editform"), section_layout_class(form, section)))

        self.add(hidden_fields)
        if not form.is_nested:
            self.add(self.get_submit_row())
예제 #7
0
파일: dfields.py 프로젝트: LANJr4D/FRED
    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)
예제 #8
0
파일: perms.py 프로젝트: LANJr4D/FRED
        def _wrapper(*args, **kwd):
            self = args[0]
            user = cherrypy.session.get('user', None)
            if user:
                utils.details_cache = {} # invalidate details cache
                nperms = []
                if isinstance(objects_nperms, types.StringTypes):
                    onperms = [objects_nperms]
                else:
                    onperms = objects_nperms
                for objects_nperm in onperms:
                    nperms.append('%s.%s' % (objects_nperm, self.classname))
                if user.check_nperms(nperms, check_type):
                    context = {'message': div()}
                    context['message'].add(
                        p(_("You don't have permissions for this page!")))
                    if fred.config.debug:
                        context['message'].add(
                            p(
                                'usernperm = %s,' % user.nperms, br(),
                                'nperms=%s,' % nperms, br(),
                                'nperm_type=%s' % check_type, br()))
                        context['message'].add(p(
                            "a tohle to je udelano nejsofistikovanejsim "
                            "decoratorem"))
                    return self._render('error', context)
                return view_func(*args, **kwd)

            redir_addr = '/login/?next=%s' % get_current_url(cherrypy.request)
            raise cherrypy.HTTPRedirect(redir_addr)
예제 #9
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')))
예제 #10
0
        def _wrapper(*args, **kwd):
            self = args[0]
            user = cherrypy.session.get('user', None)
            if user:
                utils.details_cache = {}  # invalidate details cache
                nperms = []
                if isinstance(objects_nperms, types.StringTypes):
                    onperms = [objects_nperms]
                else:
                    onperms = objects_nperms
                for objects_nperm in onperms:
                    nperms.append('%s.%s' % (objects_nperm, self.classname))
                if user.check_nperms(nperms, check_type):
                    context = {'message': div()}
                    context['message'].add(
                        p(_("You don't have permissions for this page!")))
                    if fred.config.debug:
                        context['message'].add(
                            p('usernperm = %s,' % user.nperms, br(),
                              'nperms=%s,' % nperms, br(),
                              'nperm_type=%s' % check_type, br()))
                    return self._render('error', context)
                return view_func(*args, **kwd)

            redir_addr = '/login/?next=%s' % get_current_url(cherrypy.request)
            raise cherrypy.HTTPRedirect(redir_addr)
예제 #11
0
파일: listtable.py 프로젝트: saimir/FRED
    def filter(self, *args, **kwd):
        context = {'main': div()}
        action = 'list' if kwd.get('list_all') else 'filter'
        
        if kwd.get('txt') or kwd.get('csv'):
            res = self._get_list(context, **kwd)
            return res
        elif (kwd.get('cf') or kwd.get('page') or kwd.get('load') or 
              kwd.get('list_all') or kwd.get('filter_id') or
              kwd.get('sort_col')): 
            # clear filter - whole list of objects without using filter form
            context = self._get_list(context, **kwd)
        elif kwd.get("jump_prev") or kwd.get("jump_next"):
            # Increase/decrease the key time field offset and reload the
            # table (jump to the prev./next time interval).
            table = self._get_itertable()
            delta = -1 if kwd.get("jump_prev") else 1
            cleaned_filter_data = table.get_filter_data()
            self._update_key_time_field_offset(
                cleaned_filter_data, kwd['field_name'], delta)
            action = self._process_form(context, action, cleaned_filter_data, **kwd)
        else:
            action = self._process_form(context, action, **kwd)

        return self._render(action, context)
예제 #12
0
파일: formlayouts.py 프로젝트: saimir/FRED
 def layout_fields(self): 
     section_name = self.section_spec[0]
     section_id = self.section_spec[1]
     link_id = "%s_display" % section_id
     self.add(div(
         attr(style="text-align: right; padding-right: 1em;"),
         a(
             "hide", 
             attr(href="JavaScript:void();"), 
             onclick="show_hide('%s', '%s');" % (section_id, link_id),
             id=link_id)))
     self.add(table(tagid("table"), id=section_id))
     self.add(legend(section_name))
     fields_in_section = self.get_fields()
     hidden_fields = []
     for field in fields_in_section:
         if field.is_hidden:
             hidden_fields.append(field)
             continue
         label_str = self.get_label_name(field)
         errors = self.form.errors.get(field.name_orig, None)
         self.table.add(tr(
             td(label_str),
             td(errors, field)))
     self.add(hidden_fields)
예제 #13
0
 def build_or_row(self):
     return td(
         attr(cssc='or_cell', colspan=self.columns_count), 
         input(attr(
             type="button", value="OR-", onclick="removeOr(this)", 
             style="float: left;")), 
         div(attr(style="padding-top: 0.3em"), 'OR'))
예제 #14
0
    def create_layout(self):
        form = self.form

        if form.non_field_errors():
            self.add(div(_('Errors:'), form.non_field_errors()))
        hidden_fields = []

        for index, section in enumerate(form.sections):
            section_layout_class = section[-1]
            self.add(
                div(attr(cssc="editform"), section_layout_class(form,
                                                                section)))

        self.add(hidden_fields)
        if not form.is_nested:
            self.add(self.get_submit_row())
예제 #15
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())
예제 #16
0
    def make_content(self):
        self.content = []

        self.inner_field.owner_detail = self.owner_detail
        if self.value:
            for i, history_rec in enumerate(self.value):
                val = from_any(history_rec.value, True)
                inner_field_copy = copy(self.inner_field)
                inner_field_copy.value = val
                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(
                    td(inner_field_copy),
                    td(attr(cssc='history_dates_field'), _('from'), date_from),
                    td(attr(cssc='history_dates_field'), date_to and _('to')
                       or '', date_to),
                    td(attr(cssc='history_dates_field'), log_req_link))
                self.add(history_tr)
        else:
            self.add(div(attr(cssc='field_empty')))
예제 #17
0
파일: dfields.py 프로젝트: LANJr4D/FRED
    def make_content(self):
        self.content = []

        self.inner_field.owner_detail = self.owner_detail
        if self.value:
            for i, history_rec in enumerate(self.value):
                val = from_any(history_rec.value, True)
                inner_field_copy = copy(self.inner_field)
                inner_field_copy.value = val
                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(
                    td(inner_field_copy),
                    td(attr(cssc='history_dates_field'), _('from'), date_from),
                    td(attr(cssc='history_dates_field'), date_to and _('to') or '', date_to),
                    td(attr(cssc='history_dates_field'), log_req_link)
                )
                self.add(history_tr)
        else:
            self.add(div(attr(cssc='field_empty')))
예제 #18
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')))
예제 #19
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)
예제 #20
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)
예제 #21
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')))
예제 #22
0
파일: dfields.py 프로젝트: LANJr4D/FRED
 def make_content(self):
     self.content = []
     oid = self._value
     if oid is not None:
         self.add(a(attr(href=f_urls[f_enum_name[oid.type]] + u'detail/?id=' + unicode(oid.id)),
                    oid.handle))
     else:
         self.add(div(attr(cssc='field_empty')))
예제 #23
0
 def __init__(self, context = None):
     super(MailDetail, self).__init__(context)
     c = self.context
     if c.get('result'):
         self.main.add(h1(_('Detail_of_%s' % self.get_object_name())))
         self.main.add(adifdetails.MailDetail(c.result, c.history))
         if config.debug:
             self.main.add('MailDETAIL:', div(attr(style='width: 1024px; overflow: auto;'), pre(unicode(c.result).replace(u', ', u',\n'))))
예제 #24
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())
예제 #25
0
    def allfilters(self, *args, **kwd):
        context = {'main': div()}

        itertable = self._get_itertable('filter')
        itertable.set_filter([{'Type': [False, f_name_id[self.classname]]}])
        itertable.reload()
        context['filters_list'] = FilterListCustomUnpacked(
            itertable.get_rows_dict(raw_header=True), self.classname)
        return self._render('allfilters', context)
예제 #26
0
파일: dfields.py 프로젝트: LANJr4D/FRED
    def make_content(self):
        self.content = []

        if self.object_type_name is None: # this cannot be in constructor, becouse self.owner_detail is not known at construction time
            self.object_type_name = self.owner_detail.get_object_name()

        if self.value[self.handle_name] == '':
            self.add(div(attr(cssc='field_empty')))
        self.add(a(attr(href=f_urls[self.object_type_name] + 'detail/?id=%s' % self.value[self.id_name]), self.value[self.handle_name]))
예제 #27
0
 def build_or_row(self):
     return td(
         attr(cssc='or_cell', colspan=self.columns_count),
         input(
             attr(type="button",
                  value="OR-",
                  onclick="removeOr(this)",
                  style="float: left;")),
         div(attr(style="padding-top: 0.3em"), 'OR'))
예제 #28
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')))
예제 #29
0
파일: dfields.py 프로젝트: LANJr4D/FRED
 def make_content(self):
     self.content = []
     if not self._value:
         self.add(div(attr(cssc='field_empty')))
     else:
         self.add(a(attr(
             href=(
                 f_urls[f_enum_name[ ccReg.FT_FILE]] + u'detail/?id=' +
                 unicode(self._value))),
             self.handle))
예제 #30
0
파일: details.py 프로젝트: LANJr4D/FRED
 def render(self, indent_level=0):
     self.content = [] # empty previous content (if render would be called moretimes, there would be multiple forms instead one )
     self.add(self.layout_class(self))
     if self.check_nperms():
         # TODO: render error!
         return div("ERROR NO PERMS").render()
         pass
     if not self.is_nested:
         self.add_to_bottom()
     return super(BaseDetail, self).render(indent_level)        
예제 #31
0
 def make_content(self):
     self.content = []
     oid = self._value
     if oid is not None:
         self.add(
             a(
                 attr(href=f_urls[f_enum_name[oid.type]] + u'detail/?id=' +
                      unicode(oid.id)), oid.handle))
     else:
         self.add(div(attr(cssc='field_empty')))
예제 #32
0
파일: listtable.py 프로젝트: LANJr4D/FRED
 def allfilters(self, *args, **kwd):
     context = {'main': div()}
     
     itertable = self._get_itertable('filter')
     itertable.set_filter(
         [{'Type': [False, f_name_id[self.classname]]}])
     itertable.reload()
     context['filters_list'] = FilterListCustomUnpacked(
         itertable.get_rows_dict(raw_header=True), self.classname)
     return self._render('allfilters', context)
예제 #33
0
 def make_content(self):
     self.content = []
     if not self._value:
         self.add(div(attr(cssc='field_empty')))
     else:
         self.add(
             a(
                 attr(href=(f_urls[f_enum_name[ccReg.FT_FILE]] +
                            u'detail/?id=' + unicode(self._value))),
                 self.handle))
예제 #34
0
 def render(self, indent_level=0):
     self.content = [
     ]  # empty previous content (if render would be called moretimes, there would be multiple forms instead one )
     self.add(self.layout_class(self))
     if self.check_nperms():
         # TODO: render error!
         return div("ERROR NO PERMS").render()
         pass
     if not self.is_nested:
         self.add_to_bottom()
     return super(BaseDetail, self).render(indent_level)
예제 #35
0
 def add_to_bottom(self):
     if not cherrypy.session['user'].check_nperms(
             'printout.%s' % self.get_object_name()):
         self.add(
             div(
                 attr(id='printout-form'),
                 h2(_('Generate record statement')),
                 ObjectPrintoutForm(
                     action=f_urls[self.get_object_name()] +
                     'printout/%s/' %
                     self.data.get('handle', self.data.get('fqdn')))))
     super(ObjectDetail, self).add_to_bottom()
예제 #36
0
    def make_content(self):
        self.content = []

        if self.object_type_name is None:  # this cannot be in constructor, becouse self.owner_detail is not known at construction time
            self.object_type_name = self.owner_detail.get_object_name()

        if self.value[self.handle_name] == '':
            self.add(div(attr(cssc='field_empty')))
        self.add(
            a(
                attr(href=f_urls[self.object_type_name] +
                     'detail/?id=%s' % self.value[self.id_name]),
                self.value[self.handle_name]))
예제 #37
0
    def _update_registrar(self, registrar, log_request_name, action_is_edit,
                          *params, **kwd):
        """ Handles the actual updating/creating of a registrar.
        
            Note that we have to "glue" the registrar initial form data 
            together. This is unfortunate, but it's caused by the design 
            of IDL.

            Args:
                registrar:
                    The ccReg.AdminRegistrar object that is being updated or
                    created.
                log_request_name:
                    The type of log request that keeps log of this event.
                action_is_edit:
                    True iff we are editing an already existing registrar.
                    false iff we are creating a new one.
        """
        context = {'main': div()}
        reg_data_form_class = self._get_editform_class()
        reg_data_initial = registrar.__dict__
        initial = reg_data_initial
        if action_is_edit:
            # Only append groups and certifications when we're editing an
            # already existing registrar (there are none for a new registrar).
            group_mgr = cherrypy.session['Admin'].getGroupManager()
            groups = self._get_groups_for_reg_id(int(kwd.get('id')))
            initial['groups'] = recoder.c2u(groups)
            certs = self._get_certifications_for_reg_id(int(kwd.get('id')))
            initial['certifications'] = recoder.c2u(certs)

        if cherrypy.request.method == 'POST':
            form = reg_data_form_class(kwd, initial=initial, method='post')
            if form.is_valid():
                # Create the log request only after the user has clicked on
                # "save" (we only care about contacting the server, not about
                # user entering the edit page).

                context = self._process_valid_form(form, registrar,
                                                   kwd.get('id'), context,
                                                   log_request_name)
                return context
            else:
                if config.debug:
                    context['main'].add('Form is not valid! Errors: %s' %
                                        repr(form.errors))
        else:
            form = reg_data_form_class(method='post', initial=initial)

        context['form'] = form
        return context
예제 #38
0
파일: dfields.py 프로젝트: LANJr4D/FRED
    def __init__(self, name='', label=None, nperm=None, *content, **kwd):
        super(DField, self).__init__(*content, **kwd)
        self.tag = ''
        self.name = name
        self.label = label
        self._nperm = nperm
        self.owner_form = None
        self._value = fredtypes.Null() #None
        self.access = True # if user have nperm for this field, then this will be set to False in Detail.build_fields()
        self.no_access_content = div(attr(cssc='no_access'), _('CENSORED'))

        # Increase the creation counter, and save our local copy.
        self.creation_counter = DField.creation_counter
        DField.creation_counter += 1
예제 #39
0
    def __init__(self, name='', label=None, nperm=None, *content, **kwd):
        super(DField, self).__init__(*content, **kwd)
        self.tag = ''
        self.name = name
        self.label = label
        self._nperm = nperm
        self.owner_form = None
        self._value = fredtypes.Null()  #None
        self.access = True  # if user have nperm for this field, then this will be set to False in Detail.build_fields()
        self.no_access_content = div(attr(cssc='no_access'), _('CENSORED'))

        # Increase the creation counter, and save our local copy.
        self.creation_counter = DField.creation_counter
        DField.creation_counter += 1
예제 #40
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')))
예제 #41
0
파일: adif.py 프로젝트: LANJr4D/FRED
    def _update_registrar(self, registrar, log_request_name, action_is_edit, *params, **kwd):
        """ Handles the actual updating/creating of a registrar.
        
            Note that we have to "glue" the registrar initial form data 
            together. This is unfortunate, but it's caused by the design 
            of IDL.

            Args:
                registrar:
                    The ccReg.AdminRegistrar object that is being updated or
                    created.
                log_request_name:
                    The type of log request that keeps log of this event.
                action_is_edit:
                    True iff we are editing an already existing registrar.
                    false iff we are creating a new one.
        """
        context = {'main': div()}
        reg_data_form_class = self._get_editform_class()
        reg_data_initial = registrar.__dict__
        initial = reg_data_initial
        if action_is_edit:
            # Only append groups and certifications when we're editing an
            # already existing registrar (there are none for a new registrar).
            group_mgr = cherrypy.session['Admin'].getGroupManager()
            groups = self._get_groups_for_reg_id(int(kwd.get('id')))
            initial['groups'] = recoder.c2u(groups)
            certs = self._get_certifications_for_reg_id(int(kwd.get('id')))
            initial['certifications'] = recoder.c2u(certs)

        if cherrypy.request.method == 'POST':
            form = reg_data_form_class(kwd, initial=initial, method='post')
            if form.is_valid():
                # Create the log request only after the user has clicked on
                # "save" (we only care about contacting the server, not about 
                # user entering the edit page).

                context = self._process_valid_form(
                    form, registrar, kwd.get('id'), context, log_request_name)
                return context
            else:
                if config.debug:
                    context['main'].add(
                        'Form is not valid! Errors: %s' % repr(form.errors))
        else:
            form = reg_data_form_class(method='post', initial=initial)

        context['form'] = form
        return context
예제 #42
0
파일: formlayouts.py 프로젝트: saimir/FRED
 def layout_start(self):
     section_name = self.section_spec[0]
     section_id = self.section_spec[1]
     link_id = "%s_display" % section_id
     if section_name:
         self.add(legend(section_name))
     self.add(div(
         attr(style="text-align: right; padding-right: 1em;"),
         a(
             "hide", 
             attr(href="JavaScript:void();"), 
             onclick="show_hide('%s', '%s');" % (section_id, link_id),
             id=link_id, 
             title="Click to show or hide the fieldset contents.")))
     self.add(table(
         tagid('table'), attr(cssc="form_table"), id=section_id))
예제 #43
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')))
예제 #44
0
        def _wrapper(*args, **kwd):
            user = cherrypy.session.get('user', None)
            if user:
                if not user.check_nperms(nperms, nperm_type):
                    return view_func(*args, **kwd)
                else:
                    context = {'main': div()}
                    context['main'].add(
                        p(_("You don't have permissions for this page!")))
                    if fred.config.debug:
                        context['main'].add(
                            p('nperms=%s, nperm_type=%s' %
                              (nperms, nperm_type)))
                    return BaseSiteMenu(context).render()

            redir_addr = '/login/?next=%s' % get_current_url(cherrypy.request)
            raise cherrypy.HTTPRedirect(redir_addr)
예제 #45
0
파일: perms.py 프로젝트: LANJr4D/FRED
        def _wrapper(*args, **kwd):
            user = cherrypy.session.get('user', None)
            if user:
                if not user.check_nperms(nperms, nperm_type):
                    return view_func(*args, **kwd)
                else:
                    context = {'main': div()}
                    context['main'].add(
                        p(_("You don't have permissions for this page!")))
                    if fred.config.debug:
                        context['main'].add(
                            p('nperms=%s, nperm_type=%s' % (
                                nperms, nperm_type)))
                    return BaseSiteMenu(context).render()

            redir_addr = '/login/?next=%s' % get_current_url(cherrypy.request)
            raise cherrypy.HTTPRedirect(redir_addr)
예제 #46
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')))
예제 #47
0
파일: adif.py 프로젝트: LANJr4D/FRED
 def index(self, *args, **kwargs):
     context = {'main': div()}
     reg_mgr = cherrypy.session['Admin'].getGroupManager()
     corba_groups = reg_mgr.getGroups()
     groups = recoder.c2u(corba_groups)
     active_groups = [group for group in groups if not group.cancelled]
     initial = {"groups": active_groups}
     if cherrypy.request.method == 'POST':
         form = GroupManagerEditForm(kwargs, initial=initial, method='post')
         if form.is_valid():
             context = self._process_valid_form(form, context)
         else:
             context['form'] = form
     else:
         form = GroupManagerEditForm(initial=initial, method='post')
         context['form'] = form
     res = self._render(action="edit", ctx=context)
     return res
예제 #48
0
 def __init__(self, context = None):
     super(BaseSiteMenu, self).__init__(context)
     c = self.context
     if c.has_key('menu'):
         self.menu_container.add(div(attr(id='main-menu'), c.menu))
     if c.get('body_id'):
         self.body.add(attr(id=c.body_id))
     if c.get('headline'):
         self.main.add(h1(c.headline))
     self.right_menu_container.add(
         input(save(self, 'history_checkbox'),
               attr(media_files=['/js/history_button.js', '/js/ext/ext-base.js', '/js/ext/ext-all.js'],
                    id='history_checkbox', 
                    type='checkbox', onchange='setHistory(this)')), 
               label(attr(for_id='history_checkbox'), _('history'))
     )
     if c.history:
         self.history_checkbox.checked = ['', 'checked'][c.history]
예제 #49
0
 def index(self, *args, **kwargs):
     context = {'main': div()}
     reg_mgr = cherrypy.session['Admin'].getGroupManager()
     corba_groups = reg_mgr.getGroups()
     groups = recoder.c2u(corba_groups)
     active_groups = [group for group in groups if not group.cancelled]
     initial = {"groups": active_groups}
     if cherrypy.request.method == 'POST':
         form = GroupManagerEditForm(kwargs, initial=initial, method='post')
         if form.is_valid():
             context = self._process_valid_form(form, context)
         else:
             context['form'] = form
     else:
         form = GroupManagerEditForm(initial=initial, method='post')
         context['form'] = form
     res = self._render(action="edit", ctx=context)
     return res
예제 #50
0
 def __init__(self, context = None):
     if context.get('doctype') is None:
         context['doctype'] = 'xhtml10strict'
     super(BaseTemplate, self).__init__(context)
     self.add_media_files('/css/base.css')
     self.body.add(div(attr(id='container'),
                       save(self, 'container'),
                       div(attr(id='header'), save(self, 'header')),
                       div(attr(id='content_all'), save(self, 'content_all'), #cannot be "content", because of content attribute of gpyweb widgets
                           div(attr(id='columnwrap'), save(self, 'columnwrap'),
                               div(attr(id='content-main'), save(self, 'main')))),
                       div(attr(id='footer'), save(self, 'footer'))
                       ))
예제 #51
0
파일: dfields.py 프로젝트: LANJr4D/FRED
 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)
예제 #52
0
파일: exposed.py 프로젝트: LANJr4D/FRED
def catch_webadmin_exceptions_decorator(view_func):
    ''' This decorator is applicated to all view methods of website,
        it catches some permission as PermissionDeniedError'''
    def _wrapper(*args, **kwd):
        self = args[0]
        try:
            return view_func(*args, **kwd)
        except CorbaServerDisconnectedException, e:
            self._remove_session_data()
            return self._render('disconnected')
        except CORBA.TRANSIENT, e:
            error("BACKEND IS NOT RUNNING")
            context = {'message': div()}
            if config.debug:
                context['message'].add(p('''Congratulations! Prave se vam '''
                '''(nebo nekomu pred vami) povedlo shodit backend server, '''
                '''pripiste si plusovy bod!'''))
            else:
                context['message'].add(
                    p(_('Error: Backend server is not running!')))
            context['message'].add(
                pre(attr( id='traceback'), traceback.format_exc()))    
            return self._render('error', context)
예제 #53
0
 def get_submit_row(self):
     return div(input(attr(type=u'submit', value=u'Save set', name=u'submit')))