'Review/approve/reject an unapproved record.
@param r: the S3Request
@param attr: dictionary of parameters for the method handler'

def review(self, r, **attr):

    if (not self._permitted('review')):
        r.unauthorized()
    T = current.T
    session = current.session
    response = current.response
    output = Storage()
    if r.interactive:
        _next = r.url(id='[id]', method='review')
        if self._permitted('approve'):
            approve = FORM(INPUT(_value=T('Approve'), _type='submit', _name='approve-btn', _id='approve-btn', _class='action-btn'))
            reject = FORM(INPUT(_value=T('Reject'), _type='submit', _name='reject-btn', _id='reject-btn', _class='action-btn'))
            edit = A(T('Edit'), _href=r.url(id=r.id, method='update', vars={'_next': r.url(id=r.id, method='review')}), _class='action-btn')
            cancel = A(T('Cancel'), _href=r.url(id=0), _class='action-lnk')
            output['approve_form'] = DIV(TABLE(TR(approve, reject, edit, cancel)), _id='approve_form')
            reviewing = False
            if approve.accepts(r.post_vars, session, formname='approve'):
                resource = current.s3db.resource(r.tablename, r.id, approved=False, unapproved=True)
                try:
                    success = resource.approve()
                except:
                    success = False
                if success:
                    response.confirmation = T('Record    approved')
                    output['approve_form'] = ''
                else:
                    response.warning = T('Record    could    not    be    approved.')
                r.http = 'GET'
                _next = r.url(id=0, method='review')
            elif reject.accepts(r.post_vars, session, formname='reject'):
                resource = current.s3db.resource(r.tablename, r.id, approved=False, unapproved=True)
                try:
                    success = resource.reject()
                except:
                    success = False
                if success:
                    response.confirmation = T('Record    deleted')
                    output['approve_form'] = ''
                else:
                    response.warning = T('Record    could    not    be    deleted.')
                r.http = 'GET'
                _next = r.url(id=0, method='review')
            else:
                reviewing = True
        if reviewing:
            output.update(self.read(r, **attr))
        self.next = _next
        r.http = r.env.request_method
        current.response.view = 'review.html'
    else:
        r.error(415, current.ERROR.BAD_FORMAT)
    return output
