Esempio n. 1
0
 def clean(self):
     
     cleaned = super(SubscriptionCreationForm, self).clean()
     
     if not self.errors:
         plan_name = self.cleaned_data["plan_name"]
         plan_id = self.cleaned_data["plan_id"]
         monthly_charge = self.cleaned_data["monthly_charge"]
         sale = Sale()
         
         # let's subscribe a user to our Gold Plan for this particular item
         success, instance = sale.create(plan_name, plan_id, monthly_charge)
         
         if not success:
             raise forms.ValidationError("Error: %s" % instance.message)
         else:
             #instance.save()
             # we were successful! do whatever you will here... 
             # perhaps you'd like to send an email...
             pass
     
     return cleaned