Esempio n. 1
0
    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)
Esempio n. 2
0
 def _provision_system_link(self, distro_tree):
     div = Element('div')
     div.append(make_link('/reserve_system?distro_tree_id=%s'
             % distro_tree.id, 'Pick System'))
     div.append(Element('br'))
     div.append(make_link('/reserveworkflow/reserve?distro_tree_id=%s'
             % distro_tree.id, 'Pick Any System'))
     return div
Esempio n. 3
0
    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)
Esempio n. 4
0
    def groups(self, groups=None, *args,**kw):
        if groups is None:
            groups = session.query(Group)

        def get_remove_link(x):
            try:
                if x.can_edit(identity.current.user) and not x.is_protected_group():
                    return self.delete_link.display(dict(group_id=x.group_id),
                                             action=url('remove'),
                                             action_text='Delete Group')
                else:
                    return ''
            except AttributeError:
                return ''

        group_name = ('Group Name', lambda group: make_link(
                'edit?group_id=%s' % group.group_id, group.group_name))
        display_name = ('Display Name', lambda x: x.display_name)
        remove_link = ('', get_remove_link)

        grid_fields =  [group_name, display_name, remove_link]
        grid = myPaginateDataGrid(fields=grid_fields,
                add_action='./new' if not identity.current.anonymous else None)
        return_dict = dict(title=u"Groups",
                           grid=grid,
                           search_bar = None,
                           search_widget = self.search_widget_form,
                           list = groups)
        return return_dict
Esempio n. 5
0
    def groups(self, groups=None, *args, **kw):
        if groups is None:
            groups = session.query(Group)

        def get_remove_link(x):
            try:
                if x.can_edit(
                        identity.current.user) and not x.is_protected_group():
                    return self.delete_link.display(dict(group_id=x.group_id),
                                                    action=url('remove'),
                                                    action_text='Delete Group')
                else:
                    return ''
            except AttributeError:
                return ''

        group_name = ('Group Name', lambda group: make_link(
            'edit?group_id=%s' % group.group_id, group.group_name))
        display_name = ('Display Name', lambda x: x.display_name)
        remove_link = ('', get_remove_link)

        grid_fields = [group_name, display_name, remove_link]
        grid = myPaginateDataGrid(
            fields=grid_fields,
            add_action='./new' if not identity.current.anonymous else None)
        return_dict = dict(title=u"Groups",
                           grid=grid,
                           search_bar=None,
                           search_widget=self.search_widget_form,
                           list=groups)
        return return_dict
Esempio n. 6
0
 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
Esempio n. 7
0
    def recipes(self,recipes,action='.',*args, **kw):
        recipes = recipes.filter(Recipe.recipeset.has(
            RecipeSet.job.has(and_(
            Job.deleted == None, Job.to_delete == None))))
        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_search_table(),
                           complete_data = 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)
Esempio n. 8
0
 def make_lc_remove_link(self, lc):
     if lc.removed is not None:
         return make_link(url  = 'unremove?id=%s' % lc.id,
             text = 'Re-Add (+)')
     else:
         a = Element('a', {'class': 'list'}, href='#')
         a.text = 'Remove (-)'
         a.attrib.update({'onclick' : "has_watchdog('%s')" % lc.id})
         return a
Esempio n. 9
0
    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)
Esempio n. 10
0
 def get_sys(x):
     systems = System.all(identity.current.user). \
               filter(System.groups.contains(x)). \
               filter(System.status != SystemStatus.removed).all()
     if len(systems):
         return make_link('systems?group_id=%s' % x.group_id,
                          u'System count: %s' % len(systems))
     else:
         return 'System count: 0'
Esempio n. 11
0
    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_search_table(),
                search_controller=None,
                complete_data=search_utility.DistroTree.search.create_complete_search_table(),
                date_picker=['created'],
                )

        return dict(title=u'Distro Trees',
                    action='.',
                    grid=grid,
                    search_bar=search_bar,
                    searchvalue=kwargs.get('search'),
                    options=options,
                    object_count=query.count(),
                    list=query)
Esempio n. 12
0
    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)
Esempio n. 13
0
    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_search_table(), 
                           complete_data = 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)
Esempio n. 14
0
    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_search_table(),
                           complete_data=search_utility.Task.search.create_complete_search_table(),
                           search_controller=url("/get_search_options_task"),
                           )
        return dict(title="Task Library",
                    object_count=tasks.count(),
                    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)
