Example #1
0
File: app.py Project: afrims/afrims
 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()
Example #2
0
 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
Example #3
0
 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
Example #4
0
File: app.py Project: afrims/afrims
 def _normalize_number(self, number):
     return normalize_number(number)
Example #5
0
 def clean_mobile_number(self):
     mobile_number = normalize_number(self.cleaned_data['mobile_number'])
     validate_phone(mobile_number)
     return mobile_number