'Update the doc_id in all attachments (doc_document) to the
hrm_human_resource the response is linked to.
@param form: the form'

@staticmethod
def deploy_response_update_onaccept(form):

    form_vars = form.vars
    if ((not form_vars) or ('id' not in form_vars)):
        return
    db = current.db
    s3db = current.s3db
    if (('human_resource_id' not in form_vars) or ('message_id' not in form_vars)):
        rtable = s3db.deploy_response
        response = db((rtable.id == form_vars.id)).select(rtable.human_resource_id, rtable.message_id, limitby=(0, 1)).first()
        if (not response):
            return
        human_resource_id = response.human_resource_id
        message_id = response.message_id
    else:
        human_resource_id = form_vars.human_resource_id
        message_id = form_vars.message_id
    dtable = s3db.doc_document
    ltable = s3db.deploy_mission_document
    query = ((((ltable.message_id == message_id) & (dtable.id == ltable.document_id)) & (ltable.deleted == False)) & (dtable.deleted == False))
    attachments = db(query).select(dtable.id)
    if attachments:
        doc_id = None
        if human_resource_id:
            htable = s3db.hrm_human_resource
            hr = db((htable.id == human_resource_id)).select(htable.doc_id, limitby=(0, 1)).first()
            if hr:
                doc_id = hr.doc_id
        db(dtable.id.belongs(attachments)).update(doc_id=doc_id)
