Пример #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
Пример #2
0
 def test_activated(self):
     with translation.override('en-au'):
         assert get_current_cc() == 'AU'
Пример #3
0
 def test_explicit(self):
     assert get_current_cc('en-us') == 'US'
Пример #4
0
 def test_from_default(self):
     assert get_current_cc() == 'DE'
Пример #5
0
 def test_activated(self):
     with translation.override("en-au"):
         assert get_current_cc() == "AU"
Пример #6
0
 def test_explicit(self):
     assert get_current_cc("en-us") == "US"
Пример #7
0
 def test_from_default(self):
     assert get_current_cc() == "DE"