'Set the Activity\'s project_id when created via this Custom Form'

@staticmethod
def project_criteria_activity_postprocess(form):

    db = current.db
    s3db = current.s3db
    vars_get = form.vars.get
    criteria_id = vars_get('criteria_id')
    ctable = s3db.project_indicator_criteria
    criterion = db((ctable.id == criteria_id)).select(ctable.project_id, limitby=(0, 1)).first()
    if criterion:
        criteria_activity_id = vars_get('id')
        ltable = s3db.project_criteria_activity_activity
        link = db((ltable.criteria_activity_id == criteria_activity_id)).select(ltable.activity_id, limitby=(0, 1)).first()
        if link:
            atable = s3db.project_activity
            db((atable.id == link.activity_id)).update(project_id=criterion.project_id)
