コード例 #1
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)
コード例 #2
0
    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
コード例 #3
0
ファイル: group.py プロジェクト: ShaolongHu/beaker
    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
コード例 #4
0
ファイル: retention_tags.py プロジェクト: sibiaoluo/beaker
    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 make_link(url='./delete/%s' % x.id, text='Delete')
            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)
        return_dict = dict(title='Tags',
                           grid = tag_grid,
                           object_count = tags.count(),
                           search_bar = None,
                           search_widget = self.search_widget_form,
                           list = tags)
        return return_dict
コード例 #5
0
ファイル: activity.py プロジェクト: ustbgaofan/beaker
    def _activities_grid(self, activities, search_bar, action, searcher, \
        title='Activity', **kw):
        activity_search = searcher.search(activities)
        activities_return = self.activities(activity_search, **kw)
        searchvalue = None
        search_options = {}
        if activities_return:
            if 'activities_found' in activities_return:
                activities = activities_return['activities_found']
            if 'searchvalue' in activities_return:
                searchvalue = activities_return['searchvalue']
            if 'simplesearch' in activities_return:
                search_options['simplesearch'] = activities_return['simplesearch']

        activity_grid = myPaginateDataGrid(fields=[
                                  widgets.PaginateDataGrid.Column(name='user.user_name', getter=lambda x: x.user, title='User', options=dict(sortable=True)),
                                  widgets.PaginateDataGrid.Column(name='service', getter=lambda x: x.service, title='Via', options=dict(sortable=True)),
                                  widgets.PaginateDataGrid.Column(name='created',
                                    getter=lambda x: x.created, title='Date',
                                    options=dict(sortable=True, datetime=True)),
                                  widgets.PaginateDataGrid.Column(name='object_name', getter=lambda x: x.object_name(), title='Object', options=dict(sortable=False)),
                                  widgets.PaginateDataGrid.Column(name='field_name', getter=lambda x: x.field_name, title='Property', options=dict(sortable=True)),
                                  widgets.PaginateDataGrid.Column(name='action', getter=lambda x: x.action, title='Action', options=dict(sortable=True)),
                                  widgets.PaginateDataGrid.Column(name='old_value', getter=lambda x: x.old_value, title='Old Value', options=dict(sortable=True)),
                                  widgets.PaginateDataGrid.Column(name='new_value', getter=lambda x: x.new_value, title='New Value', options=dict(sortable=True)),
                              ])

        return dict(title=title,
                    grid = activity_grid,
                    search_bar = search_bar,
                    searchvalue = searchvalue,
                    action = action,
                    options = search_options,
                    list = activities)
コード例 #6
0
ファイル: watchdog.py プロジェクト: pombredanne/beaker-1
    def index(self, *args, **kw):
        query = Watchdog.by_status(status=u'active')\
                .join(Watchdog.recipe).join(Recipe.recipeset).join(RecipeSet.job)\
                .order_by(Job.id)\
                .options(
                    joinedload_all(Watchdog.recipe, Recipe.recipeset, RecipeSet.job),
                    joinedload_all(Watchdog.recipe, Recipe.recipeset, RecipeSet.lab_controller),
                    joinedload_all(Watchdog.recipetask, RecipeTask.task))

        col = myPaginateDataGrid.Column
        fields = [
            col(name='job_id',
                getter=lambda x: x.recipe.recipeset.job.link,
                title="Job ID"),
            col(name='system_name',
                getter=lambda x: x.recipe.resource.link,
                title="System"),
            col(name='lab_controller',
                getter=lambda x: x.recipe.recipeset.lab_controller,
                title="Lab Controller"),
            col(name='task_name',
                getter=lambda x: x.recipetask.name_markup
                if x.recipetask is not None else None,
                title="Task Name"),
            col(name='kill_time',
                getter=lambda x: x.kill_time,
                title="Kill Time",
                options=dict(datetime=True))
        ]

        watchdog_grid = myPaginateDataGrid(fields=fields)
        return dict(title="Watchdogs",
                    grid=watchdog_grid,
                    search_bar=None,
                    list=query)
