示例#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"