diff --git a/symposion/teams/forms.py b/symposion/teams/forms.py
index 6004ae217f0b5444f69890a73656af10d5a77216..a9080626b7e9d24b755a5f48f6fd29bf028598c2 100644
--- a/symposion/teams/forms.py
+++ b/symposion/teams/forms.py
@@ -9,40 +9,43 @@ from symposion.teams.models import Membership
class TeamInvitationForm(forms.Form):
-
- email = forms.EmailField(help_text="email address must be that of an account on this conference site")
-
+
+ email = forms.EmailField(help_text=("email address must be that of an account on this "
+ "conference site"))
+
def __init__(self, *args, **kwargs):
self.team = kwargs.pop("team")
super(TeamInvitationForm, self).__init__(*args, **kwargs)
-
+
def clean(self):
cleaned_data = super(TeamInvitationForm, self).clean()
email = cleaned_data.get("email")
-
+
if email is None:
raise forms.ValidationError("valid email address required")
-
+
try:
user = User.objects.get(email=email)
except User.DoesNotExist:
# eventually we can invite them but for now assume they are
# already on the site
- raise forms.ValidationError(mark_safe("no account with email address %s found on this conference site" % escape(email)))
-
+ raise forms.ValidationError(
+ mark_safe("no account with email address %s found on this conference "
+ "site" % escape(email)))
+
state = self.team.get_state_for_user(user)
-
+
if state in ["member", "manager"]:
raise forms.ValidationError("user already in team")
-
+
if state in ["invited"]:
raise forms.ValidationError("user already invited to team")
-
+
self.user = user
self.state = state
-
+
return cleaned_data
-
+
def invite(self):
if self.state is None:
Membership.objects.create(team=self.team, user=self.user, state="invited")