Esempio n. 1
0
    def __init__(self, filters, filter_name=None, *content, **kwd):
        ''' Filters is list of triplets [id, type, name]
            If filter_name is specified, general filter for that object is added (e.g. /domains/filter/)
        '''
        ul.__init__(self, *content, **kwd)
        self.tag = 'ul'
        debug('LIST OF FILTERS(unpacked): %s' % filters)
        for obj_filter in filters:
            url_filter = f_urls[f_id_name[int(
                obj_filter['Type'])]] + 'filter/?filter_id=' + obj_filter['Id']
            url_filter_with_form = url_filter + '&show_form=1'
            filter_form = self.get_form(obj_filter)
            self.add(
                li(a(attr(href=url_filter), obj_filter['Name']), ' (',
                   a(attr(href=url_filter_with_form), _('form')), ')',
                   filter_form))
        if filter_name:
            self.add(
                li(
                    a(attr(href=f_urls[filter_name] + 'filter/'),
                      _('Custom filter'))))

        self.add(
            script(attr(type='text/javascript'),
                   'Ext.onReady(function () {addFieldsButtons()})'))
Esempio n. 2
0
 def __init__(self, filters, filter_name=None, *content, **kwd):
     ''' Filters is list of triplets [id, type, name] 
         If filter_name is specified, general filter for that object is added (e.g. /domains/filter/)
     '''
     ul.__init__(self, *content, **kwd)
     self.tag = 'ul'
     debug('LIST OF FILTERS(unpacked): %s' % filters)
     
     custom_presented = False
     for filter in filters:
         url_filter = f_urls[f_id_name[int(filter['Type'])]] + 'filter/?filter_id=' + filter['Id']
         url_filter_with_form =  url_filter + '&show_form=1'
         if filter['Name'].lower() == 'custom':
             form = self.get_form(filter)
             custom_presented = True
         else:
             form = None
         self.add(li(
                     a(attr(href=url_filter), filter['Name']),
                     ' (', a(attr(href=url_filter_with_form), _('form')),  ')',
                     form))
     if not custom_presented and filter_name:
         self.add(li(a(attr(href=f_urls[filter_name] + 'filter/'), _('Custom filter')),
                     self.get_default_form(filter_name)
                    ))
         
     self.add(script(attr(type='text/javascript'), 'Ext.onReady(function () {addFieldsButtons()})')) 
Esempio n. 3
0
    def __init__(self, filters, max_row_size=5, *content, **kwd):
        ''' filters is list of lists (sections) of filters (tripplet [button_label, object_name, filters] where
            filters in linear form (e.g. [{'domain.registrar.handle'='ahoj', 'handle'=[True, 'ahoj']}]
            (True is for negation)) (so if there is negation, then value is list [negation, value], otherwise it is
            just a value).
            Alternatively, instead of filter (which is a triplet), can be used direct link (couple):
            [button_label, url], or just one object in list which is added directly (e.g. any content like a Form)
        '''
        super(FilterPanel, self).__init__(*content, **kwd)
        self.tag = 'div'

        #        chunks = grouper(max_row_size, filters)
        first = True
        filter_count = max([len(l) for l in filters])

        for chunk in filters:
            filter_count = len(chunk)
            tbl = table()
            tbl.add(
                attr(cssc='filter_panel'),
                tr(
                    th(attr(colspan=filter_count),
                       b(_('Options')) if first else b())),
                tr(save(self, 'filter_buttons')))
            self._create_links(chunk)
            self.add(tbl)
            first = False
        """for button_data in filters:
Esempio n. 4
0
    def __init__(self, filters, max_row_size=5, *content, **kwd):
        ''' filters is list of tripplet [button_label, object_name, filters] where filters in linear form. written
            (e.g. [{'domain.registrar.handle'='ahoj', 'handle'=[True, 'ahoj']}] (True is for negation))
            (so if there is negation, then value is list [value, negation], otherwise it is just value)
            Alternatively, instead of filter (which is a triplet), can be used direct link (couple):
            [button_label, url]
        '''
        super(FilterPanel, self).__init__(*content, **kwd)
        self.tag = 'div'

#        chunks = grouper(max_row_size, filters)
        first = True
#        import ipdb; ipdb.set_trace()
        filter_count = max([len(l) for l in filters])

        for chunk in filters:
            filter_count = len(chunk)
            tbl = table()
            tbl.add(attr(cssc='filter_panel'),
                 tr(th(
                    attr(colspan=filter_count), 
                    b(_('Options')) if first else b())),
                 tr(save(self, 'filter_buttons')))
            self._create_links(chunk)
            self.add(tbl)
            first = False

        """for button_data in filters:
