Skip to content

Commit

Permalink
Merge pull request #398 from ticosax/readability
Browse files Browse the repository at this point in the history
Simpler code
  • Loading branch information
paltman committed Oct 13, 2017
2 parents 92b1588 + 0930f3f commit d93cbd1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pinax/stripe/actions/charges.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def sync_charge_from_stripe_data(data):
obj.customer = models.Customer.objects.filter(stripe_id=data["customer"]).first()
obj.source = data["source"]["id"]
obj.currency = data["currency"]
obj.invoice = next(iter(models.Invoice.objects.filter(stripe_id=data["invoice"])), None)
obj.invoice = models.Invoice.objects.filter(stripe_id=data["invoice"]).first()
obj.amount = utils.convert_amount_for_db(data["amount"], obj.currency)
obj.paid = data["paid"]
obj.refunded = data["refunded"]
Expand Down
4 changes: 2 additions & 2 deletions pinax/stripe/actions/customers.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def get_customer_for_user(user):
Returns:
a pinax.stripe.models.Customer object
"""
return next(iter(models.Customer.objects.filter(user=user)), None)
return models.Customer.objects.filter(user=user).first()


def purge_local(customer):
Expand Down Expand Up @@ -119,7 +119,7 @@ def link_customer(event):
cus_id = event.message["data"]["object"].get("customer", None)

if cus_id is not None:
customer = next(iter(models.Customer.objects.filter(stripe_id=cus_id)), None)
customer = models.Customer.objects.filter(stripe_id=cus_id).first()
if customer is not None:
event.customer = customer
event.save()
Expand Down

0 comments on commit d93cbd1

Please sign in to comment.