Esempio n. 15
0
    def default(self, id):
        try:
            job = Job.by_id(id)
        except InvalidRequestError:
            flash(_(u"Invalid job id %s" % id))
            redirect(".")

        if job.counts_as_deleted():
            flash(_(u'Invalid %s, has been deleted' % job.t_id))
            redirect(".")

        recipe_set_history = [RecipeSetActivity.query.with_parent(elem,"activity") for elem in job.recipesets]
        recipe_set_data = []
        for query in recipe_set_history:
            for d in query: 
                recipe_set_data.append(d)   
 
        job_history_grid = BeakerDataGrid(fields= [
                               BeakerDataGrid.Column(name='recipeset',
                                                               getter=lambda x: make_link(url='#RS_%s' % x.recipeset_id,text ='RS:%s' % x.recipeset_id), 
                                                               title='RecipeSet', options=dict(sortable=True)), 
                               BeakerDataGrid.Column(name='user', getter= lambda x: x.user, title='User', options=dict(sortable=True)),
                               BeakerDataGrid.Column(name='created', title='Created', getter=lambda x: x.created, options = dict(sortable=True)),
                               BeakerDataGrid.Column(name='field', getter=lambda x: x.field_name, title='Field Name', options=dict(sortable=True)),
                               BeakerDataGrid.Column(name='action', getter=lambda x: x.action, title='Action', options=dict(sortable=True)),
                               BeakerDataGrid.Column(name='old_value', getter=lambda x: x.old_value, title='Old value', options=dict(sortable=True)),
                               BeakerDataGrid.Column(name='new_value', getter=lambda x: x.new_value, title='New value', options=dict(sortable=True)),])

        return_dict = dict(title = 'Job',
                           recipeset_widget = self.recipeset_widget,
                           recipe_widget = self.recipe_widget,
                           hidden_id = widgets.HiddenField(name='job_id',value=job.id),
                           job_history = recipe_set_data,
                           job_history_grid = job_history_grid,
                           whiteboard_widget = self.whiteboard_widget,
                           action_widget = self.job_page_action_widget,
                           delete_action = url('delete_job_page'),
                           job = job,
                           product_widget = self.product_widget,
                           retention_tag_widget = self.retention_tag_widget,
                          )
        return return_dict
Esempio n. 16
0
    def groups(self, groups=None, *args, **kw):
        if groups is None:
            groups = session.query(Group)

        def get_sys(x):
            systems = System.all(identity.current.user). \
                      filter(System.groups.contains(x)). \
                      filter(System.status != SystemStatus.removed).all()
            if len(systems):
                return make_link('systems?group_id=%s' % x.group_id,
                                 u'System count: %s' % len(systems))
            else:
                return 'System count: 0'

        def get_remove_link(x):
            try:
                if x.can_edit(
                        identity.current.user) and not x.is_protected_group():
                    return self.delete_link.display(dict(group_id=x.group_id),
                                                    action=url('remove'),
                                                    action_text='Delete Group')
                else:
                    return ''
            except AttributeError:
                return ''

        group_name = ('Group Name', lambda group: make_link(
            'edit?group_id=%s' % group.group_id, group.group_name))
        systems = ('Systems', get_sys)
        display_name = ('Display Name', lambda x: x.display_name)
        remove_link = ('', get_remove_link)

        grid_fields = [group_name, display_name, systems, remove_link]
        grid = myPaginateDataGrid(
            fields=grid_fields,
            add_action='./new' if not identity.current.anonymous else None)
        return_dict = dict(title=u"Groups",
                           grid=grid,
                           search_bar=None,
                           search_widget=self.search_widget_form,
                           list=groups)
        return return_dict
Esempio n. 17
0
 def index(self, *args, **kw):
     configitems = session.query(ConfigItem)
     list_by_letters = set([elem.name[0].capitalize() for elem in configitems])
     results = self.process_search(**kw)
     if results:
         configitems = results
     configitems_grid = myPaginateDataGrid(fields=[
                               ('Setting', lambda x: make_edit_link(x.name, x.id)),
                               ('Description', lambda x: x.description),
                               ('Current Value', lambda x: x.current_value()),
                               ('Next Value', lambda x: x.next_value() and u'"%s" from %s' % (x.next_value().value, x.next_value().valid_from)),
                               (' ', lambda x: (x.readonly or x.current_value() is None) and " " or
                                     make_link(url='remove?id=%s' % x.id,
                                         elem_class='btn', text='Clear current value')),
                           ])
     return dict(title="Configuration",
                 grid = configitems_grid,
                 alpha_nav_bar = AlphaNavBar(list_by_letters, self.search_name),
                 search_widget = self.search_widget_form,
                 list = configitems)
