'Cancel a job assignment of the current user
@param r: the S3Request instance
@param attr: controller attributes'

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

    s3db = current.s3db
    job_id = self.record_id
    if (not job_id):
        r.error(404, current.ERROR.BAD_RECORD)
    atable = s3db.work_assignment
    auth = current.auth
    person_id = auth.s3_logged_in_person()
    if ((not person_id) or (not auth.s3_has_permission('delete', atable))):
        auth.permission.fail()
    query = ((FS('job_id') == job_id) & (FS('person_id') == person_id))
    assignments = s3db.resource('work_assignment', filter=query)
    success = assignments.delete()
    if (not success):
        error = (assignments.error or current.ERROR.NOT_PERMITTED)
        r.error(403, error)
    output = current.xml.json_message(True)
    return output
