def unapproved(self, r, **attr):
        """
            Get a list of unapproved records in this resource

            @param r: the S3Request
            @param attr: dictionary of parameters for the method handler
        """

        session = current.session
        response = current.response
        s3 = response.s3

        resource = self.resource
        table = self.table

        representation = r.representation

        output = dict()

        # Get table-specific parameters
        _config = self._config
        orderby = _config("orderby", None)
        linkto = _config("linkto", None)
        list_fields = _config("list_fields")

        list_id = "datatable"

        # Check permission to read in this table
        authorised = self._permitted()
        if not authorised:
            r.unauthorised()

        # Pagination
        get_vars = self.request.get_vars
        if representation == "aadata":
            start, limit = self._limits(get_vars)
        else:
            start = None
            limit = None if s3.no_sspag else 0

        # Linkto
        if not linkto:
            linkto = self._linkto(r)

        # List fields
        if not list_fields:
            fields = resource.readable_fields()
            list_fields = [f.name for f in fields]
        else:
            fields = [table[f] for f in list_fields if f in table.fields]
        if not fields:
            fields = []

        if not fields or \
           fields[0].name != table.fields[0]:
            fields.insert(0, table[table.fields[0]])
        if list_fields[0] != table.fields[0]:
            list_fields.insert(0, table.fields[0])

        left = []
        distinct = False

        if r.interactive:

            resource.build_query(filter=s3.filter)

            # View
            response.view = self._view(r, "list.html")

            # Page title
            crud_string = self.crud_string
            if r.component:
                title = crud_string(r.tablename, "title_display")
            else:
                title = crud_string(self.tablename, "title_list")
            output["title"] = title

            # How many records per page?
            if s3.dataTable_pageLength:
                display_length = s3.dataTable_pageLength
            else:
                display_length = 25

            # Server-side pagination?
            if not s3.no_sspag:
                dt_pagination = "true"
                if not limit:
                    limit = 2 * display_length
                session.s3.filter = get_vars
                if orderby is None:
                    # Default initial sorting
                    scol = 1 > len(list_fields) and "1" or "0"
                    get_vars.update(iSortingCols="1",
                                    iSortCol_0=scol,
                                    sSortDir_0="asc")
                    q, orderby, left = resource.datatable_filter(list_fields,
                                                                 get_vars)
                    del get_vars["iSortingCols"]
                    del get_vars["iSortCol_0"]
                    del get_vars["sSortDir_0"]
            else:
                dt_pagination = "false"

            # Get the data table
            dt, totalrows, ids = resource.datatable(fields=list_fields,
                                                    start=start,
                                                    limit=limit,
                                                    left=left,
                                                    orderby=orderby,
                                                    distinct=distinct)
            displayrows = totalrows

            # No records?
            if dt is None:
                s3.no_formats = True
                datatable = current.T("No records to review")
            else:
                dt_dom = s3.get("dataTable_dom",
                                current.deployment_settings.get_ui_datatables_dom())
                datatable = dt.html(totalrows, displayrows, list_id,
                                    dt_pagination=dt_pagination,
                                    dt_pageLength=display_length,
                                    dt_dom = dt_dom,
                                    )
                s3.actions = [{"label": str(current.T("Review")),
                               "url": r.url(id="[id]", method="review"),
                               "_class": "action-btn"}]

            # Add items to output
            output["items"] = datatable

        elif r.representation == "aadata":

            resource.build_query(filter=s3.filter, vars=session.s3.filter)

            # Apply datatable filters
            searchq, orderby, left = resource.datatable_filter(list_fields, get_vars)
            if searchq is not None:
                totalrows = resource.count()
                resource.add_filter(searchq)
            else:
                totalrows = None

            # Orderby fallbacks
            if orderby is None:
                orderby = _config("orderby", None)

            # Get a data table
            if totalrows != 0:
                dt, displayrows, ids = resource.datatable(fields=list_fields,
                                                          start=start,
                                                          limit=limit,
                                                          left=left,
                                                          orderby=orderby,
                                                          distinct=distinct)
            else:
                dt, displayrows = None, 0
            if totalrows is None:
                totalrows = displayrows

            # Echo
            draw = int(get_vars.draw or 0)

            # Representation
            if dt is not None:
                output = dt.json(totalrows,
                                 displayrows,
                                 list_id,
                                 draw)
            else:
                output = '{"recordsTotal": %s, ' \
                         '"recordsFiltered": 0,' \
                         '"dataTable_id": "%s", ' \
                         '"draw": %s, ' \
                         '"data": []}' % (totalrows, list_id, draw)

        else:
            r.error(415, current.ERROR.BAD_FORMAT)

        return output

    # -------------------------------------------------------------------------
dataset/ETHPy150Open sahana/eden/modules/s3/s3crud.py/S3CRUD.unapproved/swapped operands of `>`