Esempio n. 18
0
 def index(self, *args, **kw):
     configitems = session.query(ConfigItem)
     list_by_letters = set([elem.name[0].capitalize() for elem in configitems])
     results = self.process_search(**kw)
     if results:
         configitems = results
     configitems_grid = myPaginateDataGrid(fields=[
                               ('Setting', lambda x: make_edit_link(x.name, x.id)),
                               ('Description', lambda x: x.description),
                               ('Current Value', lambda x: x.current_value()),
                               ('Next Value', lambda x: x.next_value() and u'"%s" from %s' % (x.next_value().value, x.next_value().valid_from)),
                               (' ', lambda x: (x.readonly or x.current_value() is None) and " " or
                                     make_link(url='remove?id=%s' % x.id,
                                         elem_class='btn', text='Clear current value')),
                           ])
     return dict(title="Configuration",
                 grid = configitems_grid,
                 alpha_nav_bar = AlphaNavBar(list_by_letters, self.search_name),
                 search_widget = self.search_widget_form,
                 list = configitems)
Esempio n. 19
0
    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)
Esempio n. 20
0
    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)
Esempio n. 21
0
 def index(self):
     tags = session.query(DistroTag)
     tags_grid = widgets.PaginateDataGrid(fields=[
                               widgets.PaginateDataGrid.Column(name='tag', getter=lambda x: make_link(url  = '../distros/tagsearch/?tag=%s' % x.tag,
                               text = x.tag), title='Tag', options=dict(sortable=True)),
                           ])
     return dict(title="Tags", grid = tags_grid,
                                      search_bar = None,
                                      list = tags)
Esempio n. 22
0
 def show_delete(x):
     if x.can_delete():
         return make_link(url='./delete/%s' % x.id, text='Delete')
     else:
         return None
Esempio n. 23
0
 def get_sys(x):
     if len(x.systems):
         return make_link('systems?group_id=%s' % x.group_id, u'System count: %s' % len(x.systems))
     else:
         return 'System count: 0'
Esempio n. 24
0
 def update_params(self, d):
     super(RecipeWidget, self).update_params(d)
     d['recipe_systems'] = \
         make_link(url('../recipes/systems?recipe_id=%d' % d['recipe'].id),
                   d['recipe'].dyn_systems.count())
     d['recipe_status_reserved'] = TaskStatus.reserved
Esempio n. 25
0
 def system_name_getter(cls):
     return lambda x: make_link("/view/%s" % x.fqdn, x.fqdn)
Esempio n. 26
0
    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_search_table(without=('Owner')),
                           complete_data = search_utility.Job.search.create_complete_search_table(),
                           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)
Esempio n. 27
0
 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
Esempio n. 28
0
 def _provision_system_link(self, distro_tree):
     return make_link('/reserveworkflow/?distro_tree_id=%s'
             % distro_tree.id, 'Provision', elem_class='btn')
Esempio n. 29
0
 def action_cell(self, recipe):
     return make_link(recipe.clone_link(), 'Clone RecipeSet', elem_class='btn')
Esempio n. 30
0
 def system_name_getter(cls):
     return lambda x: make_link("/view/%s" % x.fqdn, x.fqdn)