コード例 #7
0
    def _activities_grid(self, activities, search_bar, action, searcher, \
        title='Activity', **kw):
        activity_search = searcher.search(activities)
        activities_return = self.activities(activity_search, **kw)
        searchvalue = None
        search_options = {}
        if activities_return:
            if 'activities_found' in activities_return:
                activities = activities_return['activities_found']
            if 'searchvalue' in activities_return:
                searchvalue = activities_return['searchvalue']
            if 'simplesearch' in activities_return:
                search_options['simplesearch'] = activities_return['simplesearch']

        activity_grid = myPaginateDataGrid(fields=[
                                  widgets.PaginateDataGrid.Column(name='user.user_name', getter=lambda x: x.user, title='User', options=dict(sortable=True)),
                                  widgets.PaginateDataGrid.Column(name='service', getter=lambda x: x.service, title='Via', options=dict(sortable=True)),
                                  widgets.PaginateDataGrid.Column(name='created',
                                    getter=lambda x: x.created, title='Date',
                                    options=dict(sortable=True, datetime=True)),
                                  widgets.PaginateDataGrid.Column(name='object_name', getter=lambda x: x.object_name(), title='Object', options=dict(sortable=False)),
                                  widgets.PaginateDataGrid.Column(name='field_name', getter=lambda x: x.field_name, title='Property', options=dict(sortable=True)),
                                  widgets.PaginateDataGrid.Column(name='action', getter=lambda x: x.action, title='Action', options=dict(sortable=True)),
                                  widgets.PaginateDataGrid.Column(name='old_value', getter=lambda x: x.old_value, title='Old Value', options=dict(sortable=True)),
                                  widgets.PaginateDataGrid.Column(name='new_value', getter=lambda x: x.new_value, title='New Value', options=dict(sortable=True)),
                              ])

        return dict(title=title,
                    grid = activity_grid,
                    search_bar = search_bar,
                    searchvalue = searchvalue,
                    action = action,
                    options = search_options,
                    list = activities)
コード例 #8
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
コード例 #9
0
ファイル: recipes.py プロジェクト: sibiaoluo/beaker
    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_widget(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", 
                    object_count=recipes.count(),
                    grid=recipes_grid, 
                    list=recipes,
                    search_bar=search_bar,
                    action=action,
                    options=search_options,
                    searchvalue=searchvalue)
コード例 #10
0
ファイル: distro.py プロジェクト: xhernandez/beaker
    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)
コード例 #11
0
ファイル: distro_family.py プロジェクト: pombredanne/beaker-1
 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
コード例 #12
0
ファイル: distro_family.py プロジェクト: sibiaoluo/beaker
 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
コード例 #13
0
ファイル: recipes.py プロジェクト: xhernandez/beaker
    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)
コード例 #14
0
ファイル: distrotrees.py プロジェクト: sibiaoluo/beaker
    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)
コード例 #15
0
 def systems(self, recipe_id=None, *args, **kw):
     try:
         recipe = Recipe.by_id(recipe_id)
     except NoResultFound:
         flash(_(u"Invalid recipe id %s" % recipe_id))
         redirect(url("/recipes"))
     PDC = widgets.PaginateDataGrid.Column
     fields = [PDC(name='fqdn', getter=lambda x: x.link, title='Name'),
         PDC(name='user', getter=lambda x: x.user.email_link if x.user else None, title='User'),]
     grid = myPaginateDataGrid(fields=fields)
     return dict(title='Recipe Systems', grid=grid, list=recipe.systems,
         search_bar=None)
