fix for multiple agreements
authorJan Szejko <janek37@gmail.com>
Sun, 2 Sep 2018 12:05:16 +0000 (14:05 +0200)
committerJan Szejko <janek37@gmail.com>
Sun, 2 Sep 2018 12:05:16 +0000 (14:05 +0200)
src/paypal/rest.py

index 9d9f45a..3590c6f 100644 (file)
@@ -115,11 +115,8 @@ def check_agreement(agreement_id):
 
 
 def user_is_subscribed(user):
 
 
 def user_is_subscribed(user):
-    try:
-        agreement = BillingAgreementModel.objects.get(user=user)
-    except BillingAgreementModel.DoesNotExist:
-        return False
-    return agreement.check_agreement()
+    agreements = BillingAgreementModel.objects.filter(user=user)
+    return any(agreement.check_agreement() for agreement in agreements)
 
 
 def execute_agreement(token):
 
 
 def execute_agreement(token):