Esempio n. 31
0
class Configuration(AdminPage):
    exposed = False

    id = widgets.HiddenField(name='id')
    value_str = widgets.TextArea(name='value', label=_(u'Value'))
    value_int = widgets.TextField(name='value',
                                  label=_(u'Value'),
                                  validator=validators.Int())
    valid_from = widgets.TextField(
        name='valid_from',
        label=_(u'Effective from date'),
        help_text=
        u"Enter date and time (YYYY-MM-DD HH:MM) in the future or leave blank for setting to take immediate effect"
    )

    string_form = HorizontalForm(
        'configitem',
        fields=[id, value_str, valid_from],
        action='save_data',
        submit_text=_(u'Save'),
    )

    int_form = HorizontalForm(
        'configitem',
        fields=[id, value_int, valid_from],
        action='save_data',
        submit_text=_(u'Save'),
    )

    value_grid = BeakerDataGrid(fields=[
                    ('Value', lambda x: x.value),
                    ('Effective from', lambda x: x.valid_from, {'datetime': True}),
                    ('Set by', lambda x: x.user),
                    ('Date set', lambda x: x.modified, {'datetime': True}),
                    ('', lambda x: x.valid_from <= datetime.utcnow() and " " or \
                                   make_link(url = 'delete?item=%s&id=%s' % (x.config_item.id, x.id), text = 'Delete')),
                 ])

    def __init__(self, *args, **kw):
        kw['search_url'] = url("/configuration/by_name?anywhere=1"),
        kw['search_name'] = 'name'
        super(Configuration, self).__init__(*args, **kw)

        self.search_col = ConfigItem.name
        self.search_mapper = ConfigItem

    @identity.require(identity.in_group("admin"))
    @expose(template='bkr.server.templates.config_edit')
    def edit(self, **kw):
        if kw.get('id'):
            item = ConfigItem.by_id(kw['id'])
            form_values = dict(id=item.id,
                               numeric=item.numeric,
                               value=item.current_value())
        else:
            flash(_(u"Error: No item ID specified"))
            raise redirect(".")

        # Show all future values, and the previous five
        config_values = item.values().filter(item.value_class.valid_from > datetime.utcnow()).order_by(item.value_class.valid_from.desc()).all() \
                      + item.values().filter(item.value_class.valid_from <= datetime.utcnow()).order_by(item.value_class.valid_from.desc())[:5]

        if item.readonly:
            form = None
        elif item.numeric:
            form = self.int_form
        else:
            form = self.string_form

        return dict(
            title=item.name,
            subtitle=item.description,
            form=form,
            action='./save',
            options={},
            value=form_values,
            list=config_values,
            grid=self.value_grid,
            warn_msg=item.readonly and "This item is read-only",
        )

    @expose()
    @error_handler(edit)
    @identity.require(identity.in_group("admin"))
    def save(self, **kw):
        if 'id' in kw and kw['id']:
            item = ConfigItem.by_id(kw['id'])
        else:
            flash(_(u"Error: No item ID"))
            raise redirect(".")
        if kw['valid_from']:
            try:
                valid_from = datetime.strptime(kw['valid_from'],
                                               '%Y-%m-%d %H:%M')
            except ValueError:
                flash(
                    _(u"Invalid date and time specification, use: YYYY-MM-DD HH:MM"
                      ))
                raise redirect("/configuration/edit?id=%d" % item.id)
        else:
            valid_from = None

        try:
            item.set(kw['value'], valid_from, identity.current.user)
        except Exception, msg:
            flash(_(u"Failed to save setting: %s" % msg))
            raise redirect("/configuration/edit?id=%d" % item.id)

        flash(_(u"%s saved" % item.name))
        redirect(".")
Esempio n. 32
0
 def link(self):
     return make_link(url = '/distros/view?id=%s' % self.id,
                      text = self.name)
Esempio n. 33
0
 def action_cell(self, recipe):
     return make_link(recipe.clone_link(),
                      'Clone RecipeSet',
                      elem_class='btn')
Esempio n. 34
0
    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)
Esempio n. 35
0
 def link(self):
     return make_link(url='/distrotrees/%s' % self.id, text=unicode(self))
Esempio n. 36
0
def get_power_type(power):
    # return powertype name
    return make_link(url='../powertypes/edit?id=%s' % power.powertype.id,
                     text=power.powertype.name)
Esempio n. 37
0
 def link(self):
     return make_link(url='/distros/view?id=%s' % self.id, text=self.name)
Esempio n. 38
0
 def link(self):
     return make_link(url='/distrotrees/%s' % self.id, text=unicode(self))
Esempio n. 39
0
 def _provision_system_link(self, distro_tree):
     return make_link('/reserveworkflow/?distro_tree_id=%s' %
                      distro_tree.id,
                      'Provision',
                      elem_class='btn')
Esempio n. 40
0
def get_power_type(power):
    # return powertype name
    return make_link(url  = '../powertypes/edit?id=%s' % power.powertype.id,
                     text = power.powertype.name)