コード例 #16
0
ファイル: recipes.py プロジェクト: ustbgaofan/beaker
 def systems(self, recipe_id=None, *args, **kw):
     try:
         recipe = Recipe.by_id(recipe_id)
     except NoResultFound:
         flash(_(u"Invalid recipe id %s" % recipe_id))
         redirect(url("/recipes"))
     PDC = widgets.PaginateDataGrid.Column
     fields = [PDC(name='fqdn', getter=lambda x: x.link, title='Name'),
         PDC(name='user', getter=lambda x: x.user.email_link if x.user else None, title='User'),]
     grid = myPaginateDataGrid(fields=fields)
     return dict(title='Recipe Systems', grid=grid, list=recipe.systems,
         search_bar=None)
コード例 #17
0
ファイル: distrotrees.py プロジェクト: pombredanne/beaker-1
    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)
コード例 #18
0
ファイル: distro.py プロジェクト: sibiaoluo/beaker
    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,
                    object_count = distros.count(),
                    action=action,
                    options=search_options,
                    searchvalue=searchvalue,
                    list=distros)
コード例 #19
0
 def index(self,*args,**kw):
     keytypes = session.query(Key) 
     list_by_letters = set([elem.key_name[0].capitalize() for elem in keytypes])
     results = self.process_search(**kw)
     if results:
         keytypes = results.order_by(Key.key_name)
     keytypes_grid = myPaginateDataGrid(fields=[
                               ('Key', lambda x: make_edit_link(x.key_name, x.id)),
                               ('Numeric', lambda x: x.numeric),
                               (' ', lambda x: make_remove_link(x.id)),
                           ],
                           add_action='./new')
     return dict(title="Key Types", 
                 grid = keytypes_grid, 
                 search_widget = self.search_widget_form,
                 alpha_nav_bar = AlphaNavBar(list_by_letters,self.search_name),
                 list = keytypes)
コード例 #20
0
ファイル: osversion.py プロジェクト: pombredanne/beaker-1
    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)
コード例 #21
0
    def index(self,*args,**kw):
        powertypes = session.query(PowerType)
        list_by_letters = set([elem.name[0].capitalize() for elem in powertypes if elem.name])
        results = self.process_search(**kw)
        if results:
            powertypes = results

        powertypes_grid = myPaginateDataGrid(fields=[
                                  ('Power Type', make_edit_link),
                                  (' ', make_remove_link),
                              ],
                              add_action='./new')
        

        return dict(title="Power Types", 
                    grid = powertypes_grid,
                    search_widget = self.search_widget_form,
                    alpha_nav_bar = AlphaNavBar(list_by_letters,'power'),
                    list = powertypes)
コード例 #22
0
ファイル: tasks.py プロジェクト: sibiaoluo/beaker
    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)
コード例 #23
0
ファイル: power.py プロジェクト: ShaolongHu/beaker
    def index(self,*args,**kw):
        powertypes = session.query(PowerType)
        list_by_letters = set([elem.name[0].capitalize() for elem in powertypes if elem.name])
        results = self.process_search(**kw)
        if results:
            powertypes = results
        can_edit = identity.current.user and identity.current.user.is_admin()
        powertypes_grid = myPaginateDataGrid(fields=[
                                  ('Power Type', lambda x: make_edit_link(x.name, x.id) if can_edit else x.name),
                                  (' ', lambda x: make_remove_link(x.id) if can_edit else None ),
                              ],
                              add_action='./new' if can_edit else None)
        

        return dict(title="Power Types", 
                    grid = powertypes_grid,
                    search_widget = self.search_widget_form,
                    alpha_nav_bar = AlphaNavBar(list_by_letters,'power'),
                    list = powertypes)
コード例 #24
0
ファイル: power.py プロジェクト: ustbgaofan/beaker
    def index(self,*args,**kw):
        powertypes = session.query(PowerType)
        list_by_letters = set([elem.name[0].capitalize() for elem in powertypes if elem.name])
        results = self.process_search(**kw)
        if results:
            powertypes = results

        powertypes_grid = myPaginateDataGrid(fields=[
                                  ('Power Type', make_edit_link),
                                  (' ', make_remove_link),
                              ],
                              add_action='./new')
        

        return dict(title="Power Types", 
                    grid = powertypes_grid,
                    search_widget = self.search_widget_form,
                    alpha_nav_bar = AlphaNavBar(list_by_letters,'power'),
                    list = powertypes)
