def clean_email(self): email = self.cleaned_data['email'] password = self.cleaned_data['password'] importer = OpenInviter() try: self.contacts = importer.contacts(email, password) except OpenInviterException, e: raise forms.ValidationError(e)
def __init__(self, *args, **kwargs): super(FriendImportServiceForm, self).__init__(*args, **kwargs) importer = OpenInviter() services = importer.services() self.fields['service'].choices = [] for service in services: self.fields['service'].choices.append([service, service])
def is_valid(self, *args, **kwargs): if not super(FriendImportForm, self).is_valid(*args, **kwargs): return False email = self.cleaned_data['email'] password = self.cleaned_data['password'] # this check is used in the case that a manual selection of the service # is possible in the form. See FriendImportServiceForm for an example service = False if 'service' in self.cleaned_data: service = self.cleaned_data['service'] importer = OpenInviter() try: self.contacts = importer.contacts(email, password, service=service) except OpenInviterException, e: raise forms.ValidationError(e)
def is_valid(self, *args, **kwargs): if not super(FriendImportForm, self).is_valid(*args, **kwargs): return False email = self.cleaned_data['email'] password = self.cleaned_data['password'] # this check is used in the case that a manual selection of the service # is possible in the form. See FriendImportServiceForm for an example service = False if 'service' in self.cleaned_data: service = self.cleaned_data['service'] importer = OpenInviter() try: self.contacts = importer.contacts(email, password, service = service) except OpenInviterException, e: raise forms.ValidationError(e)