def validate_review_groups(form, field='review_groups'):
    """Validates that the review groups all have valid, matching LocalSites.

    This will compare the LocalSite associated with the form to that of
    each added Group. Each Group must have the same LocalSite that the form
    is using.
    """
    groups = form.cleaned_data.get(field, [])
    local_site = form.cleaned_data['local_site']

    for group in groups:
        if group.local_site != local_site:
            raise ValidationError(
                [_("The review group %s does not exist.") % group.name])

    return groups
dataset/ETHPy150Open reviewboard/reviewboard/reviewboard/site/validation.py/validate_review_groups/original