Merge branch 'relaunch_ry' of github.com:Gluejar/regluit into pledge_pretty_stick

Conflicts:
	requirements_versioned.pip
pull/1/head
Andromeda Yelton 2012-10-03 11:43:15 -04:00
commit b07c49a87e
13 changed files with 346 additions and 598 deletions

View File

@ -84,6 +84,19 @@ class Claim(models.Model):
user = models.ForeignKey(User, related_name="claim", null=False )
status = models.CharField(max_length=7, choices= STATUSES, default='pending')
@property
def can_open_new(self):
# whether a campaign can be opened for this claim
#must be an active claim
if self.status != 'active':
return False
#can't already be a campaign
for campaign in self.campaigns:
if campaign.status in ['ACTIVE','INITIALIZED', 'SUCCESSFUL']:
return False
return True
class RightsHolder(models.Model):
created = models.DateTimeField(auto_now_add=True)
email = models.CharField(max_length=100, blank=True)

View File

@ -1139,10 +1139,8 @@ def rh_tools(request):
claim.campaigns = claim.work.campaigns.all()
else:
claim.campaigns = []
claim.can_open_new=False if claim.work.last_campaign_status in ['ACTIVE','INITIALIZED'] else True
for campaign in claim.campaigns:
if campaign.status in ['ACTIVE','INITIALIZED']:
claim.can_open_new=False
if request.method == 'POST' and request.POST.has_key('edit_managers_%s'% campaign.id) :
campaign.edit_managers_form=EditManagersForm( instance=campaign, data=request.POST, prefix=campaign.id)
if campaign.edit_managers_form.is_valid():
@ -1150,7 +1148,7 @@ def rh_tools(request):
campaign.edit_managers_form = EditManagersForm(instance=campaign, prefix=campaign.id)
else:
campaign.edit_managers_form=EditManagersForm(instance=campaign, prefix=campaign.id)
if claim.status == 'active' and claim.can_open_new:
if claim.can_open_new:
if request.method == 'POST' and request.POST.has_key('work') and int(request.POST['work']) == claim.work.id :
claim.campaign_form = OpenCampaignForm(request.POST)
if claim.campaign_form.is_valid():
@ -1159,11 +1157,8 @@ def rh_tools(request):
new_campaign.target = D(settings.UNGLUEIT_MINIMUM_TARGET)
new_campaign.save()
claim.campaign_form.save_m2m()
claim.can_open_new=False
else:
claim.campaign_form = OpenCampaignForm(data={'work': claim.work, 'name': claim.work.title, 'userid': request.user.id, 'managers_1': request.user.id})
else:
claim.can_open_new=False
campaigns = request.user.campaigns.all()
new_campaign = None
for campaign in campaigns:

View File

@ -1,4 +1,4 @@
from regluit.payment.models import Transaction, PaymentResponse
from regluit.payment.models import PaymentResponse
from django.http import HttpResponseForbidden
from datetime import timedelta
@ -8,18 +8,6 @@ import datetime
import time
def requires_explicit_preapprovals():
"""a function that returns for the given payment processor"""
return False
def make_account(user, token):
"""template function for return a payment.Account corresponding to the payment system"""
return None
def ProcessIPN(request):
return HttpResponseForbidden()
class BasePaymentRequest:
'''
Handles common information incident to payment processing
@ -71,6 +59,17 @@ class BasePaymentRequest:
def timestamp(self):
return str(datetime.datetime.now())
class Processor:
"""a function that returns for the given payment processor"""
requires_explicit_preapprovals=False
def make_account(self, user, token):
"""template function for return a payment.Account corresponding to the payment system"""
return None
def ProcessIPN(self, request):
return HttpResponseForbidden()
class Pay( BasePaymentRequest ):

View File

@ -4,6 +4,7 @@ from django.contrib.auth.models import User
from django.conf import settings
from regluit.payment.parameters import *
from regluit.payment import baseprocessor
from regluit.payment.baseprocessor import BasePaymentRequest
@ -28,6 +29,7 @@ def credit_transaction(t,user,amount):
user.credit.add_to_pledged(pledge_amount)
t.set_credit_approved(pledge_amount)
class Processor(baseprocessor.Processor):
class CancelPreapproval(BasePaymentRequest):
'''
Cancels an exisiting token.

View File