Esempio n. 5
0
File: menu.py Progetto: saimir/FRED
    def create_menu_tree(self):
        self.add(ul(tagid('_menu1')))
        for menu in self.menutree.submenus:
            if self.user.check_nperms(menu.nperm, menu.nperm_type):
                continue  # user has negative permission for this menu -> don't display it

            menu_open = menu in self.open_nodes
            cssc = menu.cssc
            #            disabled = menu.disabled

            if menu_open:
                cssc += ' selected-menu'
                #                if disabled:
                #                    cssc += ' disabled-menu'
                if menu.submenus:
                    self.submenu = MenuHoriz(menu, self.selected_menu_handle,
                                             self.user)

            url = self.get_url(menu)

            self._menu1.add(
                li(attr(cssc=cssc), a(attr(href=url), menu.caption)))
        self.add(div(attr(cssc='cleaner'), ''))
        if self.submenu:
            self.add(
                div(attr(cssc='submenu'), self.submenu,
                    div(attr(cssc='cleaner'), '')))
Esempio n. 6
0
 def __init__(self, filters, filter_name=None, *content, **kwd):
     ''' Filters is list of triplets [id, type, name] 
         If filter_name is specified, general filter for that object is added (e.g. /domains/filter/)
     '''
     super(FilterList, self).__init__(*content, **kwd)
     self.tag = 'ul'
     debug('LIST OF FILTERS: %s' % filters)
     for filter in filters:
         url_filter = f_urls[f_id_name[int(filter['Type'])]] + 'filter/?filter_id=' + filter['Id']
         url_filter_with_form =  url_filter + '&show_form=1'
         self.add(li(
                     a(attr(href=url_filter), filter['Name']),
                     ' (', a(attr(href=url_filter_with_form), _('form')),  ')',
                    ))
     if filter_name:
         self.add(li(a(attr(href=f_urls[filter_name] + 'filter/'), _('Custom filter'))))
Esempio n. 7
0
    def create_menu_tree(self):
        for menu in self.menutree.submenus:
            if self.user.check_nperms(menu.nperm, menu.nperm_type):
                continue  # user has negative permission for this menu -> don't display it

            menu_open = menu in self.open_nodes
            cssc = menu.cssc

            submenu = None
            if menu_open:
                cssc += ' selected-menu'
                if menu.submenus:
                    submenu = Menu(menu, self.selected_menu_handle, self.user)

            url = self.get_url(menu)

            self.add(
                li(attr(cssc=cssc), a(attr(href=url), menu.caption), submenu))
Esempio n. 8
0
File: menu.py Progetto: LANJr4D/FRED
    def create_menu_tree(self):
        for menu in self.menutree.submenus:
            if self.user.check_nperms(menu.nperm, menu.nperm_type):
                continue # user has negative permission for this menu -> don't display it
                
                
            menu_open = menu in self.open_nodes
            cssc = menu.cssc
                
            submenu = None
            if menu_open:
                cssc += ' selected-menu'
                if menu.submenus:
                    submenu = Menu(menu, self.selected_menu_handle, self.user)
            
            url = self.get_url(menu)

            self.add(li(attr(cssc=cssc), a(attr(href=url), menu.caption), submenu))
Esempio n. 9
0
 def _create_links(self, filters):
     for button_data in filters:
         if len(button_data) == 2:
             button_label, url = button_data
             self.filter_buttons.add(
                 td(a(attr(href = url), _(button_label))))
         elif len(button_data) == 3:
             button_label, obj_name, filter = button_data
             self.filter_buttons.add(
                 td(form(
                     attr(
                         action=f_urls[obj_name] + 'filter/', 
                         method='POST'),
                     textarea(
                         attr(
                             style='display: none', 
                             name='json_linear_filter'),
                         simplejson.dumps(filter)),
                     input(attr(type='submit', value=_(button_label))))))
Esempio n. 10
0
File: menu.py Progetto: LANJr4D/FRED
    def create_menu_tree(self):
        self.add(ul(tagid('_menu1')))
        for menu in self.menutree.submenus:
            if self.user.check_nperms(menu.nperm, menu.nperm_type):
                continue # user has negative permission for this menu -> don't display it

            menu_open = menu in self.open_nodes
            cssc = menu.cssc
#            disabled = menu.disabled
                
            if menu_open:
                cssc += ' selected-menu'
#                if disabled:
#                    cssc += ' disabled-menu'
                if menu.submenus:
                    self.submenu = MenuHoriz(menu, self.selected_menu_handle, self.user)
            
            url = self.get_url(menu)
            
            self._menu1.add(li(attr(cssc=cssc), a(attr(href=url), menu.caption)))
        self.add(div(attr(cssc='cleaner'), ''))
        if self.submenu:
            self.add(div(attr(cssc='submenu'), self.submenu, div(attr(cssc='cleaner'), '')))