コード例 #25
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
コード例 #26
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)
コード例 #27
0
    def index(self, *args, **kw):
        users = session.query(User)
        list_by_letters = set(
            [elem.user_name[0].capitalize() for elem in users])
        result = self.process_search(**kw)
        if result:
            users = result

        users_grid = myPaginateDataGrid(fields=[
            ('Login', lambda x: make_edit_link(x.user_name, x.user_id)),
            ('Display Name', lambda x: x.display_name),
            ('Disabled', lambda x: x.disabled),
            ('', lambda x: self.make_remove_link(x)),
        ],
                                        add_action='./new')
        return dict(title="Users",
                    grid=users_grid,
                    alpha_nav_bar=AlphaNavBar(list_by_letters, 'user'),
                    search_widget=self.search_widget_form,
                    list=users)
コード例 #28
0
ファイル: configuration.py プロジェクト: pombredanne/beaker-1
 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)
コード例 #29
0
ファイル: user.py プロジェクト: omps/beaker
 def index(self,*args,**kw): 
     users = session.query(User) 
     list_by_letters = set([elem.user_name[0].capitalize() for elem in users]) 
     result = self.process_search(**kw)
     if result:
         users = result
     
    
     users_grid = myPaginateDataGrid(fields=[
                               ('Login', lambda x: make_edit_link(x.user_name,
                                                                  x.user_id)),
                               ('Display Name', lambda x: x.display_name),
                               ('Disabled', lambda x: x.disabled),
                               ('', lambda x: self.make_remove_link(x)),
                           ],
                           add_action='./new')
     return dict(title="Users",
                 grid = users_grid,
                 alpha_nav_bar = AlphaNavBar(list_by_letters,'user'),
                 search_widget = self.search_widget_form,
                 list = users)
コード例 #30
0
    def index(self, *args, **kw):
        powertypes = session.query(PowerType)
        list_by_letters = set(
            [elem.name[0].capitalize() for elem in powertypes if elem.name])
        results = self.process_search(**kw)
        if results:
            powertypes = results
        can_edit = identity.current.user and identity.current.user.is_admin()
        powertypes_grid = myPaginateDataGrid(
            fields=[
                ('Power Type', lambda x: make_edit_link(x.name, x.id)
                 if can_edit else x.name),
                (' ', lambda x: make_remove_link(x.id) if can_edit else None),
            ],
            add_action='./new' if can_edit else None)

        return dict(title="Power Types",
                    grid=powertypes_grid,
                    search_widget=self.search_widget_form,
                    alpha_nav_bar=AlphaNavBar(list_by_letters, 'power'),
                    list=powertypes)
コード例 #31
0
ファイル: keytypes.py プロジェクト: ShaolongHu/beaker
 def index(self, *args, **kw):
     keytypes = session.query(Key)
     list_by_letters = set([elem.key_name[0].capitalize() for elem in keytypes])
     results = self.process_search(**kw)
     if results:
         keytypes = results.order_by(Key.key_name)
     can_edit = identity.current.user and identity.current.user.is_admin()
     keytypes_grid = myPaginateDataGrid(
         fields=[
             ("Key", lambda x: make_edit_link(x.key_name, x.id) if can_edit else x.key_name),
             ("Numeric", lambda x: x.numeric),
             (" ", lambda x: make_remove_link(x.id) if can_edit else None),
         ],
         add_action="./new" if can_edit else None,
     )
     return dict(
         title="Key Types",
         grid=keytypes_grid,
         search_widget=self.search_widget_form,
         alpha_nav_bar=AlphaNavBar(list_by_letters, self.search_name),
         list=keytypes,
     )
