def distro(self, **kw): activities = DistroActivity.all() activity_search = search_utility.DistroActivity.search search_bar = SearchBar(activity_search.create_complete_search_table(), name='activitysearch',) return self._activities_grid(activities, search_bar, 'distro', search_utility.DistroActivity, title='Distro Activity', **kw)
def index(self, *args, **kw): tasks = Task.query # FIXME What we really want is some default search options # For now we won't show deleted/invalid tasks in the grid # but for data integrity reasons we will allow you to view # the task directly. Ideally we would have a default search # option of valid=True which the user could change to false # to see all "deleted" tasks tasks = tasks.filter(Task.valid == True) tasks_return = self._tasks(tasks, **kw) searchvalue = None search_options = {} if tasks_return: if 'tasks_found' in tasks_return: tasks = tasks_return['tasks_found'] if 'searchvalue' in tasks_return: searchvalue = tasks_return['searchvalue'] if 'simplesearch' in tasks_return: search_options['simplesearch'] = tasks_return['simplesearch'] tasks_grid = myPaginateDataGrid(fields=[ widgets.PaginateDataGrid.Column( name='name', getter=lambda x: make_link("./%s" % x.id, x.name), title='Name', options=dict(sortable=True)), widgets.PaginateDataGrid.Column(name='description', getter=lambda x: x.description, title='Description', options=dict(sortable=True)), widgets.PaginateDataGrid.Column(name='version', getter=lambda x: x.version, title='Version', options=dict(sortable=True)), widgets.PaginateDataGrid.Column( name='action', getter=lambda x: self.task_list_action_widget.display( task=x, type_='tasklist', title='Action', options=dict(sortable=False))), ]) search_bar = SearchBar( name='tasksearch', label=_(u'Task Search'), table=search_utility.Task.search.create_complete_search_table(), search_controller=url("/get_search_options_task"), ) return dict( title="Task Library", grid=tasks_grid, list=tasks, search_bar=search_bar, action='.', action_widget=self. task_list_action_widget, #Hack,inserts JS for us. options=search_options, searchvalue=searchvalue)
def index(self, **kw): activities = Activity.all() activity_search = search_utility.Activity.search search_bar = SearchBar(activity_search.create_complete_search_table(), name='activitysearch',) return self._activities_grid(activities, search_bar, '.', search_utility.Activity, **kw)
def system(self, **kw): activities = SystemActivity.all() activity_search = search_utility.SystemActivity.search search_bar = SearchBar(activity_search.create_complete_search_table(), name='activitysearch',) return self._activities_grid(activities, search_bar, 'system', search_utility.SystemActivity, title='System Activity', **kw)
def group(self, **kw): activities = GroupActivity.all() activity_search = search_utility.GroupActivity.search search_bar = SearchBar(activity_search.create_complete_search_table(), name='activitysearch',) return self._activities_grid(activities, search_bar, 'group', search_utility.GroupActivity, title='Group Activity', **kw)
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 labcontroller(self, **kw): activities = LabControllerActivity.all() activity_search = search_utility.LabControllerActivity.search search_bar = SearchBar(activity_search.create_complete_search_table(), name='activitysearch',) return self._activities_grid(activities, search_bar, 'labcontroller', search_utility.LabControllerActivity, title='Lab Controller Activity', **kw)
def recipes(self,recipes,action='.',*args, **kw): recipes = recipes.join(Recipe.recipeset)\ .join(RecipeSet.job)\ .filter(not_(Job.is_deleted)) recipes_return = self._recipes(recipes,**kw) searchvalue = None search_options = {} if recipes_return: if 'recipes_found' in recipes_return: recipes = recipes_return['recipes_found'] if 'searchvalue' in recipes_return: searchvalue = recipes_return['searchvalue'] if 'simplesearch' in recipes_return: search_options['simplesearch'] = recipes_return['simplesearch'] PDC = widgets.PaginateDataGrid.Column recipes_grid = myPaginateDataGrid( fields=[ PDC(name='id', getter=lambda x:make_link(url='./%s' % x.id, text=x.t_id), title='ID', options=dict(sortable=True)), PDC(name='whiteboard', getter=lambda x:x.whiteboard, title='Whiteboard', options=dict(sortable=True)), PDC(name='distro_tree.arch.arch', getter=lambda x:x.arch, title='Arch', options=dict(sortable=True)), PDC(name='resource.fqdn', getter=lambda x: x.resource and x.resource.link, title='System', options=dict(sortable=True)), PDC(name='distro_tree.distro.name', getter=lambda x: x.distro_tree and x.distro_tree.link, title='Distro Tree', options=dict(sortable=False)), PDC(name='progress', getter=lambda x: x.progress_bar, title='Progress', options=dict(sortable=False)), PDC(name='status', getter=_custom_status, title='Status', options=dict(sortable=True)), PDC(name='result', getter=_custom_result, title='Result', options=dict(sortable=True)), PDC(name='action', getter=lambda x:self.action_cell(x), title='Action', options=dict(sortable=False)),]) search_bar = SearchBar(name='recipesearch', label=_(u'Recipe Search'), simplesearch_label = 'Lookup ID', table = search_utility.Recipe.search.create_complete_search_table(), search_controller=url("/get_search_options_recipe"), quick_searches = [('Status-is-Queued','Queued'),('Status-is-Running','Running'),('Status-is-Completed','Completed')]) return dict(title="Recipes", grid=recipes_grid, list=recipes, search_bar=search_bar, action=action, options=search_options, searchvalue=searchvalue)
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)
def reserve(self, action='.', *args, **kw): searchvalue = None reserves = System.all(identity.current.user).join('open_reservation')\ .options(contains_eager(System.open_reservation)) reserves_return = self._reserves(reserves, **kw) search_options = {} if reserves_return: if 'reserves_found' in reserves_return: reserves = reserves_return['reserves_found'] if 'searchvalue' in reserves_return: searchvalue = reserves_return['searchvalue'] if 'simplesearch' in reserves_return: search_options['simplesearch'] = reserves_return['simplesearch'] search_bar = SearchBar(name='reservesearch', label=_(u'Reserve Search'), table = search_utility.SystemReserve.search.create_complete_search_table(), search_controller=url("./get_search_options_reserve"), ) reservations = [system.open_reservation for system in reserves] reserve_grid = myPaginateDataGrid(fields=[ widgets.PaginateDataGrid.Column(name='system.fqdn', getter=lambda x: make_link(url = '/view/%s' % x.system.fqdn, text = x.system), title=u'System', options=dict(sortable=True)), widgets.PaginateDataGrid.Column(name='start_time', getter=lambda x: x.start_time, title=u'Reserved Since', options=dict(sortable=True, datetime=True)), widgets.PaginateDataGrid.Column(name='user', getter=lambda x: x.user, title=u'Current User', options=dict(sortable=True)), ]) return dict(title=u"Reserve Report", grid = reserve_grid, search_bar = search_bar, options = search_options, action=action, searchvalue = searchvalue, list=reservations)
def jobs(self, jobs, action='.', title=u'Jobs', *args, **kw): jobs = jobs.filter(and_(Job.deleted == None, Job.to_delete == None)) jobs_return = self._jobs(jobs, **kw) searchvalue = None search_options = {} if jobs_return: if 'jobs_found' in jobs_return: jobs = jobs_return['jobs_found'] if 'searchvalue' in jobs_return: searchvalue = jobs_return['searchvalue'] if 'simplesearch' in jobs_return: search_options['simplesearch'] = jobs_return['simplesearch'] def get_group(x): if x.group: return make_link(url='../groups/edit?group_id=%d' % x.group.group_id, text=x.group.group_name) else: return None PDC = widgets.PaginateDataGrid.Column jobs_grid = myPaginateDataGrid( fields=[ PDC(name='id', getter=lambda x:make_link(url = './%s' % x.id, text = x.t_id), title='ID', options=dict(sortable=True)), PDC(name='whiteboard', getter=lambda x:x.whiteboard, title='Whiteboard', options=dict(sortable=True)), PDC(name='group', getter=get_group, title='Group', options=dict(sortable=True)), PDC(name='owner', getter=lambda x:x.owner.email_link, title='Owner', options=dict(sortable=True)), PDC(name='progress', getter=lambda x: x.progress_bar, title='Progress', options=dict(sortable=False)), PDC(name='status', getter= _custom_status, title='Status', options=dict(sortable=True)), PDC(name='result', getter=_custom_result, title='Result', options=dict(sortable=True)), PDC(name='action', getter=lambda x: \ self.job_list_action_widget.display( task=x, type_='joblist', delete_action=url('/jobs/delete_job_row'), export=url('/to_xml?taskid=%s' % x.t_id), title='Action', options=dict(sortable=False)))]) search_bar = SearchBar( name='jobsearch', label=_(u'Job Search'), simplesearch_label='Lookup ID', table=search_utility.Job.search.create_complete_search_table( without=('Owner')), search_controller=url("/get_search_options_job"), quick_searches=[('Status-is-Queued', 'Queued'), ('Status-is-Running', 'Running'), ('Status-is-Completed', 'Completed')]) return dict( title=title, grid=jobs_grid, list=jobs, action_widget=self. job_list_action_widget, #Hack,inserts JS for us. search_bar=search_bar, action=action, options=search_options, searchvalue=searchvalue)