def tags(self, tags=None, user=None, *args, **kw): if tags is None: tags = Tag.get_all() def show_delete(x): if x.can_delete(): return XML('<a class="btn" href="./delete/%s">' '<i class="fa fa-times"/> Delete</a>' % x.id) else: return None def show_tag(x): if x.is_default: #If we are the default, we can't change to not default return x.tag elif user and user.is_admin(): return make_edit_link(x.tag,x.id) else: #no perms to edit return x.tag my_fields = [myPaginateDataGrid.Column(name='tag', title='Tags', getter=lambda x: show_tag(x),options=dict(sortable=True)), myPaginateDataGrid.Column(name='default', title='Default', getter=lambda x: x.default,options=dict(sortable=True)), myPaginateDataGrid.Column(name='delete', title='Delete', getter=lambda x: show_delete(x))] tag_grid = myPaginateDataGrid(fields=my_fields, add_action='./new') return_dict = dict(title='Tags', grid = tag_grid, search_bar = None, search_widget = self.search_widget_form, list = tags) return return_dict
def distros(self, distros, action='.', *args, **kw): distros_return = self._distros(distros, **kw) searchvalue = None hidden_fields = None search_options = {} if distros_return: if 'distros_found' in distros_return: distros = distros_return['distros_found'] if 'searchvalue' in distros_return: searchvalue = distros_return['searchvalue'] if 'simplesearch' in distros_return: search_options['simplesearch'] = distros_return['simplesearch'] distros_grid = myPaginateDataGrid(fields=[ myPaginateDataGrid.Column( name='id', getter=lambda x: make_link(url='/distros/view?id=%s' % x.id, text=x.id), title='ID', options=dict(sortable=True)), myPaginateDataGrid.Column( name='name', getter=lambda x: make_link(url='/distros/view?id=%s' % x.id, text=x.name), title='Name', options=dict(sortable=True)), myPaginateDataGrid.Column(name='osversion.osmajor.osmajor', getter=lambda x: x.osversion.osmajor, title='OS Major Version', options=dict(sortable=True)), myPaginateDataGrid.Column(name='osversion.osminor', getter=lambda x: x.osversion.osminor, title='OS Minor Version', options=dict(sortable=True)), myPaginateDataGrid.Column(name='date_created', getter=lambda x: x.date_created, title='Date Created', options=dict(sortable=True, datetime=True)), ]) if 'tag' in kw: hidden_fields = [('tag', kw['tag'])] search_bar = SearchBar( name='distrosearch', label=_(u'Distro Search'), table=search_utility.Distro.search.create_complete_search_table(), search_controller=url("/get_search_options_distros"), extra_hiddens=hidden_fields, date_picker=['created']) return dict(title="Distros", grid=distros_grid, search_bar=search_bar, action=action, options=search_options, searchvalue=searchvalue, list=distros)
def index(self,*args,**kw): template_data = self.osversions(*args, **kw) template_data['search_bar'] = None template_data['grid'] = myPaginateDataGrid(fields=[ myPaginateDataGrid.Column(name='osmajor.osmajor', getter=lambda x: x.osmajor, title='OS Major', options=dict(sortable=True)), myPaginateDataGrid.Column(name='osminor', getter=lambda x: x.osminor, title='OS Minor', options=dict(sortable=True)), myPaginateDataGrid.Column(name='arches', getter=lambda x: " ".join([arch.arch for arch in x.arches]), title='Arches', options=dict(sortable=True)), ]) return template_data
def osversions(self, osversions=None, *args, **kw): q = session.query(self.search_mapper) # This line +3 dupes the start of process_search if osversions is None: for j in self.join: q = q.join(j) osversions = q osversions_grid = myPaginateDataGrid(fields=[ myPaginateDataGrid.Column(name='osmajor.osmajor', getter=lambda x: make_link(url = './edit_osmajor?id=%s' % x.osmajor.id, text = x.osmajor), title='OS Major', options=dict(sortable=True)), myPaginateDataGrid.Column(name='osmajor.alias', getter=lambda x: x.osmajor.alias, title='Alias', options=dict(sortable=True)), myPaginateDataGrid.Column(name='osminor', getter=lambda x: make_link(url = './edit?id=%s' % x.id, text = x.osminor), title='OS Minor', options=dict(sortable=True)), myPaginateDataGrid.Column(name='arches', getter=lambda x: " ".join([arch.arch for arch in x.arches]), title='Arches', options=dict(sortable=True)), ]) return dict(title="OS Versions", grid = osversions_grid, addable = False, list = osversions)
def index(self, **kwargs): query = DistroTree.query.join(DistroTree.distro, Distro.osversion, OSVersion.osmajor)\ .filter(DistroTree.lab_controller_assocs.any()) options = {} if 'simplesearch' in kwargs: kwargs['search'] = [{'table': 'Name', 'operation': 'contains', 'value': kwargs['simplesearch']}] options['simplesearch'] = kwargs['simplesearch'] if 'search' in kwargs: search = search_utility.DistroTree.search(query) for row in kwargs['search']: search.append_results(row['value'], row['table'], row['operation']) query = search.return_results() grid = myPaginateDataGrid(fields=[ myPaginateDataGrid.Column(name='id', title=u'ID', getter=lambda x: make_link(url=str(x.id), text=str(x.id)), options=dict(sortable=True)), myPaginateDataGrid.Column(name='distro.name', title=u'Distro', getter=lambda x: x.distro.link, options=dict(sortable=True)), myPaginateDataGrid.Column(name='variant', title=u'Variant', options=dict(sortable=True)), myPaginateDataGrid.Column(name='arch.arch', title=u'Arch', options=dict(sortable=True)), myPaginateDataGrid.Column(name='distro.osversion.osmajor.osmajor', title=u'OS Major Version', options=dict(sortable=True)), myPaginateDataGrid.Column(name='distro.osversion.osminor', title=u'OS Minor Version', options=dict(sortable=True)), myPaginateDataGrid.Column(name='date_created', title=u'Date Created', options=dict(sortable=True, datetime=True)), Utility.direct_column(title=u'Provision', getter=self._provision_system_link), ]) search_bar = SearchBar(name='search', label=_(u'Distro Tree Search'), table=search_utility.DistroTree.search.create_complete_search_table(), search_controller=None, date_picker=['created'], ) return dict(title=u'Distro Trees', action='.', grid=grid, search_bar=search_bar, searchvalue=kwargs.get('search'), options=options, list=query)