コード例 #32
0
ファイル: reports.py プロジェクト: sibiaoluo/beaker
    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_search_table(),
                               complete_data=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,
                    object_count=len(reservations),
                    list=reservations)
コード例 #33
0
ファイル: watchdog.py プロジェクト: ustbgaofan/beaker
    def index(self, *args, **kw):
        query = Watchdog.by_status(status=u'active')\
                .join(Watchdog.recipe, Recipe.recipeset, RecipeSet.job)\
                .order_by(Job.id)\
                .options(
                    joinedload_all(Watchdog.recipe, Recipe.recipeset, RecipeSet.job),
                    joinedload_all(Watchdog.recipe, Recipe.recipeset, RecipeSet.lab_controller),
                    joinedload_all(Watchdog.recipetask, RecipeTask.task))

        col = myPaginateDataGrid.Column
        fields = [col(name='job_id', getter=lambda x: x.recipe.recipeset.job.link, title="Job ID"),
                  col(name='system_name', getter=lambda x: x.recipe.resource.link, title="System"),
                  col(name='lab_controller', getter=lambda x: x.recipe.recipeset.lab_controller, title="Lab Controller"),
                  col(name='task_name', getter=lambda x: x.recipetask.name_markup
                        if x.recipetask is not None else None, title="Task Name"),
                  col(name='kill_time', getter=lambda x: x.kill_time,
                      title="Kill Time", options=dict(datetime=True))]

        watchdog_grid = myPaginateDataGrid(fields=fields)
        return dict(title="Watchdogs",
                grid=watchdog_grid,
                search_bar=None,
                list=query)
コード例 #34
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)
コード例 #35
0
ファイル: group.py プロジェクト: sibiaoluo/beaker
    def groups(self, groups=None, *args,**kw):
        if groups is None:
            groups = session.query(Group)

        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'

        def get_remove_link(x):
            try:
                if x.can_edit(identity.current.user):
                    return self.delete_link.display(dict(group_id=x.group_id),
                                             action=url('remove'),
                                             action_text='Remove (-)')
                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)
        return_dict = dict(title=u"Groups",
                           grid=grid,
                           object_count = groups.count(),
                           search_bar = None,
                           search_widget = self.search_widget_form,
                           list = groups)
        return return_dict
コード例 #36
0
ファイル: recipes.py プロジェクト: sibiaoluo/beaker
                    action=action,
                    options=search_options,
                    searchvalue=searchvalue)

    @expose(template='bkr.server.templates.grid')
    @paginate('list', default_order='fqdn', limit=20, max_limit=None)
    def systems(self, recipe_id=None, *args, **kw):
        try:
            recipe = Recipe.by_id(recipe_id)
        except NoResultFound, e:
            flash(_(u"Invalid recipe id %s" % recipe_id))
            redirect(url("/recipes"))
        PDC = widgets.PaginateDataGrid.Column
        fields = [PDC(name='fqdn', getter=lambda x: x.link, title='Name'),
            PDC(name='user', getter=lambda x: x.user.email_link if x.user else None, title='User'),]
        grid = myPaginateDataGrid(fields=fields)
        return dict(title='Recipe Systems', grid=grid, list=recipe.systems,
            object_count = len(recipe.systems), search_bar=None)

    @expose(template="bkr.server.templates.recipe")
    def default(self, id):
        try:
            recipe = Recipe.by_id(id)
        except InvalidRequestError:
            flash(_(u"Invalid recipe id %s" % id))
            redirect(".")
        if recipe.is_deleted():
            flash(_(u"Invalid %s, has been deleted" % recipe.t_id))
            redirect(".")
        return dict(title   = 'Recipe',
                    recipe_widget        = self.recipe_widget,
コード例 #37
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)
コード例 #38
0
ファイル: jobs.py プロジェクト: ustbgaofan/beaker
    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)