'After DB I/O tasks for Project DRRPP records'

@staticmethod
def project_drrpp_onaccept(form):

    db = current.db
    form_vars = form.vars
    id = form_vars.id
    project_id = form_vars.project_id
    dtable = db.project_drrpp
    if (not project_id):
        project_id = db((dtable.id == id)).select(dtable.project_id, limitby=(0, 1)).first().project_id
    table = db.project_project
    hr_id = db((table.id == project_id)).select(table.human_resource_id, limitby=(0, 1)).first().human_resource_id
    if hr_id:
        s3db = current.s3db
        htable = db.hrm_human_resource
        ctable = s3db.pr_contact
        ptable = db.pr_person
        query = ((htable.id == hr_id) & (ptable.id == htable.person_id))
        left = ctable.on(((ctable.pe_id == ptable.pe_id) & (ctable.contact_method == 'EMAIL')))
        row = db(query).select(htable.organisation_id, ptable.first_name, ptable.middle_name, ptable.last_name, ctable.value, left=left, limitby=(0, 1)).first()
        focal_person = s3_fullname(row[ptable])
        organisation_id = row[htable].organisation_id
        email = row[ctable].value
        db((dtable.id == id)).update(focal_person=focal_person, organisation_id=organisation_id, email=email)
