Esempio n. 1
0
 def validate(self, data):
     field = data['field']
     try:
         data['value'] = scrub_field(field, data['value'])
     except ValueError as exc:
         raise serializers.ValidationError('Scrubber for %r failed: %s' % (field, exc)) from exc
     if field == 'phone':
         country_code = parse_phone_number(data['value'], get_current_cc()).country_code
         if country_code in settings.SMS_BLACKLISTED_COUNTRIES:
             raise serializers.ValidationError('This country code (+%d) is not available at this time.' % country_code)
     return data
Esempio n. 2
0
 def test_activated(self):
     with translation.override('en-au'):
         assert get_current_cc() == 'AU'
Esempio n. 3
0
 def test_explicit(self):
     assert get_current_cc('en-us') == 'US'
Esempio n. 4
0
 def test_from_default(self):
     assert get_current_cc() == 'DE'
Esempio n. 5
0
 def test_activated(self):
     with translation.override("en-au"):
         assert get_current_cc() == "AU"
Esempio n. 6
0
 def test_explicit(self):
     assert get_current_cc("en-us") == "US"
Esempio n. 7
0
 def test_from_default(self):
     assert get_current_cc() == "DE"