From 8481bbf3b9fe2d4ecc5009dc06b17ffdf6fb867d Mon Sep 17 00:00:00 2001 From: Brett Smith Date: Fri, 17 Feb 2017 15:11:32 -0500 Subject: [PATCH] python models: Supporter.supporter_type() handles untagged payments. --- python/supporters/models.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/python/supporters/models.py b/python/supporters/models.py index ba711d2..b9e6e36 100644 --- a/python/supporters/models.py +++ b/python/supporters/models.py @@ -112,7 +112,12 @@ class Supporter: return expose_wrapper def _supporter_type(self, payments): - return payments.last().program.rsplit(':', 1)[-1] + for payment in payments.reverse(): + if payment.program is not None: + break + else: + return None + return payment.program.rsplit(':', 1)[-1] supporter_type = _expose(_supporter_type) def _calculate_lapse_date(self, last_payment_date, supporter_type):