Created
May 7, 2011 14:00
-
-
Save Alir3z4/960517 to your computer and use it in GitHub Desktop.
forms.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def clean(self): | |
from decimal import Decimal | |
cleaned_data = self.cleaned_data | |
price_mode = cleaned_data.get('price_mode') | |
price = cleaned_data.get('price') | |
if price_mode == u'0': | |
if price: | |
return self.cleaned_data['price'] | |
return self.cleaned_data['price_mode'] | |
else: | |
self._errors['price'] = self.error_class([_("Enter valid price!")]) | |
elif price_mode != u'0' and price: | |
if price_mode == u'1': | |
self._errors['price'] = self.error_class([_("You select `Free` mode, leave `Price` input empty!")]) | |
elif price_mode == u'2': | |
self._errors['price'] = self.error_class([_("You select `Please Contact` mode, leave `Price` input empty!")]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment