Exemplo n.º 1
0
Arquivo: role.py Projeto: dmdm/PySite
    def index(self):
        gr = Grid(self.GRID_ID)
        gr.opts.update(self.GRIDOPTS)
        gr.url = self.request.resource_url(self.context, "xhr_browse")
        gr.add_opts["url"] = self.request.resource_url(self.context, "xhr_create")
        gr.edit_opts["url"] = self.request.resource_url(self.context, "xhr_update")
        gr.delete_opts["url"] = self.request.resource_url(self.context, "xhr_delete")

        self._build_browse_queries(self.request, gr)
        gr.build_colmodel(self.DD, fieldlist=self.BROWSE_FIELDLIST, opts=self.COLOPTS)
        return dict(grid=gr)
Exemplo n.º 2
0
Arquivo: role.py Projeto: dmdm/PySite
 def xhr_browse(self):
     gr = Grid(self.GRID_ID)
     # Need to build the colModel here to initialise the list of allowed
     # fields e.g. for search.
     gr.build_colmodel(self.DD, fieldlist=self.BROWSE_FIELDLIST, opts=self.COLOPTS)
     # Apply request before building the queries. Otherwise
     # build_browse_queries() gets an unitialised grid and sets defaults
     # e.g. for order_field. The settings from the request will then not
     # be applied to the queries.
     gr.apply_request(self.request)
     data_qry, total_qry = self._build_browse_queries(self.request, gr)
     data, total = self._fetch_browse_data(data_qry, total_qry)
     gr.total_rows = total
     resp = gr.get_data_response(data, self.BROWSE_FIELDLIST, self.ID_FIELD)
     return resp
Exemplo n.º 3
0
    def index(self):
        gr = Grid(self.GRID_ID)
        gr.opts.update(self.GRIDOPTS)
        gr.url = self.request.resource_url(self.context, 'xhr_browse')
        gr.add_opts['url'] = self.request.resource_url(self.context,
            "xhr_create")
        gr.edit_opts['url'] = self.request.resource_url(self.context,
            "xhr_update")
        gr.delete_opts['url'] = self.request.resource_url(self.context,
            "xhr_delete")

        self._build_browse_queries(self.request, gr)
        gr.build_colmodel(self.DD, fieldlist=self.BROWSE_FIELDLIST,
            opts=self.COLOPTS)

        sess = DbSession
        roles = sess.query(Role.id, Role.name).order_by(Role.name).all()
        create_rolemember_url = self.request.resource_url(self.context,
            'xhr_create_rolemember')
        return dict(grid=gr, roles=roles,
            create_rolemember_url=create_rolemember_url)