'Sign up the current user for this a job
@param r: the S3Request instance
@param attr: controller attributes'

def signup(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('create', atable))):
        auth.permission.fail()
    query = (((atable.job_id == job_id) & (atable.person_id == person_id)) & (atable.deleted != True))
    row = current.db(query).select(atable.id, limitby=(0, 1)).first()
    if (not row):
        assignment = {'job_id': job_id, 'person_id': person_id}
        assignment_id = atable.insert(**assignment)
        if assignment_id:
            current.audit('create', 'work', 'assignment', record=assignment_id, representation=r.representation)
            assignment['id'] = assignment_id
            s3db.update_super(atable, assignment)
            auth.s3_set_record_owner(atable, assignment_id)
            auth.s3_make_session_owner(atable, assignment_id)
            s3db.onaccept(atable, assignment)
    output = current.xml.json_message(True)
    return output
