adding option for supporters to pledge anonymously

pull/1/head
Andromeda Yelton 2011-11-01 17:08:09 -04:00
parent 60f29fc98c
commit c139e4dcfc
4 changed files with 11 additions and 6 deletions

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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: