コード例 #1
0
 def clean(self):
     cleaned_data = super(SurveyDataForm, self).clean()
     if 'send_flyers_country' in cleaned_data and 'send_flyers_zip' in cleaned_data:
         country = cleaned_data['send_flyers_country']
         code = cleaned_data['send_flyers_zip']
         try:
             cleaned_data['send_flyers_zip'] = clean_postal_code(country, code)
         except ValidationError, e:
             del cleaned_data['send_flyers_zip']
             self.add_error('send_flyers_zip', e)
コード例 #2
0
 def clean(self):
     cleaned_data = super(HostingForm, self).clean()
     if 'country' in cleaned_data and 'zip_code' in cleaned_data:
         country = cleaned_data['country']
         code = cleaned_data['zip_code']
         try:
             cleaned_data['zip_code'] = clean_postal_code(country, code)
         except ValidationError, e:
             del cleaned_data['zip_code']
             self.add_error('zip_code', e)
コード例 #3
0
 def clean(self):
     cleaned_data = super(HostingForm, self).clean()
     if 'country' in cleaned_data and 'zip_code' in cleaned_data:
         country = cleaned_data['country']
         code = cleaned_data['zip_code']
         try:
             cleaned_data['zip_code'] = clean_postal_code(country, code)
         except ValidationError, e:
             del cleaned_data['zip_code']
             self.add_error('zip_code', e)
コード例 #4
0
 def clean(self):
     cleaned_data = super(OrganizationPaymentForm, self).clean()
     if 'check_zip' in cleaned_data:
         country = self.instance.check_country
         code = cleaned_data['check_zip']
         try:
             cleaned_data['check_zip'] = clean_postal_code(country, code)
         except ValidationError, e:
             del cleaned_data['check_zip']
             self.add_error('check_zip', e)
コード例 #5
0
 def clean(self):
     cleaned_data = super(OrganizationPaymentForm, self).clean()
     if 'check_zip' in cleaned_data:
         country = self.instance.check_country
         code = cleaned_data['check_zip']
         try:
             cleaned_data['check_zip'] = clean_postal_code(country, code)
         except ValidationError, e:
             del cleaned_data['check_zip']
             self.add_error('check_zip', e)
コード例 #6
0
 def clean(self):
     cleaned_data = super(SurveyDataForm, self).clean()
     if 'send_flyers_country' in cleaned_data and 'send_flyers_zip' in cleaned_data:
         country = cleaned_data['send_flyers_country']
         code = cleaned_data['send_flyers_zip']
         try:
             cleaned_data['send_flyers_zip'] = clean_postal_code(
                 country, code)
         except ValidationError, e:
             del cleaned_data['send_flyers_zip']
             self.add_error('send_flyers_zip', e)
コード例 #7
0
 def test_gb_postal__valid1(self):
     clean_postal_code('GB', 'NW4 9BX')
コード例 #8
0
 def test_unhandled_country(self):
     clean_postal_code('12', ';[]32adf,,,')
コード例 #9
0
 def test_us_postal__empty(self):
     clean_postal_code('US', '')
コード例 #10
0
 def test_us_postal__invalid1(self):
     with self.assertRaises(ValidationError):
         clean_postal_code('US', 'ABCDEF')
コード例 #11
0
 def test_us_postal__valid2(self):
     clean_postal_code('US', '16801-2345')
コード例 #12
0
 def test_us_postal__valid1(self):
     clean_postal_code('US', '16801')
コード例 #13
0
 def test_gb_postal__invalid1(self):
     with self.assertRaises(ValidationError):
         clean_postal_code('GB', '12345')
コード例 #14
0
 def test_gb_postal__valid3(self):
     clean_postal_code('GB', 'M3 3BT')
コード例 #15
0
 def test_gb_postal__valid2(self):
     clean_postal_code('GB', 'M32 8BR')