diff --git a/frontend/forms.py b/frontend/forms.py index d220141f..846af7d8 100644 --- a/frontend/forms.py +++ b/frontend/forms.py @@ -44,6 +44,7 @@ class UserData(forms.Form): class CampaignPledgeForm(forms.Form): pledge_amount = forms.DecimalField(initial=D('0.00'), min_value=D('0.00'), max_value=D('10000.00'), decimal_places=2) preapproval_amount = forms.DecimalField(initial=D('20.00'), min_value=D('0.00'), max_value=D('10000.00'), decimal_places=2) + anonymous = forms.BooleanField(required=False, label="Don't display my username in the supporters list") def clean(self): # force a choice: only one of pledge_amount and pre_approval can be non-zero. cleaned_data = self.cleaned_data diff --git a/frontend/views.py b/frontend/views.py index 6306650a..212e2825 100755 --- a/frontend/views.py +++ b/frontend/views.py @@ -187,6 +187,7 @@ class CampaignFormView(FormView): pk = self.kwargs["pk"] pledge_amount = form.cleaned_data["pledge_amount"] preapproval_amount = form.cleaned_data["preapproval_amount"] + anonymous = form.cleaned_data["anonymous"] # right now, if there is a non-zero pledge amount, go with that. otherwise, do the pre_approval campaign = models.Campaign.objects.get(id=int(pk)) @@ -204,7 +205,7 @@ class CampaignFormView(FormView): return_url = self.request.build_absolute_uri(reverse('campaign_by_id',kwargs={'pk': str(pk)})) t, url = p.authorize('USD', TARGET_TYPE_CAMPAIGN, preapproval_amount, campaign=campaign, list=None, user=user, - return_url=return_url) + return_url=return_url, anonymous=anonymous) else: # instant payment: send to the partnering RH # right now, all money going to Gluejar. @@ -214,7 +215,7 @@ class CampaignFormView(FormView): #return_url = self.request.build_absolute_uri("/campaigns/%s" %(str(pk))) return_url = self.request.build_absolute_uri(reverse('campaign_by_id',kwargs={'pk': str(pk)})) t, url = p.pledge('USD', TARGET_TYPE_CAMPAIGN, receiver_list, campaign=campaign, list=None, user=user, - return_url=return_url) + return_url=return_url, anonymous=anonymous) if url: logger.info("CampaignFormView paypal: " + url) diff --git a/payment/manager.py b/payment/manager.py index f84f64fe..fc0f3a24 100644 --- a/payment/manager.py +++ b/payment/manager.py @@ -342,7 +342,7 @@ class PaymentManager( object ): transaction.error = p.error() return False - def authorize(self, currency, target, amount, campaign=None, list=None, user=None, return_url=None, cancel_url=None): + def authorize(self, currency, target, amount, campaign=None, list=None, user=None, return_url=None, cancel_url=None, anonymous=False): ''' authorize @@ -367,7 +367,8 @@ class PaymentManager( object ): status='NONE', campaign=campaign, list=list, - user=user + user=user, + anonymous=anonymous ) p = Preapproval(t, amount, return_url=return_url, cancel_url=cancel_url) @@ -384,7 +385,7 @@ class PaymentManager( object ): logger.info("Authorize Error: " + p.error()) return t, None - def pledge(self, currency, target, receiver_list, campaign=None, list=None, user=None, return_url=None, cancel_url=None): + def pledge(self, currency, target, receiver_list, campaign=None, list=None, user=None, return_url=None, cancel_url=None, anonymous=False): ''' pledge @@ -421,7 +422,8 @@ class PaymentManager( object ): campaign=campaign, list=list, user=user, - date_payment=datetime.now() + date_payment=datetime.now(), + anonymous=anonymous ) t.create_receivers(receiver_list) diff --git a/payment/models.py b/payment/models.py index 7452f65b..c0a1cc6c 100644 --- a/payment/models.py +++ b/payment/models.py @@ -25,6 +25,7 @@ class Transaction(models.Model): user = models.ForeignKey(User, null=True) campaign = models.ForeignKey(Campaign, null=True) list = models.ForeignKey(Wishlist, null=True) + anonymous = models.BooleanField(null=False) def save(self, *args, **kwargs): if not self.secret: