'Update affiliations.
@ToDo: ondelete function needed too'

@staticmethod
def org_team_onaccept(form):

    if hasattr(form, 'vars'):
        _id = form.vars.id
    elif (isinstance(form, Row) and ('id' in form)):
        _id = form.id
    else:
        return
    if (not _id):
        return
    db = current.db
    table = db.org_organisation_team
    record = db((table.id == _id)).select(table.group_id, table.organisation_id, limitby=(0, 1)).first()
    if record:
        from pr import OU
        org = ('org_organisation', record.organisation_id)
        group = ('pr_group', record.group_id)
        current.s3db.pr_add_affiliation(org, group, role='Groups', role_type=OU)
