def _associate_contact(self, connection): normalized_number = normalize_number(connection.identity) self.debug('Normalized number: {0}'.format(normalized_number)) try: contact = Contact.objects.get(phone=normalized_number) except Contact.DoesNotExist: self.debug('Failed to find matching contact') contact = None if contact: self.debug('Associating connection to {0}'.format(contact)) connection.contact = contact connection.save()
def value_from_datadict(self, data, files, name): value = super(FancyPhoneInput, self).value_from_datadict(data, files, name) if value: value = normalize_number(value) return value
def clean_mobile_number(self): mobile_number = self.cleaned_data.get('mobile_number', u'') if mobile_number: mobile_number = normalize_number(mobile_number) validate_phone(mobile_number) return mobile_number
def _normalize_number(self, number): return normalize_number(number)
def clean_mobile_number(self): mobile_number = normalize_number(self.cleaned_data['mobile_number']) validate_phone(mobile_number) return mobile_number