

def form_valid(self, form):
    user_or_email = form.cleaned_data['invitee']
    role = form.cleaned_data['role']
    if isinstance(user_or_email, string_types):
        self.membership = self.team.invite_user(self.request.user, user_or_email, role)
    else:
        self.membership = self.team.add_user(user_or_email, role, by=self.request.user)
    self.after_membership_added(form)
    data = self.get_form_success_data(form)
    return self.render_to_response(data)

dataset/ETHPy150Open pinax/pinax-teams/pinax/teams/views.py TeamInviteView.form_valid/original