@ -0,0 +1,16 @@
from django.core.management.base import BaseCommand
from regluit.payment import stripelib
from decimal import Decimal as D
class Command(BaseCommand):
help = "create a credit card record and charge it -- for testing"
def handle(self, *args, **kwargs):
# test card
sc = stripelib.StripeClient()
card = stripelib.card(number="4242424242424242", exp_month="01", exp_year="2013", cvc="123")
cust = sc.create_customer(card=card, description="William Shakespeare XIV (via test_stripe_charge)", email="bill.shakespeare@gmail.com")
print cust
# let's charge RY $1.00
charge = sc.create_charge(D('1.00'), customer=cust.id, description="$1 TEST CHARGE for Will S. XIV")
print charge

View File

@ -1,4 +1,3 @@
from regluit.core.models import Campaign, Wishlist
from regluit.payment.models import Transaction, Receiver, PaymentResponse
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
@ -7,8 +6,6 @@ from regluit.payment.parameters import *
from regluit.payment.signals import transaction_charged, pledge_modified, pledge_created
from regluit.payment import credit
from regluit.payment.baseprocessor import Pay, Finish, Preapproval, ProcessIPN, CancelPreapproval, PaymentDetails, PreapprovalDetails, RefundPayment
import uuid
import traceback
from regluit.utils.localdatetime import now
@ -40,14 +37,12 @@ class PaymentManager( object ):
# Forward to our payment processor
mod = __import__("regluit.payment." + module, fromlist=[str(module)])
method = getattr(mod, "ProcessIPN")
return method(request)
return = mod.Processor().ProcessIPN(request)
def update_preapproval(self, transaction):
"""Update a transaction to hold the data from a PreapprovalDetails on that transaction"""
t = transaction
method = getattr(transaction.get_payment_class(), "PreapprovalDetails")
p = method(t)
p = transaction.get_payment_class().PreapprovalDetails(t)
preapproval_status = {'id':t.id, 'key':t.preapproval_key}
@ -99,8 +94,7 @@ class PaymentManager( object ):
t = transaction
payment_status = {'id':t.id}
method = getattr(transaction.get_payment_class(), "PaymentDetails")
p = method(t)
p = transaction.get_payment_class().PaymentDetails(t)
if p.error() or not p.success():
logger.info("Error retrieving payment details for transaction %d" % t.id)
@ -414,8 +408,7 @@ class PaymentManager( object ):
transaction.date_executed = now()
transaction.save()
method = getattr(transaction.get_payment_class(), "Finish")
p = method(transaction)
p = transaction.get_payment_class().Finish(transaction)
# Create a response for this
envelope = p.envelope()
@ -469,8 +462,7 @@ class PaymentManager( object ):
transaction.date_payment = now()
transaction.save()
method = getattr(transaction.get_payment_class(), "Execute")
p = method(transaction)
p = transaction.get_payment_class().Execute(transaction)
# Create a response for this
envelope = p.envelope()
@ -510,12 +502,11 @@ class PaymentManager( object ):
'''
# does this transaction explicity require preapprovals?
requires_explicit_preapprovals = getattr(transaction.get_payment_class(), "requires_explicit_preapprovals")
requires_explicit_preapprovals = transaction.get_payment_class().requires_explicit_preapprovals
if requires_explicit_preapprovals():
if requires_explicit_preapprovals:
method = getattr(transaction.get_payment_class(), "CancelPreapproval")
p = method(transaction)
p = transaction.get_payment_class().CancelPreapproval(transaction)
# Create a response for this
envelope = p.envelope()
@ -576,8 +567,7 @@ class PaymentManager( object ):
urllib.urlencode({'tid':transaction.id}))
return_url = urlparse.urljoin(settings.BASE_URL, return_path)
method = getattr(transaction.get_payment_class(), "Preapproval")
p = method(transaction, transaction.amount, expiry, return_url=return_url, paymentReason=paymentReason)
p = transaction.get_payment_class().Preapproval(transaction, transaction.amount, expiry, return_url=return_url, paymentReason=paymentReason)
# Create a response for this
envelope = p.envelope()
@ -745,7 +735,7 @@ class PaymentManager( object ):
# does this transaction explicity require preapprovals?
requires_explicit_preapprovals = getattr(transaction.get_payment_class(), "requires_explicit_preapprovals")
requires_explicit_preapprovals = transaction.get_payment_class().requires_explicit_preapprovals
if transaction.type != PAYMENT_TYPE_AUTHORIZATION:
logger.info("Error, attempt to modify an invalid transaction type")
@ -786,7 +776,7 @@ class PaymentManager( object ):
credit.CancelPreapproval(transaction)
return t, reverse('fund_pledge', args=[t.id])
elif requires_explicit_preapprovals() and (amount > transaction.max_amount or expiry != transaction.date_expired):
elif requires_explicit_preapprovals and (amount > transaction.max_amount or expiry != transaction.date_expired):
# set the expiry date based on the campaign deadline
expiry = transaction.campaign.deadline + timedelta( days=settings.PREAPPROVAL_PERIOD_AFTER_CAMPAIGN )
@ -829,7 +819,7 @@ class PaymentManager( object ):
# corresponding notification to the user? that would go here.
return False, None
elif (requires_explicit_preapprovals() and amount <= transaction.max_amount) or (not requires_explicit_preapprovals()):
elif (requires_explicit_preapprovals and amount <= transaction.max_amount) or (not requires_explicit_preapprovals):
# Update transaction but leave the preapproval alone
transaction.amount = amount
transaction.set_pledge_extra(pledge_extra)
@ -862,8 +852,7 @@ class PaymentManager( object ):
logger.info("Refund Transaction failed, invalid transaction status")
return False
method = getattr(transaction.get_payment_class(), "RefundPayment")
p = method(transaction)
p = transaction.get_payment_class().RefundPayment(transaction)
# Create a response for this
envelope = p.envelope()
@ -921,8 +910,7 @@ class PaymentManager( object ):
t.date_payment=now()
t.execution=EXECUTE_TYPE_CHAINED_INSTANT
t.type=PAYMENT_TYPE_INSTANT
method = getattr(t.get_payment_class(), "Pay")
p = method(t,return_url=return_url, nevermind_url=nevermind_url)
p = t.get_payment_class().Pay(t,return_url=return_url, nevermind_url=nevermind_url)
# Create a response for this
envelope = p.envelope()
@ -955,8 +943,7 @@ class PaymentManager( object ):
"""delegate to a specific payment module the task of creating a payment account"""
mod = __import__("regluit.payment." + host, fromlist=[host])
method = getattr(mod, "make_account")
return method(user, token)
return mod.Processor().make_account(user, token)

View File

@ -1,7 +1,7 @@
from django.db import models
from django.contrib.auth.models import User
from django.conf import settings
from regluit.core.models import Campaign, Wishlist, Premium, PledgeExtra
from regluit.payment.parameters import *
from regluit.payment.signals import credit_balance_added, pledge_created
from regluit.utils.localdatetime import now
@ -78,8 +78,8 @@ class Transaction(models.Model):
# associated User, Campaign, and Premium for this Transaction
user = models.ForeignKey(User, null=True)
campaign = models.ForeignKey(Campaign, null=True)
premium = models.ForeignKey(Premium, null=True)
campaign = models.ForeignKey('core.Campaign', null=True)
premium = models.ForeignKey('core.Premium', null=True)
# how to acknowledge the user on the supporter page of the campaign ebook
ack_name = models.CharField(max_length=64, null=True)
@ -109,13 +109,13 @@ class Transaction(models.Model):
def get_payment_class(self):
'''
Returns the specific payment module that implements this transaction
Returns the specific payment processor that implements this transaction
'''
if self.host == PAYMENT_HOST_NONE:
return None
else:
mod = __import__("regluit.payment." + self.host, fromlist=[str(self.host)])
return mod
return mod.Processor()
def set_credit_approved(self, amount):
self.amount=amount
@ -137,10 +137,12 @@ class Transaction(models.Model):
self.ack_dedication = pledge_extra.ack_dedication
def get_pledge_extra(self, pledge_extra):
return PledgeExtra(anonymous=self.anonymous,
premium=self.premium,
ack_name=self.ack_name,
ack_dedication=self.ack_dedication)
class pe:
premium=self.premium
anonymous=self.anonymous
ack_name=self.ack_name
ack_dedication=self.ack_dedication
return pe
@classmethod
def create(cls,amount=0.00, host=PAYMENT_HOST_NONE, max_amount=0.00, currency='USD',

View File

@ -7,15 +7,16 @@ from pytz import utc
from django.conf import settings
from regluit.payment.models import Account
from regluit.payment.parameters import PAYMENT_HOST_STRIPE
from regluit.payment.parameters import TRANSACTION_STATUS_ACTIVE, TRANSACTION_STATUS_COMPLETE, PAYMENT_TYPE_AUTHORIZATION, TRANSACTION_STATUS_CANCELED
from regluit.payment import baseprocessor
from regluit.utils.localdatetime import now, zuluformat
import stripe
logger = logging.getLogger(__name__)
class StripeError(Exception):
pass
@ -260,62 +261,13 @@ class PledgeScenarioTest(TestCase):
print "list of events", cls._sc.event.all()
print [(i, e.id, e.type, e.created, e.pending_webhooks, e.data) for (i,e) in enumerate(cls._sc.event.all()['data'])]
class StripePaymentRequest(object):
'''
Handles common information incident to payment processing
class StripePaymentRequest(baseprocessor.BasePaymentRequest):
"""so far there is no need to have a separate class here"""
pass
'''
class Processor(baseprocessor.Processor):
# Global values for the class
response = None
raw_response = None
errorMessage = None
status = None
url = None
def ack( self ):
return None
def success(self):
if self.errorMessage:
return False
else:
return True
def error(self):
if self.errorMessage:
return True
else:
return False
def error_data(self):
return None
def error_id(self):
return None
def error_string(self):
return self.errorMessage
def envelope(self):
# The envelope is used to store info about this request
if self.response:
return str(self.response)
else:
return None
def correlation_id(self):
return None
def timestamp(self):
return str(datetime.datetime.now())
def requires_explicit_preapprovals():
"""a function that returns for the given payment processor"""
return False
def make_account(user, token):
def make_account(self, user, token):
"""returns a payment.models.Account based on stripe token and user"""
sc = StripeClient()
@ -324,9 +276,6 @@ def make_account(user, token):
customer = sc.create_customer(card=token, description=user.username,
email=user.email)
from regluit.payment.models import Account
account = Account(host = PAYMENT_HOST_STRIPE,
account_id = customer.id,
card_last4 = customer.active_card.last4,
@ -342,31 +291,10 @@ def make_account(user, token):
return account
class Pay(StripePaymentRequest):
class Pay(StripePaymentRequest, baseprocessor.Processor.Pay):
pass
'''
The pay function generates a redirect URL to approve the transaction
'''
def __init__( self, transaction, return_url=None, amount=None, paymentReason=""):
self.transaction=transaction
def api(self):
return "null api"
def exec_status( self ):
return None
def amount( self ):
return None
def key( self ):
return None
def next_url( self ):
return self.url
class Preapproval(StripePaymentRequest):
class Preapproval(StripePaymentRequest, baseprocessor.Processor.Preapproval):
def __init__( self, transaction, amount, expiry=None, return_url=None, paymentReason=""):

View File

@ -14,7 +14,6 @@ from regluit.payment.models import Transaction
from regluit.core.models import Campaign, Wishlist, Work
from regluit.core.signals import handle_transaction_charged
from regluit.payment.parameters import *
from regluit.payment.paypal import *
import traceback
from django.core.validators import URLValidator
from django.core.exceptions import ValidationError

View File

@ -1,5 +1,4 @@
from regluit.payment.manager import PaymentManager
from regluit.payment.paypal import IPN
from regluit.payment.models import Transaction
from regluit.core.models import Campaign, Wishlist

View File

@ -49,6 +49,5 @@ ssh==1.7.14
stevedore==0.4
stripe==1.7.4
virtualenv==1.4.9
virtualenv-clone==0.2.4
virtualenvwrapper==3.6
wsgiref==0.1.2

View File

@ -21,7 +21,8 @@ DATABASES = {
'PASSWORD': 'forgetn0t',
'HOST': 'justdb.cboagmr25pjs.us-east-1.rds.amazonaws.com',
'PORT': '',
'TEST_CHARSET': 'utf8'
'TEST_CHARSET': 'utf8',
'TEST_COLLATION': 'utf8_bin'
}
}

View File

@ -1,7 +1,6 @@
from regluit.core import models
from regluit.payment.models import Transaction, PaymentResponse, Receiver
from regluit.payment.manager import PaymentManager
from regluit.payment.paypal import IPN_PREAPPROVAL_STATUS_ACTIVE, IPN_PAY_STATUS_INCOMPLETE, IPN_PAY_STATUS_COMPLETED
import django
from django.conf import settings
@ -14,9 +13,6 @@ import unittest, time, re
import logging
import os
# PayPal developer sandbox
from regluit.payment.tests import loginSandbox, paySandbox, payAmazonSandbox
def setup_selenium():
# Set the display window for our xvfb
os.environ['DISPLAY'] = ':99'
@ -305,195 +301,7 @@ def test_relaunch(unglue_it_url = settings.LIVE_SERVER_TEST_URL, do_local=True,
yield sel
def support_campaign(unglue_it_url = settings.LIVE_SERVER_TEST_URL, do_local=True, backend='amazon', browser='firefox'):
"""
programatically fire up selenium to make a Pledge
do_local should be True only if you are running support_campaign on db tied to LIVE_SERVER_TEST_URL
"""
django.db.transaction.enter_transaction_management()
UNGLUE_IT_URL = unglue_it_url
USER = settings.UNGLUEIT_TEST_USER
PASSWORD = settings.UNGLUEIT_TEST_PASSWORD
setup_selenium()
if browser == 'firefox':
sel = webdriver.Firefox()
elif browser == 'chrome':
sel = webdriver.Chrome(executable_path='/Users/raymondyee/C/src/Gluejar/regluit/test/chromedriver')
elif browser == 'htmlunit':
# HTMLUNIT with JS -- not successful
sel = webdriver.Remote("http://localhost:4444/wd/hub", webdriver.DesiredCapabilities.HTMLUNITWITHJS)
else:
sel = webdriver.Firefox()
time.sleep(10)
# find a campaign to pledge to
if backend == 'paypal':
loginSandbox(sel)
time.sleep(2)
print "now opening unglue.it"
#sel.get("http://www.google.com")
sel.get(UNGLUE_IT_URL)
# long wait because sel is slow after PayPal
sign_in_link = WebDriverWait(sel, 100).until(lambda d : d.find_element_by_xpath("//span[contains(text(),'Sign In')]/.."))
sign_in_link.click()
# enter unglue.it login info
input_username = WebDriverWait(sel,20).until(lambda d : d.find_element_by_css_selector("input#id_username"))
input_username.send_keys(USER)
sel.find_element_by_css_selector("input#id_password").send_keys(PASSWORD)
sel.find_element_by_css_selector("input[value*='sign in']").click()
# click on biggest campaign list
# I have no idea why selenium thinks a is not displayed....so that's why I'm going up one element.
# http://stackoverflow.com/a/6141678/7782
biggest_campaign_link = WebDriverWait(sel,20).until(lambda d: d.find_element_by_css_selector("li > a[href*='/campaigns/ending']"))
biggest_campaign_link.click()
time.sleep(1)
# pull up one of the campaigns to pledge to
# for now, take the first book and click on the link to get to the work page
work_links = WebDriverWait(sel,10).until(lambda d: d.find_elements_by_css_selector("div.book-list div.title a"))
work_links[0].click()
support_button = WebDriverWait(sel,10).until(lambda d: d.find_element_by_css_selector("input[value*='Support']"))
support_button.click()
# just click Pledge button without filling out amount -- should have the form validation spot the error
pledge_button = WebDriverWait(sel,20).until(lambda d: d.find_element_by_css_selector("input[value*='Pledge']"))
pledge_button.click()
# check to see whether there is an error
error_messages = WebDriverWait(sel,20).until(lambda d: d.find_elements_by_css_selector("ul.errorlist"))
if len(error_messages):
print "yes: Error in just hitting pledge button as expected"
else:
print "ooops: there should be an error message when pledge button hit"
# fill out a premium -- the first one for now
premium_button = WebDriverWait(sel,20).until(lambda d: d.find_element_by_css_selector('input[type="radio"][value="1"]'))
premium_button.click()
print "making $10 pledge"
# now we have to replace the current preapproval amount with 10
sel.execute_script("""document.getElementById("id_preapproval_amount").value="10";""")
# must also pick a premium level -- otherwise there will not be a pledge_button -- let's pick the first premium ($1)
premium_button = WebDriverWait(sel,20).until(lambda d: d.find_element_by_css_selector('input[type="radio"][value="1"]'))
premium_button.click()
pledge_button = WebDriverWait(sel,20).until(lambda d: d.find_element_by_css_selector("input[value*='Pledge']"))
pledge_button.click()
# grab the URL where sel is now?
if backend == 'paypal':
print "Now trying to pay PayPal", sel.current_url
paySandbox(None, sel, sel.current_url, authorize=True, already_at_url=True, sleep_time=5)
elif backend == 'amazon':
payAmazonSandbox(sel)
# should be back on a pledge complete page
print sel.current_url, re.search(r"/pledge/complete",sel.current_url)
time.sleep(2)
django.db.transaction.commit()
# time out to simulate an IPN -- update all the transactions
if do_local:
django.db.transaction.enter_transaction_management()
pm = PaymentManager()
print pm.checkStatus()
transaction0 = Transaction.objects.all()[0]
print "transaction amount:{0}, transaction premium:{1}".format(transaction0.amount, transaction0.premium.id)
django.db.transaction.commit()
django.db.transaction.enter_transaction_management()
# I have no idea what the a[href*="/work/"] is not displayed....so that's why I'm going up one element.
work_url = WebDriverWait(sel,20).until(lambda d: d.find_element_by_css_selector('p > a[href*="/work/"]'))
work_url.click()
# change_pledge
print "clicking Modify Pledge button"
change_pledge_button = WebDriverWait(sel,20).until(lambda d: d.find_element_by_css_selector("input[value*='Modify Pledge']"))
change_pledge_button.click()
# enter a new pledge, which is less than the previous amount and therefore doesn't require a new PayPal transaction
print "changing pledge to $5 -- should not need to go to PayPal"
preapproval_amount_input = WebDriverWait(sel,20).until(lambda d: d.find_element_by_css_selector("input#id_preapproval_amount"))
preapproval_amount_input.clear() # get rid of existing pledge
preapproval_amount_input.send_keys("5")
pledge_button = WebDriverWait(sel,20).until(lambda d: d.find_element_by_css_selector("input[value*='Modify Pledge']"))
pledge_button.click()
# return to the Work page again
work_url = WebDriverWait(sel,20).until(lambda d: d.find_element_by_css_selector('p > a[href*="/work/"]'))
work_url.click()
change_pledge_button = WebDriverWait(sel,20).until(lambda d: d.find_element_by_css_selector("input[value*='Modify Pledge']"))
change_pledge_button.click()
# enter a new pledge, which is more than the previous amount and therefore requires a new PayPal transaction
preapproval_amount_input = WebDriverWait(sel,20).until(lambda d: d.find_element_by_css_selector("input#id_preapproval_amount"))
preapproval_amount_input.clear() # get rid of existing pledge
preapproval_amount_input.send_keys("25")
pledge_button = WebDriverWait(sel,20).until(lambda d: d.find_element_by_css_selector("input[value*='Modify Pledge']"))
pledge_button.click()
if backend == 'paypal':
paySandbox(None, sel, sel.current_url, authorize=True, already_at_url=True, sleep_time=5)
elif backend == 'amazon':
payAmazonSandbox(sel)
# wait a bit to allow PayPal sandbox to be update the status of the Transaction
time.sleep(10)
django.db.transaction.commit()
# time out to simulate an IPN -- update all the transactions
if do_local:
django.db.transaction.enter_transaction_management()
pm = PaymentManager()
print pm.checkStatus()
django.db.transaction.commit()
django.db.transaction.enter_transaction_management()
# now go back to the work page, hit modify pledge, and then the cancel link
work_url = WebDriverWait(sel,20).until(lambda d: d.find_element_by_css_selector('p > a[href*="/work/"]'))
work_url.click()
change_pledge_button = WebDriverWait(sel,20).until(lambda d: d.find_element_by_css_selector("input[value*='Modify Pledge']"))
change_pledge_button.click()
cancel_url = WebDriverWait(sel,20).until(lambda d: d.find_element_by_css_selector('a[href*="/pledge/cancel"]'))
cancel_url.click()
# hit the confirm cancellation button
cancel_pledge_button = WebDriverWait(sel,20).until(lambda d: d.find_element_by_css_selector("input[value*='Confirm Pledge Cancellation']"))
cancel_pledge_button.click()
django.db.transaction.commit()
# Why is the status of the new transaction not being updated?
# force a db lookup -- see whether there are 1 or 2 transactions
# they should both be cancelled
if do_local:
transactions = list(Transaction.objects.all())
print "number of transactions", Transaction.objects.count()
print "transactions before pm.checkStatus"
print [(t.id, t.type, t.preapproval_key, t.status, t.premium, t.amount) for t in Transaction.objects.all()]
print "checkStatus:", pm.checkStatus(transactions=transactions)
yield sel
#sel.quit()
def successful_campaign_signal():
"""fire off a success_campaign signal and send notifications"""